lola-mcp-server 0.1.0__tar.gz → 0.1.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {lola_mcp_server-0.1.0 → lola_mcp_server-0.1.4}/PKG-INFO +1 -1
- {lola_mcp_server-0.1.0 → lola_mcp_server-0.1.4}/lola_mcp_server.egg-info/PKG-INFO +1 -1
- lola_mcp_server-0.1.4/public_mcp_server.py +96 -0
- {lola_mcp_server-0.1.0 → lola_mcp_server-0.1.4}/pyproject.toml +1 -1
- lola_mcp_server-0.1.0/public_mcp_server.py +0 -95
- {lola_mcp_server-0.1.0 → lola_mcp_server-0.1.4}/README.md +0 -0
- {lola_mcp_server-0.1.0 → lola_mcp_server-0.1.4}/lola_mcp_server.egg-info/SOURCES.txt +0 -0
- {lola_mcp_server-0.1.0 → lola_mcp_server-0.1.4}/lola_mcp_server.egg-info/dependency_links.txt +0 -0
- {lola_mcp_server-0.1.0 → lola_mcp_server-0.1.4}/lola_mcp_server.egg-info/entry_points.txt +0 -0
- {lola_mcp_server-0.1.0 → lola_mcp_server-0.1.4}/lola_mcp_server.egg-info/requires.txt +0 -0
- {lola_mcp_server-0.1.0 → lola_mcp_server-0.1.4}/lola_mcp_server.egg-info/top_level.txt +0 -0
- {lola_mcp_server-0.1.0 → lola_mcp_server-0.1.4}/setup.cfg +0 -0
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
from mcp.server.fastmcp import FastMCP
|
|
2
|
+
import httpx
|
|
3
|
+
import os
|
|
4
|
+
import asyncio
|
|
5
|
+
import base64
|
|
6
|
+
import json
|
|
7
|
+
|
|
8
|
+
mcp = FastMCP("Lola Suite MCP Bridge")
|
|
9
|
+
|
|
10
|
+
BASE_URL = os.getenv("LOLA_BASE_URL")
|
|
11
|
+
ACCESS_TOKEN = os.getenv("LOLA_ACCESS_TOKEN")
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
# ---------------- SAFETY CHECK ----------------
|
|
15
|
+
|
|
16
|
+
if not BASE_URL or not BASE_URL.startswith("http"):
|
|
17
|
+
raise RuntimeError("LOLA_BASE_URL must be a full https:// URL")
|
|
18
|
+
|
|
19
|
+
if not ACCESS_TOKEN:
|
|
20
|
+
raise RuntimeError("LOLA_ACCESS_TOKEN is required")
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def headers():
|
|
24
|
+
return {
|
|
25
|
+
"Authorization": f"Bearer {ACCESS_TOKEN}",
|
|
26
|
+
"Content-Type": "application/json",
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
# ---------------- DECODE TOKEN ----------------
|
|
31
|
+
|
|
32
|
+
def get_allowed_tools():
|
|
33
|
+
"""
|
|
34
|
+
Extract allowed tool list from the access token payload
|
|
35
|
+
"""
|
|
36
|
+
payload = ACCESS_TOKEN.split(".")[0]
|
|
37
|
+
decoded = base64.b64decode(payload).decode()
|
|
38
|
+
data = json.loads(decoded)
|
|
39
|
+
|
|
40
|
+
return set(
|
|
41
|
+
data.get("selections", {})
|
|
42
|
+
.get("lola_server", [])
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
# ---------------- DYNAMIC TOOL REGISTRATION ----------------
|
|
47
|
+
|
|
48
|
+
async def register_tools():
|
|
49
|
+
allowed = get_allowed_tools()
|
|
50
|
+
|
|
51
|
+
async with httpx.AsyncClient(timeout=30.0) as client:
|
|
52
|
+
res = await client.get(f"{BASE_URL}/tools_lola", headers=headers())
|
|
53
|
+
res.raise_for_status()
|
|
54
|
+
tools = res.json()["tools"]
|
|
55
|
+
|
|
56
|
+
for tool in tools:
|
|
57
|
+
tool_name = tool["name"]
|
|
58
|
+
|
|
59
|
+
# 🔒 Filter tools by access token
|
|
60
|
+
if tool_name not in allowed:
|
|
61
|
+
continue
|
|
62
|
+
|
|
63
|
+
input_schema = tool["input_schema"]
|
|
64
|
+
description = tool.get("description", "")
|
|
65
|
+
|
|
66
|
+
# ⚠️ Important: capture tool_name correctly (closure fix)
|
|
67
|
+
async def dynamic_tool(tool_name=tool_name, **kwargs):
|
|
68
|
+
async with httpx.AsyncClient(timeout=30.0) as client:
|
|
69
|
+
r = await client.post(
|
|
70
|
+
f"{BASE_URL}/call_lola",
|
|
71
|
+
json={"name": tool_name, "arguments": kwargs},
|
|
72
|
+
headers=headers(),
|
|
73
|
+
)
|
|
74
|
+
r.raise_for_status()
|
|
75
|
+
return r.json()
|
|
76
|
+
|
|
77
|
+
mcp.tool(
|
|
78
|
+
name=tool_name,
|
|
79
|
+
description=description,
|
|
80
|
+
input_schema=input_schema,
|
|
81
|
+
)(dynamic_tool)
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
# ---------------- MAIN ----------------
|
|
85
|
+
|
|
86
|
+
async def startup():
|
|
87
|
+
await register_tools()
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
def main():
|
|
91
|
+
asyncio.run(startup())
|
|
92
|
+
mcp.run()
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
if __name__ == "__main__":
|
|
96
|
+
main()
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
from mcp.server.fastmcp import FastMCP
|
|
2
|
-
import httpx
|
|
3
|
-
import os
|
|
4
|
-
import asyncio
|
|
5
|
-
|
|
6
|
-
mcp = FastMCP("Lola Suite MCP Bridge")
|
|
7
|
-
|
|
8
|
-
# Change only via ENV later (no code edits needed)
|
|
9
|
-
BASE_URL = os.getenv(
|
|
10
|
-
"LOLA_BASE_URL",
|
|
11
|
-
"https://extraneous-blaine-seclusive.ngrok-free.dev"
|
|
12
|
-
)
|
|
13
|
-
|
|
14
|
-
API_KEY = os.getenv("LOLA_API_KEY", "SUPER_SECRET_KEY_123")
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
def headers():
|
|
18
|
-
return {
|
|
19
|
-
"Authorization": f"Bearer {API_KEY}",
|
|
20
|
-
"Content-Type": "application/json",
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
# ---------------- HEALTH CHECK ----------------
|
|
25
|
-
|
|
26
|
-
async def health_check():
|
|
27
|
-
async with httpx.AsyncClient(timeout=10.0) as client:
|
|
28
|
-
try:
|
|
29
|
-
r = await client.get(f"{BASE_URL}/tools_lola", headers=headers())
|
|
30
|
-
r.raise_for_status()
|
|
31
|
-
print(" Connected to backend:", BASE_URL)
|
|
32
|
-
except Exception as e:
|
|
33
|
-
raise RuntimeError(
|
|
34
|
-
f"Cannot reach backend at {BASE_URL}. "
|
|
35
|
-
"Make sure FastAPI and ngrok are running."
|
|
36
|
-
) from e
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
# ---------------- HUBSPOT ----------------
|
|
40
|
-
|
|
41
|
-
@mcp.tool()
|
|
42
|
-
async def hubspot_list_tools():
|
|
43
|
-
"""List all HubSpot tools"""
|
|
44
|
-
async with httpx.AsyncClient(timeout=30.0) as client:
|
|
45
|
-
r = await client.get(f"{BASE_URL}/tools_hubspot", headers=headers())
|
|
46
|
-
r.raise_for_status()
|
|
47
|
-
return r.json()
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
@mcp.tool()
|
|
51
|
-
async def hubspot_call_tool(name: str, arguments: dict):
|
|
52
|
-
"""Call a HubSpot tool"""
|
|
53
|
-
async with httpx.AsyncClient(timeout=30.0) as client:
|
|
54
|
-
r = await client.post(
|
|
55
|
-
f"{BASE_URL}/call_hubspot",
|
|
56
|
-
json={"name": name, "arguments": arguments},
|
|
57
|
-
headers=headers(),
|
|
58
|
-
)
|
|
59
|
-
r.raise_for_status()
|
|
60
|
-
return r.json()
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
# ---------------- LOLA ----------------
|
|
64
|
-
|
|
65
|
-
@mcp.tool()
|
|
66
|
-
async def lola_list_tools():
|
|
67
|
-
"""List all Lola tools"""
|
|
68
|
-
async with httpx.AsyncClient(timeout=30.0) as client:
|
|
69
|
-
r = await client.get(f"{BASE_URL}/tools_lola", headers=headers())
|
|
70
|
-
r.raise_for_status()
|
|
71
|
-
return r.json()
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
@mcp.tool()
|
|
75
|
-
async def lola_call_tool(name: str, arguments: dict):
|
|
76
|
-
"""Call a Lola tool"""
|
|
77
|
-
async with httpx.AsyncClient(timeout=30.0) as client:
|
|
78
|
-
r = await client.post(
|
|
79
|
-
f"{BASE_URL}/call_lola",
|
|
80
|
-
json={"name": name, "arguments": arguments},
|
|
81
|
-
headers=headers(),
|
|
82
|
-
)
|
|
83
|
-
r.raise_for_status()
|
|
84
|
-
return r.json()
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
# ---------------- MAIN ----------------
|
|
88
|
-
|
|
89
|
-
def main():
|
|
90
|
-
asyncio.run(health_check())
|
|
91
|
-
mcp.run()
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
if __name__ == "__main__":
|
|
95
|
-
main()
|
|
File without changes
|
|
File without changes
|
{lola_mcp_server-0.1.0 → lola_mcp_server-0.1.4}/lola_mcp_server.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|