MCP Tools Server
Tool execution layer of Cosmos — provider architecture, tool visibility, and where to find the full API reference
Updated 2026-11-03
Verified 2026-11-03
The MCP Tools Server (cosmos-mcp-v3) is the tool execution layer of the Cosmos platform. Built on FastMCP, it exposes tools over HTTP REST and the MCP protocol to two audiences: internal clients (ADK, JumpStart apps) get organization-specific API, DB, custom, and connector tools, and external AI assistants (Claude Desktop, Factory) get Cosmos platform management tools (cosmos_*) over MCP with OAuth2.
Why It Matters
MCP is where a tool call actually executes. Configurator owns tool definitions and ADK decides which tools an agent needs; MCP runs the HTTP call, database query, or connector invocation, and caps response size so a large tool output cannot overflow an agent's context window.
Architecture At A Glance
MCP provider and middleware architecture
SourceLoading diagram...
Tool providers:
| Provider | Source | Description |
|---|---|---|
RedisToolProvider | Redis DB 11 | API, custom, and DB tools from the Kafka-synced cache |
ConnectorProvider | Redis and external servers | External MCP servers (for example GitHub, Gmail, Stripe, SAP HANA) configured per organization |
LocalProvider | Code | Inbuilt tools and the cosmos_* platform tools |
HTTP authentication: MCPAuthMiddleware (ASGI) protects the MCP transport path (MCP_PATH, default /mcp). It accepts a bearer token or an access_token cookie and caches session authorization. ADK's service client (cosmos-adk-v3) must send X-Org-Id and a delegated user (X-On-Behalf-Of-User-Id or X-Subject-User-Id), or the request is rejected with 403. Other callers must hold mcp.tool.call or mcp.tool.list. REST routes check permissions per route.
FastMCP middleware, in order: AutoSyncMiddleware (fetches tools missing from the cache from Configurator), ResilientPingMiddleware (15-second keep-alive), and ResponseLimitingMiddleware (caps tool output at 500 KB).
Tool search: a BM25 search transform replaces the full catalog with two synthetic tools, search_tools (up to 8 results) and call_tool. The pinned tools and get_current_user stay visible without searching.
Key Capabilities
- Two-level auto-sync — a tool missing from cache is fetched from Configurator and synced to Redis, either per call (
/tools/call/) or in batch when ADK'sX-MCP-Toolsheader lists an agent's tools. - Tool visibility — requests without
X-Org-Id(external assistants) see thecosmos_*tools,get_current_user, and the search tools. Requests withX-Org-Idsee the organization's tools withoutcosmos_*, unlessX-Cosmos-Platform-Assistantistrue; platform write tools then also needX-Cosmos-Platform-Write-Confirmed. - Connector tools — external MCP servers configured per organization. Each discovered tool is tagged with its
org_idand connector for scoped filtering. - Inbuilt tools —
get_current_user,knowledge_base,web_browse, and the DMS family:dms_read_file,dms_write_file,dms_delete_file,dms_list_files,dms_search_files,dms_file_exists,dms_move_file,dms_get_file_url, anddms_merge_documents. - Knowledge base authorization — when
X-Project-Idis sent,knowledge_baseauthorizes each collection and graph against the project (cosmos.kb.read), checks it against the agent's resource manifest, and forwardsX-Project-Idto RAGflow. - Cosmos platform tools — 63
cosmos_*tools covering tools, agents, apps, skills, templates, prompts, knowledge base, connectors, files, and guardrails. Agent tools accept pinned skill and sub-agent versions. Five are pinned regardless of search:cosmos_list_organizations,cosmos_list_files,cosmos_upload_file,cosmos_get_direct_endpoints,cosmos_get_bearer_token. - OAuth2 proxy for external clients — when
MCP_OAUTH_ENABLEDis on, clients discover/.well-known/oauth-authorization-server, register, are redirected through/authorizeto the User Service login, and exchange a code for a token at/token. MCP passes the User Service JWT through; it does not mint its own.
API Overview
| Area | Routes |
|---|---|
| Health | GET /health/ |
| REST tools | GET /tools/list/, POST /tools/call/, GET /tools/debug/org/{org_id}/ |
| Catalog | GET /custom-tools/, GET /custom-tools/{name}, GET /connectors/, GET /connectors/{name} |
| MCP transport | Streamable HTTP at /mcp |
| OAuth2 | /.well-known/oauth-protected-resource, /.well-known/oauth-authorization-server, /register, /authorize, /token |
→ Full API reference: MCP API
Configuration
MCP runs on Python 3.12–3.13 and uses uv for dependencies (uv sync, uv run server.py). Key dependencies: fastmcp==3.4.10, mcp==1.30.0, confluent-kafka, redis, httpx, database drivers, and connector SDKs. Telemetry uses azure-monitor-opentelemetry: the container entrypoint runs the server and the Kafka consumer under opentelemetry-instrument and maps APPINSIGHTSCONNECTIONSTRING to APPLICATIONINSIGHTS_CONNECTION_STRING.
| Variable | Default | Purpose |
|---|---|---|
HYPERSCALER | local | local, azure, or gcp behavior |
MCP_BIND_HOST, MCP_BIND_PORT | 0.0.0.0, 8000 | Listen address (published on 8102 locally) |
MCP_PATH | /mcp | MCP transport path |
REDIS_HOST, REDIS_PORT, REDISPASSWORD, REDIS_SSL | localhost, 6379, empty, 1 | Tool cache (DB 11) |
KAFKA_BOOTSTRAP_SERVER, KAFKA_TOPIC_CONSUMER, KAFKA_CONSUMER_GROUP | —, configurator, mcp-consumer-group | Tool sync consumer |
CONFIGURATOR_SERVICE_URL | — | Tool definitions for auto-sync |
USER_SERVICE_URL, RETRIEVAL_SERVICE_URL, STORAGE_SERVICE_URL | — | Auth, knowledge base, and DMS backends |
COSMOS_SERVICE_CLIENT_ID, COSMOS_MCP_SERVICE_CLIENT_SECRET | — | Service OAuth client |
COSMOS_SERVICE_AUDIENCE | cosmos-mcp-v3 | Expected token audience |
TOOL_AUTO_SYNC_ENABLED, TOOL_AUTO_SYNC_TIMEOUT | true, 10 | Auto-sync switch and timeout in seconds |
MCP_OAUTH_ENABLED, MCP_PUBLIC_URL, OAUTH_CLIENT_ID, OAUTH_CLIENT_SECRET | false | OAuth2 proxy for external clients |
Integration Points
| Service | Integration |
|---|---|
| Configurator | Tool definitions for auto-sync (/api/v1/tools/mcp-list/) |
| User Service | JWT validation, authorization checks, OAuth2 login |
| ADK | Primary consumer through MCPToolset |
| Kafka | tools-consumer container syncs configurator topic events to Redis |
| Redis | DB 11 tool cache |
| RAGflow, Storage | Backends for knowledge_base and DMS tools |
Troubleshooting
- Tools not appearing after deployment — check the
tools-consumerlogs (./manage.sh dev logs tools-consumer), confirm the tool is deployed in Configurator, and restart with./manage.sh dev restart tools-server. - Auto-sync failures — search the tools-server logs for "Auto-sync"; verify
CONFIGURATOR_SERVICE_URL,COSMOS_SERVICE_CLIENT_ID, andCOSMOS_MCP_SERVICE_CLIENT_SECRET. - OAuth2 not working — verify
MCP_OAUTH_ENABLED=trueand the OAuth client variables, confirm the User Service is reachable (curl http://localhost:8101/health/), and run./manage.sh <env> setup-oauthto regenerate the OAuth application.
Changelog
See the MCP changelog for verified changes.