arcade-mcp/libs/tests/arcade_mcp_server
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
..
integration Fix: Skip currently executing file during tool discovery (#668) 2025-11-03 11:26:51 -08:00
transports MCP Local (#563) 2025-09-25 15:28:15 -07:00
__init__.py MCP Local (#563) 2025-09-25 15:28:15 -07:00
conftest.py MCP Local (#563) 2025-09-25 15:28:15 -07:00
test_context.py Fix MCP capabilities, examples, tests, and more (#657) 2025-10-30 11:59:00 -07:00
test_convert.py MCP Local (#563) 2025-09-25 15:28:15 -07:00
test_error_handling_middleware.py MCP Local (#563) 2025-09-25 15:28:15 -07:00
test_logging_middleware.py MCP Local (#563) 2025-09-25 15:28:15 -07:00
test_mcp_app.py Improve arcade deploy CLI Command (#634) 2025-11-03 11:19:04 -08:00
test_middleware_base.py MCP Local (#563) 2025-09-25 15:28:15 -07:00
test_openapi_docs.py MCP Local (#563) 2025-09-25 15:28:15 -07:00
test_prompt.py MCP Local (#563) 2025-09-25 15:28:15 -07:00
test_public_imports.py MCP Local (#563) 2025-09-25 15:28:15 -07:00
test_resource.py MCP Local (#563) 2025-09-25 15:28:15 -07:00
test_server.py Disallow executing auth/secret tools for unauthenticated servers using HTTP transport (#641) 2025-10-22 13:14:46 -07:00
test_session.py MCP Local (#563) 2025-09-25 15:28:15 -07:00
test_session_cancellation.py MCP Local (#563) 2025-09-25 15:28:15 -07:00
test_settings.py Fix server info bug (#614) 2025-10-13 13:04:18 -07:00
test_tool.py MCP Local (#563) 2025-09-25 15:28:15 -07:00