Skip to content

API Reference parrot.handlers.mcp_helper

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot.handlers.mcp_helper

View source

MCP Helper HTTP Handler — discovery, activation, and management of MCP servers.

Provides four endpoints under /api/v1/agents/chat/{agent_id}/mcp-servers:

  • GET /mcp-servers — return the full catalog of pre-built helpers
  • POST /mcp-servers — activate a server on the session ToolManager
  • GET /mcp-servers/active — list active MCP servers in the session
  • DELETE /mcp-servers/{name} — deactivate a server

Routes are registered by :func:setup_mcp_helper_routes.

The activation flow:

  1. Validate params via :class:~parrot.mcp.registry.MCPServerRegistry.
  2. Separate secret params from non-secret params.
  3. Encrypt secrets and store in DocumentDB (user_credentials collection).
  4. Call the corresponding create_*_mcp_server factory to build config.
  5. Register on the session-scoped ToolManager.
  6. Persist non-secret config via :class:~parrot.handlers.mcp_persistence.MCPPersistenceService.

Alias ActivateMCPServerRequest

Re-exported from parrot.mcp.registry.ActivateMCPServerRequest.

Class MCPActiveHandler

HTTP handler that returns the currently active MCP servers in the session.

Handles one route:

  • GET /api/v1/agents/chat/{agent_id}/mcp-servers/active

Method MCPActiveHandler.get

Return the list of active MCP servers from the session ToolManager.

get() -> web.Response

Returns: web.Response — 200 JSON array of active server names.

Class MCPHelperHandler

HTTP handler for MCP server catalog listing and activation.

Handles two routes:

  • GET /api/v1/agents/chat/{agent_id}/mcp-servers — full catalog
  • POST /api/v1/agents/chat/{agent_id}/mcp-servers — activate server

Method MCPHelperHandler.get

Return the full catalog of pre-built MCP server helpers.

get() -> web.Response

Returns: web.Response — 200 JSON array of :class:~parrot.mcp.registry.MCPServerDescriptor objects serialized as dicts.

Method MCPHelperHandler.post

Activate a pre-built MCP server on the session ToolManager.

Request body (JSON): .. code-block:: json

    {"server": "perplexity", "params": {"api_key": "sk-..."}}

post() -> web.Response

Returns: web.Response — 200 JSON with registered tool names. 400 if params validation fails or server already active. 502 if the MCP server fails to connect. 500 on Vault or config-build errors.

Alias MCPParamType

Re-exported from parrot.mcp.registry.MCPParamType.

Alias MCPPersistenceService

Re-exported from parrot.handlers.mcp_persistence.MCPPersistenceService.

Class MCPServerItemHandler

HTTP handler for deactivating a specific MCP server.

Handles one route:

  • DELETE /api/v1/agents/chat/{agent_id}/mcp-servers/{server_name}

Method MCPServerItemHandler.delete

Deactivate an MCP server: remove from ToolManager, soft-delete from DB.

The Vault credential (if any) is also hard-deleted per the spec decision.

delete() -> web.Response

Returns: web.Response — 200 JSON confirmation message. 500 on database errors.

Alias MCPServerRegistry

Re-exported from parrot.mcp.registry.MCPServerRegistry.

Alias ToolManager

Re-exported from parrot.tools.manager.ToolManager.

Alias UserMCPServerConfig

Re-exported from parrot.mcp.registry.UserMCPServerConfig.

Alias agent_tooling_ref

Re-exported from parrot.tools.spec.agent_tooling_ref.

Alias delete_vault_credential

Re-exported from parrot.handlers.vault_utils.delete_vault_credential.

Alias get_factory_map

Re-exported from parrot.mcp.registry.get_factory_map.

Attribute logger

Function setup_mcp_helper_routes

Register MCP helper management routes on the aiohttp application.

Registers four routes:

  • GET /api/v1/agents/chat/{agent_id}/mcp-servers → :class:MCPHelperHandler (catalog)
  • POST /api/v1/agents/chat/{agent_id}/mcp-servers → :class:MCPHelperHandler (activate)
  • GET /api/v1/agents/chat/{agent_id}/mcp-servers/active → :class:MCPActiveHandler (list active)
  • DELETE /api/v1/agents/chat/{agent_id}/mcp-servers/{server_name} → :class:MCPServerItemHandler (deactivate)

setup_mcp_helper_routes(app: web.Application) -> None

Parameter Type Default Description
app web.Application The aiohttp :class:~aiohttp.web.Application instance.

Alias store_vault_credential

Re-exported from parrot.handlers.vault_utils.store_vault_credential.

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally