FastMCP Dishka
Integration package for using dishka dependency injection with FastMCP tools, resources, and prompts.
It provides:
FastMCPProviderwith FastMCP request context objects for dishka.setup_dishka()middleware that opens aScope.REQUESTcontainer per tool/resource/prompt call.@injectsupport for parameters marked asFromDishka[T].
Usage
from dishka import Provider, Scope, make_async_container, provide
from fastmcp import FastMCP
from fastmcp_dishka import FastMCPProvider, FromDishka, inject, setup_dishka
class GreetingService:
def greet(self, name: str) -> str:
return f"Hello, {name}!"
class AppProvider(Provider):
greeting = provide(GreetingService, scope=Scope.REQUEST)
mcp = FastMCP("GreetMCP")
container = make_async_container(AppProvider(), FastMCPProvider())
setup_dishka(container, mcp)
@mcp.tool
@inject
async def greet(name: str, service: FromDishka[GreetingService]) -> str:
return service.greet(name)
Place @inject below FastMCP decorators so FastMCP registers the wrapped
function signature.
@mcp.prompt defines a reusable prompt template exposed to MCP clients. A
prompt does not perform an action like a tool; it returns text or chat messages
that a client can insert into an LLM conversation.
@mcp.prompt
@inject
async def welcome_prompt(
name: str,
service: FromDishka[GreetingService],
) -> str:
return f"Write a short welcome message for: {service.greet(name)}"
See examples/fastmcp_app.py for a complete FastMCP server with a tool, resource, prompt, and Dishka providers.
Development
Install development dependencies:
uv sync --dev
Run tests with coverage:
make test
Run linting and formatting:
make lint
make format
Install pre-commit hooks:
make pre-commit-install
Metadata
Release files for fastmcp-dishka 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| fastmcp_dishka-1.0.0.tar.gz | 8.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| fastmcp_dishka-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 19.1 kB
Release files / fastmcp_dishka-1.0.0.tar.gz
| Download URL | fastmcp_dishka-1.0.0.tar.gz |
|---|---|
| Size | 8.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4b7bc9f8c7b5c878bde9c03481eb5cb906e1d0848106d6eaba68f99242fe4110
|
|
BLAKE2b-256 checksum How to use checksums |
c5315faf25ece6b2cf6676e4c74cead27473bf131a88fb3536647632fe536a6f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 15, 2026.
Transparency logRelease files / fastmcp_dishka-1.0.0-py3-none-any.whl
| Download URL | fastmcp_dishka-1.0.0-py3-none-any.whl |
|---|---|
| Size | 10.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
23dcbf241ca70390097d6aa1c239c789fbdaf0d6ef614689ec992240f242962c
|
|
BLAKE2b-256 checksum How to use checksums |
4c57bd31bb924f00f80a08ecb1574b34e6c7924624cc5762e00d4565555390eb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 15, 2026.
Transparency log