Skip to content

feat: add MCP tool server discovery and invocation endpoint #1436

@syn-zhu

Description

@syn-zhu

Summary

Add three new MCP tools to the kagent-controller's existing MCP endpoint at :8083/mcp for dynamic tool server discovery and invocation:

Tool Purpose
list_tool_servers List all tool servers across RemoteMCPServer, Service (with kagent.dev/mcp-service=true), and MCPServer CRs
list_tools Connect to a specific tool server and return its available tools
call_tool Invoke a specific tool on a specific tool server

Motivation

This was originally proposed as kagent-dev/kmcp#123 but the reviewer correctly noted that it belongs in kagent instead of kmcp, because:

  1. kagent already watches all three tool source types — RemoteMCPServer, Service, and MCPServer (optional)
  2. kagent already has an MCP handler at :8083/mcp with list_agents / invoke_agent
  3. kmcp should stay focused on deployment — translating MCPServer CRs into Kubernetes resources

Moving to kagent provides unified discovery across all tool sources, not just MCPServer CRs.

Design

  • Ref format: Kind/namespace/name (e.g. RemoteMCPServer/default/my-server, Service/tools/prometheus, MCPServer/default/weather)
  • Session caching: sync.Map with evict-and-retry on stale connections
  • URL derivation: Reuses existing ConvertServiceToRemoteMCPServer and ConvertMCPServerToRemoteMCPServer from the translator package
  • MCPServer CRD is optional: Gracefully returns empty list if kmcp is not installed

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions