-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.py
More file actions
56 lines (43 loc) · 1.91 KB
/
server.py
File metadata and controls
56 lines (43 loc) · 1.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
"""API-Football MCP Server — comprehensive MCP server for API-Football v3."""
import argparse
import sys
from mcp.server.fastmcp import FastMCP
mcp = FastMCP(
"API-Football",
instructions=(
"Football/soccer data server powered by API-Football v3. "
"Use search_team, search_player, search_league, search_coach, or search_venue "
"to find IDs by name before calling other tools. "
"Most tools require numeric IDs (team, player, league, fixture). "
"Season is typically a 4-digit year (e.g., 2024 for the 2024/25 season). "
"Common league IDs: 39=Premier League, 140=La Liga, 135=Serie A, 78=Bundesliga, 61=Ligue 1, "
"2=Champions League, 3=Europa League."
),
host="0.0.0.0",
port=8111,
)
# Ensure this module is available as 'server' in sys.modules even when run as __main__,
# so that tool modules doing 'from server import mcp' get the same mcp instance.
if __name__ == "__main__" and "server" not in sys.modules:
sys.modules["server"] = sys.modules[__name__]
def register_tools():
"""Register all tools — called after mcp is created to avoid circular imports."""
import tools # noqa: F401
def main():
parser = argparse.ArgumentParser(description="API-Football MCP Server")
parser.add_argument(
"--transport",
choices=["stdio", "sse", "streamable-http"],
default="streamable-http",
help="Transport protocol (default: streamable-http)",
)
parser.add_argument("--host", default="0.0.0.0", help="Host to bind to (default: 0.0.0.0)")
parser.add_argument("--port", type=int, default=8111, help="Port to bind to (default: 8111)")
args = parser.parse_args()
mcp._host = args.host
mcp._port = args.port
register_tools()
print(f"Starting API-Football MCP Server on {args.host}:{args.port} ({args.transport})")
mcp.run(transport=args.transport)
if __name__ == "__main__":
main()