Hacktoberfest 2026: as issues que os mantenedores marcaram para outubro, abertas e boas para iniciantes. Ver issues do Hacktoberfest

[Feature] De-couple Starlette from FastMCP to make it easier to implement MCP endpoints in other frameworks

Aberta
#622 1 comentário 15 reações 0 responsáveis Ver no GitHub

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
5/5
Tempo estimado
Mais de uma semana
Facilidade para iniciantes
30/100
Tipo de issue
Funcionalidade
Clareza
Razoavelmente clara
Status de atividade
Estagnada
Stack de tecnologia
django, python
Domínio
api, backend

Direção de pesquisa

Revise a integração de baixo nível do MCPServer, os tool/resource/prompt managers, os decoradores e os métodos handler descritos na issue. Compare as configurações específicas do Starlette, o transporte e o roteamento com o limite proposto do FastMCPBase, incluindo a referência do Context ao FastMCP; considera-se concluído quando o código independente de framework mantém esses recursos, enquanto o FastMCP mantém as preocupações do Starlette.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

enhancement needs decision P3 v2

If someone wanted to implement an MCP server in another framework such as Django or some other ASGI implementation, one would have to use the mcp.server.lowlevel.Server class and implement handlers for the low-level server. This means we have to sacrifice a ton of functionality from FastMCP that really has nothing to do with the python server backend. For example tool/resource/prompt managers, decorators, etc would have to be re-impemented.

It seems that these features of FastMCP could be decoupled in to a base class or mixin that handles all the tool/resource/prompt management & decorators, as well as the integration with the low-level Server. You could then extend that class to implement your own server with all the routing and request/response logic.

The proposed base class would have minimal dependencies on these framework-specific concerns:

Base Class Dependencies:

  • MCPServer from mcp.server.lowlevel.server
  • Tool/Resource/Prompt managers
  • Basic handler methods (list_tools, call_tool, etc.)
  • The decorators (@tool, @resource, @prompt)

Server-specific Responsibilities:

  • Settings handling (Settings class with HTTP config)
  • Transport logic (stdio vs SSE)
  • Routing (custom_route, Starlette routing)
class FastMCPBase:
    """Base class or mixin with tool/resource/prompt management and core handlers"""
    
    def __init__(self, name: str, instructions: str = None):
        self._mcp_server = MCPServer(name=name, instructions=instructions)
        self._tool_manager = ToolManager()
        self._resource_manager = ResourceManager()
        self._prompt_manager = PromptManager()
        self._setup_handlers()
    
    # All the @tool, @resource, @prompt decorators
    # All the list_tools, call_tool, etc. handler methods
    # Context management

class FastMCP(FastMCPBase):
    """Starlette-specific implementation"""
    
    def __init__(self, name: str, **settings):
        super().__init__(name)
        self.settings = Settings(**settings)
        self._custom_starlette_routes = []
    
    # Only Starlette-specific methods like sse_app, routing, etc.

The implementation in the other library could look like this:

class DjangoMCP(FastMCPBase):
    """Django-specific implementation"""
    # Django-specific routing & transport logic

One slight complication could be the Context class as it has a reference to the FastMCP instance (self._fastmcp. However the only function that's used is read_resource which would already be on the base class. So possible just need to change the type hint to use the base class.

Linguagem predominante
Python
Estrelas
24.3k
Forks
4k
Merge médio
1d 11h
PRs com merge (30d)
30

Guia de contribuição

Abrir o guia de contribuição

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de modelcontextprotocol/python-sdk

Todas as issues de modelcontextprotocol/python-sdk

Issues semelhantes

Mais issues de Python

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.