-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmcp_server.py
More file actions
65 lines (58 loc) · 1.58 KB
/
Copy pathmcp_server.py
File metadata and controls
65 lines (58 loc) · 1.58 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
57
58
59
60
61
62
63
64
65
import os
import httpx
from mcp.server.fastmcp import FastMCP
BASE = os.environ.get('DATALEADS_BASE_URL', 'https://data.dataleads.pro/v1')
KEY = os.environ.get('DATALEADS_API_KEY', '')
mcp = FastMCP('App Store & Google Play Data API')
def _call(path, payload):
body = {'clientKey': KEY}
body.update(payload or {})
r = httpx.post(BASE + path, json=body, headers={'Authorization': 'Bearer ' + KEY}, timeout=120)
r.raise_for_status()
return r.json()
TOOLS = [
{
"name": "app_gplay_details",
"method": "POST",
"path": "/app/gplay/details",
"description": "V1 App Gplay Details"
},
{
"name": "app_gplay_reviews",
"method": "POST",
"path": "/app/gplay/reviews",
"description": "V1 App Gplay Reviews"
},
{
"name": "app_apple_search",
"method": "POST",
"path": "/app/apple/search",
"description": "V1 App Apple Search"
},
{
"name": "app_apple_details",
"method": "POST",
"path": "/app/apple/details",
"description": "V1 App Apple Details"
},
{
"name": "app_apple_reviews",
"method": "POST",
"path": "/app/apple/reviews",
"description": "V1 App Apple Reviews"
}
]
def _register():
import json as _json
for t in TOOLS:
def _make(t=t):
def _tool(payload: dict) -> dict:
return _call(t['path'], payload)
_tool.__name__ = t['name']
_tool.__doc__ = t['description']
return _tool
fn = _make()
mcp.tool()(fn, name=t['name'], description=t['description'])
_register()
if __name__ == '__main__':
mcp.run()