Dishka dependency injection for FastMCP tools, resources, and prompts with request scopes and deterministic finalization.
View on GitHub ↗Homepage ↗dishka IoC container integration for FastMCP. Declare dependencies as FromDishka[Service] in MCP tools, resources and prompts and let dishka resolve them per request — with real scopes, finalization and modular providers, sharing one container with the rest of your application.
The client sees a tool that takes only item — catalog is injected at call time and never appears in the schema.
Requires Python 3.11+, dishka=1.10.1, fastmcp=3.2.4,<4.
Registration time and execution time are separate concerns:
- @inject sits below the FastMCP decorator. @mcp.tool builds the JSON schema from the function signature. @inject rewrites that signature first, stripping every FromDishka parameter, so the schema the LLM sees contains only the real client-facing arguments. Order matters — @inject must be the inner decorator. - setupdishka registers a middleware that publishes the root container and current FastMCP objects through ContextVars. @inject then opens and finalizes Scope.REQUEST around the handler in the thread where it executes. This keeps sync dependency setup, use and cleanup in the same worker thread.
Scope Boundary Lifetime --------------------------- Scope.APP The whole server Owned by the root container; you close it on shutdown (see below) Scope.REQUEST One tool call / resource read / prompt render Opened and finalized by @inject around the handler
Scope.SESSION is intentionally not supported. FastMCP's middleware exposes a session-start hook (oninitialize) but no session-teardown hook, so a session-lifetime container could never be finalized deterministically. Rather
From the project README.
Add the radar badge to your README — it shows your project was picked up by MCP Radar and links to this page:
[](https://mcp.liqiwa.com/s/bagowix--dishka-fastmcp.html)
Authenticated, self-hosted WhatsApp MCP server that serves 96 tools for the token cost of 29, with a labeled eval for tool-retrieval accuracy. Go bridge + Python FastMCP.
AdamRussak/self-docSelf-hosted documentation RAG pipeline that serves semantic search to LLM agents over the Model Context Protocol.
nisargpatel1906/Aethos_MemoryUniversal, cross-tool persistent memory bank for AI assistants (Claude Code, Cursor, Windsurf, OpenCode, Codex) powered by FastMCP, Gemini embeddings & Supabase pgvector.
bybit-exchange/kaasTurn scattered notes, docs and transcripts into a queryable Markdown wiki — an LLM knowledge-base compiler with MCP access, no embeddings, self-hosted.
Vladimir-Human/ru-marketplace-mcpДевять российских маркетплейсов и китайский Taobao как MCP-серверы: Wildberries, Ozon, Яндекс Маркет, Детский мир, Авито, Мегамаркет, Lamoda, DNS, Ситилинк. Плюс сравнение цен по всем сразу. Только чт
aka-kika/hig-mcpMCP server serving Apple Human Interface Guidelines as structured design tokens for AI coding agents — post-WWDC25 system colors, Liquid Glass constraints, SwiftUI mappings.
The top new MCP servers of the week, every Monday. No spam, unsubscribe anytime.