[SPIKE-001] MCP Integration Pattern #1

Closed
opened 2025-12-29 03:49:29 +00:00 by cardosofelipe · 1 comment

Objective

Research and validate the approach for integrating MCP (Model Context Protocol) servers with the FastAPI backend.

Key Questions

  1. How do we instantiate MCP clients within FastAPI's dependency injection system?
  2. What's the connection lifecycle? (per-request, singleton, pool?)
  3. How do we handle MCP server failures gracefully?
  4. How do we pass project_id scoping to MCP tool calls?
  5. What's the security model for MCP tool permissions?

Research Areas

  • Anthropic MCP SDK documentation and examples
  • FastAPI async patterns for external service calls
  • Connection pooling strategies
  • Error handling and retry patterns

Expected Deliverables

  • Proof-of-concept integration with gitea-mcp server
  • Recommended architecture pattern
  • ADR documenting the decision

Acceptance Criteria

  • Can call MCP tools from FastAPI endpoint
  • Handles connection failures gracefully
  • Works with project_id scoping
  • Performance acceptable (<100ms overhead)

Labels

spike, architecture, mcp

## Objective Research and validate the approach for integrating MCP (Model Context Protocol) servers with the FastAPI backend. ## Key Questions 1. How do we instantiate MCP clients within FastAPI's dependency injection system? 2. What's the connection lifecycle? (per-request, singleton, pool?) 3. How do we handle MCP server failures gracefully? 4. How do we pass `project_id` scoping to MCP tool calls? 5. What's the security model for MCP tool permissions? ## Research Areas - [ ] Anthropic MCP SDK documentation and examples - [ ] FastAPI async patterns for external service calls - [ ] Connection pooling strategies - [ ] Error handling and retry patterns ## Expected Deliverables - Proof-of-concept integration with gitea-mcp server - Recommended architecture pattern - ADR documenting the decision ## Acceptance Criteria - [ ] Can call MCP tools from FastAPI endpoint - [ ] Handles connection failures gracefully - [ ] Works with project_id scoping - [ ] Performance acceptable (&lt;100ms overhead) ## Labels `spike`, `architecture`, `mcp`
cardosofelipe added the architecturemcppriority:highspike labels 2025-12-29 03:54:32 +00:00
Author
Owner

Spike Completed

Research completed and documented in:

  • Spike Document: docs/spikes/SPIKE-001-mcp-integration-pattern.md
  • ADR: docs/adrs/ADR-001-mcp-integration-architecture.md

Key Findings:

  • Use FastMCP 2.0 for all MCP server implementations
  • Unified singleton pattern with explicit project_id/agent_id scoping
  • SSE transport for MCP server connections
  • 7 MCP servers: LLM Gateway, Git, KB, Issues, FS, Code Analysis, CI/CD

Decision:

Adopt FastMCP 2.0 with unified singleton servers and explicit project/agent scoping for all MCP integrations.

This spike can be closed.

## Spike Completed Research completed and documented in: - **Spike Document:** `docs/spikes/SPIKE-001-mcp-integration-pattern.md` - **ADR:** `docs/adrs/ADR-001-mcp-integration-architecture.md` ### Key Findings: - Use **FastMCP 2.0** for all MCP server implementations - **Unified singleton pattern** with explicit project_id/agent_id scoping - **SSE transport** for MCP server connections - 7 MCP servers: LLM Gateway, Git, KB, Issues, FS, Code Analysis, CI/CD ### Decision: Adopt FastMCP 2.0 with unified singleton servers and explicit project/agent scoping for all MCP integrations. This spike can be closed.
Sign in to join this conversation.