Hacktoberfest 2026: die Issues, die Maintainer für den Oktober markiert haben – offen und einsteigerfreundlich. Hacktoberfest-Issues durchsuchen

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

Offen
#622 1 Kommentar 15 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Anfängerfreundlichkeit
30/100
Issue-Typ
Feature
Klarheit
Größtenteils klar
Aktivitätsstatus
Veraltet
Tech-Stack
django, python
Bereich
api, backend

Rechercherichtung

Überprüfe die im Issue beschriebenen Low-Level-Integrationen von MCPServer, tool/resource/prompt managers, Decorators und Handler-Methoden. Vergleiche Starlette-spezifische Einstellungen, den Transport und das Routing mit der vorgeschlagenen FastMCPBase-Grenze, einschließlich der FastMCP-Referenz von Context; als abgeschlossen gilt die Arbeit, wenn framework-unabhängiger Code diese Fähigkeiten beibehält, während FastMCP die Starlette-Belange behält.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

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.

Vorherrschende Sprache
Python
Sterne
24.3k
Forks
4k
Ø Merge
1 T. 11 Std.
Gemergte PRs (30 T.)
30

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus modelcontextprotocol/python-sdk

Alle Issues in modelcontextprotocol/python-sdk

Ähnliche Issues

Weitere Issues zu Python

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.