-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmcp_stdio.py
More file actions
51 lines (36 loc) · 1.22 KB
/
Copy pathmcp_stdio.py
File metadata and controls
51 lines (36 loc) · 1.22 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
#!/usr/bin/env python3
"""ShotAPI MCP Server — stdio transport for Claude Code / Claude Desktop / Cursor
Usage:
# Add to Claude Code (free tier):
claude mcp add shotapi python mcp_stdio.py
# With paid tier API Key:
claude mcp add shotapi -e SHOTAPI_KEY=shotapi_pro_xxx python mcp_stdio.py
# Or use remote mode (no install):
claude mcp add --transport streamable-http shotapi https://aiphotoshop.mynatapp.cc/mcp
"""
import asyncio
import atexit
import os
import argparse
# Parse --shotapi-key arg (Smithery passes config this way)
parser = argparse.ArgumentParser()
parser.add_argument("--shotapi-key", default="", help="ShotAPI API Key for paid tiers")
args, _ = parser.parse_known_args()
if args.shotapi_key and not os.getenv("SHOTAPI_KEY"):
os.environ["SHOTAPI_KEY"] = args.shotapi_key
from mcp_server import mcp, close_client
def _cleanup():
try:
client_loop = asyncio.new_event_loop()
client_loop.run_until_complete(close_client())
client_loop.close()
except Exception:
pass
atexit.register(_cleanup)
async def main():
try:
await mcp.run_stdio_async()
finally:
await close_client()
if __name__ == "__main__":
asyncio.run(main())