arcade-mcp/libs/tests
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_mcp_server Fix: Skip currently executing file during tool discovery (#668) 2025-11-03 11:26:51 -08:00
cli Server start events (#635) 2025-10-22 16:14:52 -07:00
core Fix MCP capabilities, examples, tests, and more (#657) 2025-10-30 11:59:00 -07:00
mcp MCP Local (#563) 2025-09-25 15:28:15 -07:00
sdk [READY][PROD-215][TDK] Adding Slack error adaptor (#577) 2025-09-24 17:26:37 -03:00
tool Tool Error Handling (#539) 2025-09-10 10:45:18 -07:00
worker MCP Local (#563) 2025-09-25 15:28:15 -07:00
__init__.py 🏗️ Restructure: Multi-Package Architecture + uv Migration (#412) 2025-06-11 16:48:17 -07:00
conftest.py Don't send events when running CLI commands in unit tests (#600) 2025-10-03 16:29:53 -07:00