#5346·fastmcp

Unable to use third-party DI markers (e.g. dependency-injector) in tool signatures

Author: TheLazzziestCreated Sep 28, 2026Updated Sep 28, 2026
Labelsenhancementserverlow-priority

What happened?

Hey! While I've been working a tool-versioning layer on top of FastMCP pyverge and I ran into what looks like a gap in how injected params are detected. Wanted to check whether it's intentional or a bug.

Context

FastMCP recognizes injected parameters only when the default is an uncalled_for.base.Dependency subclass (fastmcp/server/dependencies.py, get_dependency_parameters). Parameter defaults using another DI library:dependency_injector.wiring.Provide; in my case, are not detected, so they are treated as payload parameters.

Example Code

python
# pip install fastmcp dependency-injector

from dependency_injector.wiring import Provide, inject
from fastmcp import FastMCP


class WeatherService:
    def forecast(self, city: str) -> dict:
        return {"city": city}

class Container(containers.DeclarativeContainer):
    weather_service = providers.Singleton(WeatherService)


container = Container()

@inject
def search_weather(city: str, weather: WeatherService = Provide["weather_service"]) -> dict:
    return weather.forecast(city)


mcp = FastMCP("repro")
mcp.tool(search_weather)

Version Information

4.0.10