Skip to content

Enable raise errors in tool_manager._load_tools #1531

@huiwy

Description

@huiwy

Enhancement

There may be errors when listing tools, but i cannot know the existance of errors besides the warning.

from fastmcp import Client

async def main():
    client = Client({
        "a": {
            "command": "uvx",
            "args": ["--version"],
        },
        "b": {
            "command": "uvx",
            "args": ["--version"],
        },
    })

    await client._connect()
    print(await client.list_tools())

if __name__ == "__main__":
    import asyncio
    asyncio.run(main())

output:

[08/18/25 14:06:00] WARNING  Failed to get tools from server: 'FastMCP', mounted at: 'a': Client failed to connect: Connection closed                          tool_manager.py:86
                    WARNING  Failed to get tools from server: 'FastMCP', mounted at: 'b': Client failed to connect: Connection closed                          tool_manager.py:86
[]

Is it possible to add an env variable or an argument to explicitly raise an error to inform me?

For example

tools/tool_manager

    async def _load_tools(self, *, via_server: bool = False) -> dict[str, Tool]:
        try:
        ...
        except Exception as e:
                # Skip failed mounts silently, matches existing behavior
+                if os.envron.get("RAISE_ERROR_GET_TOOLS", "false") == "true": raise e
                logger.warning(
                    f"Failed to get tools from server: {mounted.server.name!r}, mounted at: {mounted.prefix!r}: {e}"
                )
                continue

Metadata

Metadata

Assignees

No one assigned

    Labels

    clientRelated to the FastMCP client SDK or client-side functionality.enhancementImprovement to existing functionality. For issues and smaller PR improvements.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions