Skip to content

Server-side exception logging for expected control-flow errors creates noise in error monitoring #4035

@daniel-tsiang

Description

@daniel-tsiang

Enhancement

Problem

When using FastMCP errors as control flow to guide LLM behavior, every error triggers logger.exception() on the server side, creating noise in production error monitoring systems (Sentry, DataDog, etc.).

Example workflow where this happens:

@mcp.tool
def check_model_status(model_id: str) -> dict:
    if not model_registry.is_deployed(model_id):
        # This is expected behavior to guide the LLM, not a bug
        # But it logs a full stack trace server-side
        raise ToolError(f"Model {model_id} not deployed. Call deploy_model first.")
    return model_registry.get_status(model_id)

In multi-step LLM workflows, errors often represent normal operation (prerequisite checks, validation, state machine transitions) rather than bugs. The LLM needs to see these error messages to know what to do next, but server operators don't need stack traces for expected behavior.

Currently, there's no way to send an error to the LLM client without also logging it server-side as an exception.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementImprovement to existing functionality. For issues and smaller PR improvements.serverRelated to FastMCP server implementation or server-side functionality.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions