-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.py
More file actions
50 lines (39 loc) · 1.34 KB
/
Copy pathserver.py
File metadata and controls
50 lines (39 loc) · 1.34 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
#!/usr/bin/env python3
"""MCP Server for GitHub API."""
import logging
from fastmcp import FastMCP
from fastmcp_credentials import CredentialMiddleware, HeaderCredentialBackend
from github_mcp.cli import parse_args
from github_mcp.config import configure_logging
from github_mcp.tools import register_tools
configure_logging()
logger = logging.getLogger("github-mcp-server")
backend = HeaderCredentialBackend()
mcp = FastMCP(
"MewCP GitHub MCP Server", middleware=[CredentialMiddleware(backend, "oauth")]
)
register_tools(mcp)
# Expose ASGI app for hosted runtimes.
app = mcp.http_app(path="/mcp", transport="streamable-http", stateless_http=True)
if __name__ == "__main__":
logger.info("=" * 60)
logger.info("GitHub MCP Server Starting")
logger.info("=" * 60)
args = parse_args()
run_kwargs = {}
if args.transport:
run_kwargs["transport"] = args.transport
logger.info("Transport: %s", args.transport)
if args.host:
run_kwargs["host"] = args.host
logger.info("Host: %s", args.host)
if args.port:
run_kwargs["port"] = args.port
logger.info("Port: %s", args.port)
try:
mcp.run(**run_kwargs)
except KeyboardInterrupt:
logger.info("Server stopped !")
except Exception as exc:
logger.error("Server crashed: %s", exc, exc_info=True)
raise