-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmcp_server.py
More file actions
41 lines (34 loc) · 1010 Bytes
/
Copy pathmcp_server.py
File metadata and controls
41 lines (34 loc) · 1010 Bytes
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
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('Tech Stack Detector 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": "tech",
"method": "POST",
"path": "/tech",
"description": "V1 Tech"
}
]
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()