arcade-mcp/libs
Eric Gustin d89b3a53d4
Fix: Skip currently executing file during tool discovery (#668)
### The Bug:
When an entrypoint file imports its parent package and
calls add_tools_from_module() on that package, and the same entrypoint
file also defines tools using @app.tool or @tool decorators, then the
server fails to start with an `AttributeError`. This is because the
tools would be discovered via AST parsing, but those tools weren't added
to the module's namespace yet because the file is still executing.

For example, this would fail on startup:
```py
#!/usr/bin/env python3
"""local_filesystem MCP server"""

import sys
from typing import Annotated

from arcade_mcp_server import MCPApp

import local_filesystem

app = MCPApp(name="eric_server", version="1.0.0", log_level="DEBUG")


app.add_tools_from_module(local_filesystem)


@app.tool
def eric(name: Annotated[str, "The name of the person to greet"]) -> str:
    """Greet a person by name."""
    return "return"


if __name__ == "__main__":
    transport = sys.argv[1] if len(sys.argv) > 1 else "stdio"

    app.run(transport="http", host="127.0.0.1", port=8074)
```

### The fix:
Skip the entrypoint file. This means that any tool defined inside of the
entrypoint file must be added via MCPApp.add_tool(...) or instead use
the recommended @app.tool.
2025-11-03 11:26:51 -08:00
..
arcade-cli Improve arcade deploy CLI Command (#634) 2025-11-03 11:19:04 -08:00
arcade-core Fix: Skip currently executing file during tool discovery (#668) 2025-11-03 11:26:51 -08:00
arcade-evals MCP Local (#563) 2025-09-25 15:28:15 -07:00
arcade-mcp-server Improve arcade deploy CLI Command (#634) 2025-11-03 11:19:04 -08:00
arcade-serve Release libs for arcade-mcp (#598) 2025-10-03 12:11:25 -07:00
arcade-tdk Release libs for arcade-mcp (#598) 2025-10-03 12:11:25 -07:00
tests Fix: Skip currently executing file during tool discovery (#668) 2025-11-03 11:26:51 -08:00