Skip to main content

discovery.py

Source: src/sunholo/mcp/discovery.py

Functions

is_mcp_tool(tool_id: 'str') -> 'bool'

Check if a tool ID represents an MCP tool.

Args: tool_id: Tool identifier string.

Returns: True if this is an MCP tool (external_mcp or mcp_* prefix).

Classes

MCPDiscovery

Discovers and manages MCP tools from multiple servers.

Maintains a registry of MCP servers and their discovered tools. Tools are identified by the convention: mcp_{server_id}.

Usage: discovery = MCPDiscovery() discovery.register_server("search", url="http://localhost:8080/mcp") tools = await discovery.discover_all()

  • init(self)

    • Initialize self. See help(type(self)) for accurate signature.
  • add_to_available_tools(self, available_tools: 'List[str]') -> 'List[str]'

    • Add MCP tool IDs to an available tools list.

Adds the external_mcp generic tool and per-server tool IDs.

Args: available_tools: Existing available tools list.

Returns: Extended list with MCP tools added.

  • discover_all(self) -> 'List[Dict[str, Any]]'
    • Discover tools on all registered servers with auto_discover=True.

Returns: List of all discovered tool info dicts.

  • discover_server(self, server_id: 'str') -> 'List[Dict[str, Any]]'
    • Discover tools on a specific server.

Connects to the server via MCPClientManager and lists available tools.

Args: server_id: Server to discover.

Returns: List of discovered tool info dicts.

  • get_tool_info(self, tool_id: 'str') -> 'Optional[Dict[str, Any]]'
    • Get detailed info for a specific MCP tool.

Args: tool_id: Tool ID (e.g. "mcp_search" or "mcp_search_query").

Returns: Tool info dict, or None if not found.

  • get_tools_for_server(self, server_id: 'str') -> 'List[Dict[str, Any]]'

    • Get all discovered tools for a server.
  • list_discovered_tools(self) -> 'List[Dict[str, Any]]'

    • List all discovered tools across all servers.
  • list_servers(self) -> 'List[Dict[str, Any]]'

    • List all registered servers.
  • register_server(self, server_id: 'str', name: 'str' = '', description: 'str' = '', url: 'str' = '', command: 'str' = '', args: 'List[str] | None' = None, auth: 'str' = '', tags: 'List[str] | None' = None, auto_discover: 'bool' = True) -> 'None'

    • Register an MCP server for discovery.

Args: server_id: Unique identifier. name: Human-readable name. description: Server description. url: HTTP/SSE URL. command: Command for stdio transport. args: Command arguments. auth: Authentication token. tags: Categorization tags. auto_discover: Discover tools on startup.

  • unregister_server(self, server_id: 'str') -> 'None'
    • Remove a server from the registry.

MCPServerConfig

Configuration for an MCP server.

Args: server_id: Unique identifier for this server. name: Human-readable server name. description: Description of what this server provides. url: HTTP/SSE URL for the MCP server. command: Command for stdio transport (alternative to url). args: Command arguments for stdio transport. auth: Authentication token or method. tags: Categorization tags. auto_discover: Whether to discover tools on startup.

  • init(self, server_id: 'str', name: 'str' = '', description: 'str' = '', url: 'str' = '', command: 'str' = '', args: 'List[str] | None' = None, auth: 'str' = '', tags: 'List[str] | None' = None, auto_discover: 'bool' = True)

    • Initialize self. See help(type(self)) for accurate signature.
  • to_dict(self) -> 'Dict[str, Any]'

    • Serialize to dict.
Sunholo Multivac

Get in touch to see if we can help with your GenAI project.

Contact us

Other Links

Sunholo Multivac - GenAIOps

Copyright ©

Holosun ApS 2026