Skip to content

deprecation warning has unwanted sideeffects #3646

@Speedy1991

Description

@Speedy1991

What happened?

Hello, I look for a way to disable fastmcp.settings.deprecation_warnings = False

The problem is, fastmcp sets some defaults while __init__.py import:

# ensure deprecation warnings are displayed by default
if settings.deprecation_warnings:
    warnings.simplefilter("default", DeprecationWarning)

leading to problems if fastmcp is mounted as sibling to e.g. a django app, because this will change the default behavor and also show other warnings, like functools

DeprecationWarning: Argument name-based matching of 'info' is deprecated and will be removed in v1.0. Ensure that reserved arguments are annotated their respective types (i.e. use value: 'DirectiveValue[str]' instead of 'value: str' and 'info: Info' instead of a plain 'info').

and

RemovedInDjango60Warning: The default scheme will be changed from 'http' to 'https' in Django 6.0. Pass the forms.URLField.assume_scheme argument to silence this warning, or set the FORMS_URLFIELD_ASSUME_HTTPS transitional setting to True to opt into using 'https' as the new default scheme.

and

RemovedInDjango60Warning: CheckConstraint.check is deprecated in favor of .condition.

however i need to import fastmcp to change the setting and the code to enable/disable these warnings already run :/

My current workaround is to add this before any other imports in my asgi.py file:

import os

os.environ.setdefault('FASTMCP_DEPRECATION_WARNINGS', '0')

import sys
from contextlib import asynccontextmanager
import fastmcp
...
...

Version Information

FastMCP version:                                                  3.1.1
MCP version:                                                     1.26.0
Python version:                                                  3.14.0
Platform:                                     Windows-11-10.0.26200-SP0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working. Reports of errors, unexpected behavior, or broken functionality.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions