Skip to main content

FastMCP Dishka

CI PyPI Python License Ruff Coverage

Integration package for using dishka dependency injection with FastMCP tools, resources, and prompts.

It provides:

  • FastMCPProvider with FastMCP request context objects for dishka.
  • setup_dishka() middleware that opens a Scope.REQUEST container per tool/resource/prompt call.
  • @inject support for parameters marked as FromDishka[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)

Source distribution for fastmcp-dishka 1.0.0
File Size Uploaded
fastmcp_dishka-1.0.0.tar.gz 8.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for fastmcp-dishka 1.0.0
File Interpreter ABI Platform
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 log

Release 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

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

0.2.0

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page