lola-mcp-server 0.1.0__py3-none-any.whl → 0.1.4__py3-none-any.whl

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: lola-mcp-server
3
- Version: 0.1.0
3
+ Version: 0.1.4
4
4
  Summary: MCP bridge to Lola & HubSpot servers
5
5
  Requires-Dist: mcp
6
6
  Requires-Dist: httpx
@@ -0,0 +1,6 @@
1
+ public_mcp_server.py,sha256=JVw_g5MUaYAhWahkD7rzA_GbVnl9mCYfBnFAurKhLLI,2372
2
+ lola_mcp_server-0.1.4.dist-info/METADATA,sha256=el5qYIT_DwqZUlzYkEY6Ct4LFuvwQgpre_65KdnubDI,145
3
+ lola_mcp_server-0.1.4.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
4
+ lola_mcp_server-0.1.4.dist-info/entry_points.txt,sha256=7ohrLpfi22BMGEDWSgn0tQLet94CcyP5AX1Tk5DbalI,59
5
+ lola_mcp_server-0.1.4.dist-info/top_level.txt,sha256=mEMxVolBhbIAki_wnZGkv3e8U-6xFTL2TvC-iP2_MxU,18
6
+ lola_mcp_server-0.1.4.dist-info/RECORD,,
public_mcp_server.py CHANGED
@@ -2,92 +2,93 @@ from mcp.server.fastmcp import FastMCP
2
2
  import httpx
3
3
  import os
4
4
  import asyncio
5
+ import base64
6
+ import json
5
7
 
6
8
  mcp = FastMCP("Lola Suite MCP Bridge")
7
9
 
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
- )
10
+ BASE_URL = os.getenv("LOLA_BASE_URL")
11
+ ACCESS_TOKEN = os.getenv("LOLA_ACCESS_TOKEN")
13
12
 
14
- API_KEY = os.getenv("LOLA_API_KEY", "SUPER_SECRET_KEY_123")
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")
15
21
 
16
22
 
17
23
  def headers():
18
24
  return {
19
- "Authorization": f"Bearer {API_KEY}",
25
+ "Authorization": f"Bearer {ACCESS_TOKEN}",
20
26
  "Content-Type": "application/json",
21
27
  }
22
28
 
23
29
 
24
- # ---------------- HEALTH CHECK ----------------
30
+ # ---------------- DECODE TOKEN ----------------
25
31
 
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
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)
37
39
 
40
+ return set(
41
+ data.get("selections", {})
42
+ .get("lola_server", [])
43
+ )
38
44
 
39
- # ---------------- HUBSPOT ----------------
40
45
 
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()
46
+ # ---------------- DYNAMIC TOOL REGISTRATION ----------------
48
47
 
48
+ async def register_tools():
49
+ allowed = get_allowed_tools()
49
50
 
50
- @mcp.tool()
51
- async def hubspot_call_tool(name: str, arguments: dict):
52
- """Call a HubSpot tool"""
53
51
  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
-
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)
62
82
 
63
- # ---------------- LOLA ----------------
64
83
 
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()
84
+ # ---------------- MAIN ----------------
85
85
 
86
+ async def startup():
87
+ await register_tools()
86
88
 
87
- # ---------------- MAIN ----------------
88
89
 
89
90
  def main():
90
- asyncio.run(health_check())
91
+ asyncio.run(startup())
91
92
  mcp.run()
92
93
 
93
94
 
@@ -1,6 +0,0 @@
1
- public_mcp_server.py,sha256=eSqCe4WaHWJ2FrapGw24NQDWlua4MJl4Abo4vVNp3YI,2478
2
- lola_mcp_server-0.1.0.dist-info/METADATA,sha256=dGcKoCDhOpoAxHl27EfqlJUPR6CqJ34MuJZye0usCKw,145
3
- lola_mcp_server-0.1.0.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
4
- lola_mcp_server-0.1.0.dist-info/entry_points.txt,sha256=7ohrLpfi22BMGEDWSgn0tQLet94CcyP5AX1Tk5DbalI,59
5
- lola_mcp_server-0.1.0.dist-info/top_level.txt,sha256=mEMxVolBhbIAki_wnZGkv3e8U-6xFTL2TvC-iP2_MxU,18
6
- lola_mcp_server-0.1.0.dist-info/RECORD,,