Commit e7577e1
feat: add MCP tool server discovery and invocation endpoint
Adds three new MCP tools to the kagent-controller's existing MCP endpoint
at :8083/mcp, enabling dynamic discovery and invocation of tools across
all tool source types:
- list_tool_servers: Lists all tool servers (RemoteMCPServer, Service
with kagent.dev/mcp-service=true label, MCPServer CRs)
- list_tools: Connects to a tool server and returns its tool catalog
- call_tool: Invokes a specific tool on a specific tool server
This moves the functionality originally proposed in kagent-dev/kmcp#123
into kagent per reviewer feedback, since kagent already watches all three
resource types and has the existing MCP handler infrastructure.
Key design decisions:
- Unified ref format: Kind/namespace/name (e.g. RemoteMCPServer/default/my-server)
- Session caching with evict-and-retry for stale connections
- Reuses existing ConvertServiceToRemoteMCPServer and
ConvertMCPServerToRemoteMCPServer from the translator package
- MCPServer CRD is optional (graceful degradation if not installed)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>1 parent 0477163 commit e7577e1
4 files changed
Lines changed: 1066 additions & 3 deletions
File tree
- go/core/internal/mcp
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
31 | 32 | | |
| 33 | + | |
32 | 34 | | |
33 | 35 | | |
34 | 36 | | |
| |||
92 | 94 | | |
93 | 95 | | |
94 | 96 | | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
95 | 127 | | |
96 | 128 | | |
97 | 129 | | |
| |||
309 | 341 | | |
310 | 342 | | |
311 | 343 | | |
312 | | - | |
| 344 | + | |
313 | 345 | | |
314 | | - | |
315 | | - | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
316 | 353 | | |
317 | 354 | | |
0 commit comments