meshcode 1.2.5__tar.gz → 1.2.6__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.
Files changed (24) hide show
  1. {meshcode-1.2.5 → meshcode-1.2.6}/PKG-INFO +1 -1
  2. {meshcode-1.2.5 → meshcode-1.2.6}/meshcode/__init__.py +1 -1
  3. {meshcode-1.2.5 → meshcode-1.2.6}/meshcode/meshcode_mcp/server.py +22 -3
  4. {meshcode-1.2.5 → meshcode-1.2.6}/meshcode/setup_clients.py +28 -0
  5. {meshcode-1.2.5 → meshcode-1.2.6}/meshcode.egg-info/PKG-INFO +1 -1
  6. {meshcode-1.2.5 → meshcode-1.2.6}/pyproject.toml +1 -1
  7. {meshcode-1.2.5 → meshcode-1.2.6}/README.md +0 -0
  8. {meshcode-1.2.5 → meshcode-1.2.6}/meshcode/cli.py +0 -0
  9. {meshcode-1.2.5 → meshcode-1.2.6}/meshcode/comms_v4.py +0 -0
  10. {meshcode-1.2.5 → meshcode-1.2.6}/meshcode/launcher.py +0 -0
  11. {meshcode-1.2.5 → meshcode-1.2.6}/meshcode/launcher_install.py +0 -0
  12. {meshcode-1.2.5 → meshcode-1.2.6}/meshcode/meshcode_mcp/__init__.py +0 -0
  13. {meshcode-1.2.5 → meshcode-1.2.6}/meshcode/meshcode_mcp/__main__.py +0 -0
  14. {meshcode-1.2.5 → meshcode-1.2.6}/meshcode/meshcode_mcp/backend.py +0 -0
  15. {meshcode-1.2.5 → meshcode-1.2.6}/meshcode/meshcode_mcp/realtime.py +0 -0
  16. {meshcode-1.2.5 → meshcode-1.2.6}/meshcode/meshcode_mcp/test_backend.py +0 -0
  17. {meshcode-1.2.5 → meshcode-1.2.6}/meshcode/meshcode_mcp/test_realtime.py +0 -0
  18. {meshcode-1.2.5 → meshcode-1.2.6}/meshcode/protocol_v2.py +0 -0
  19. {meshcode-1.2.5 → meshcode-1.2.6}/meshcode.egg-info/SOURCES.txt +0 -0
  20. {meshcode-1.2.5 → meshcode-1.2.6}/meshcode.egg-info/dependency_links.txt +0 -0
  21. {meshcode-1.2.5 → meshcode-1.2.6}/meshcode.egg-info/entry_points.txt +0 -0
  22. {meshcode-1.2.5 → meshcode-1.2.6}/meshcode.egg-info/requires.txt +0 -0
  23. {meshcode-1.2.5 → meshcode-1.2.6}/meshcode.egg-info/top_level.txt +0 -0
  24. {meshcode-1.2.5 → meshcode-1.2.6}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: meshcode
3
- Version: 1.2.5
3
+ Version: 1.2.6
4
4
  Summary: Real-time communication between AI agents — Supabase-backed CLI
5
5
  Author-email: MeshCode <hello@meshcode.io>
6
6
  License: MIT
@@ -1,2 +1,2 @@
1
1
  """MeshCode — Real-time communication between AI agents."""
2
- __version__ = "1.2.5"
2
+ __version__ = "1.2.6"
@@ -48,10 +48,29 @@ if not PROJECT_NAME or not AGENT_NAME:
48
48
  sys.exit(2)
49
49
 
50
50
 
51
- # Resolve project_id once at startup; auto-register the agent
52
- _PROJECT_ID: Optional[str] = be.get_project_id(PROJECT_NAME)
51
+ # Resolve project_id at startup. Try in order:
52
+ # 1. MESHCODE_PROJECT_ID env var (baked by `meshcode setup`, fastest)
53
+ # 2. mc_resolve_project RPC with the user's api_key (security definer, bypasses RLS)
54
+ # 3. Direct SELECT via get_project_id (only works if RLS is open / user is admin)
55
+ _PROJECT_ID: Optional[str] = os.environ.get("MESHCODE_PROJECT_ID") or None
53
56
  if not _PROJECT_ID:
54
- print(f"[meshcode-mcp] ERROR: project '{PROJECT_NAME}' not found", file=sys.stderr)
57
+ _api_key = os.environ.get("MESHCODE_API_KEY", "")
58
+ if _api_key:
59
+ try:
60
+ _r = be.sb_rpc("mc_resolve_project", {
61
+ "p_api_key": _api_key,
62
+ "p_project_name": PROJECT_NAME,
63
+ })
64
+ if isinstance(_r, dict) and _r.get("project_id"):
65
+ _PROJECT_ID = _r["project_id"]
66
+ elif isinstance(_r, dict) and _r.get("error"):
67
+ print(f"[meshcode-mcp] WARNING: mc_resolve_project: {_r['error']}", file=sys.stderr)
68
+ except Exception as _e:
69
+ print(f"[meshcode-mcp] WARNING: mc_resolve_project failed: {_e}", file=sys.stderr)
70
+ if not _PROJECT_ID:
71
+ _PROJECT_ID = be.get_project_id(PROJECT_NAME)
72
+ if not _PROJECT_ID:
73
+ print(f"[meshcode-mcp] ERROR: project '{PROJECT_NAME}' not found (check MESHCODE_API_KEY env var)", file=sys.stderr)
55
74
  sys.exit(2)
56
75
 
57
76
  _register_result = be.register_agent(PROJECT_NAME, AGENT_NAME, AGENT_ROLE or "MCP-connected agent")
@@ -98,6 +98,33 @@ def setup(client: str, project: str, agent: str, role: str = "") -> int:
98
98
  sb = _load_supabase_env()
99
99
  api_key = creds.get("api_key", "")
100
100
 
101
+ # Resolve project_id via the SECURITY DEFINER RPC so we don't depend on
102
+ # RLS letting the publishable key SELECT mc_projects at MCP server boot.
103
+ project_id = ""
104
+ try:
105
+ import json as _json
106
+ from urllib.request import Request as _Req, urlopen as _urlopen
107
+ _body = _json.dumps({"p_api_key": api_key, "p_project_name": project}).encode()
108
+ _req = _Req(
109
+ f"{sb['SUPABASE_URL']}/rest/v1/rpc/mc_resolve_project",
110
+ data=_body,
111
+ method="POST",
112
+ headers={
113
+ "apikey": sb["SUPABASE_KEY"],
114
+ "Authorization": f"Bearer {sb['SUPABASE_KEY']}",
115
+ "Content-Type": "application/json",
116
+ },
117
+ )
118
+ with _urlopen(_req, timeout=10) as _resp:
119
+ _data = _json.loads(_resp.read().decode())
120
+ if isinstance(_data, dict) and _data.get("project_id"):
121
+ project_id = _data["project_id"]
122
+ elif isinstance(_data, dict) and _data.get("error"):
123
+ print(f"[meshcode] ERROR: could not resolve project '{project}': {_data['error']}", file=sys.stderr)
124
+ return 2
125
+ except Exception as _e:
126
+ print(f"[meshcode] WARNING: project_id resolution failed ({_e}); MCP server will retry at boot", file=sys.stderr)
127
+
101
128
  os_name = platform.system()
102
129
  config_path = CLIENT_CONFIG_PATHS[client].get(os_name)
103
130
  if config_path is None:
@@ -126,6 +153,7 @@ def setup(client: str, project: str, agent: str, role: str = "") -> int:
126
153
  "args": ["-m", "meshcode.meshcode_mcp", "serve"],
127
154
  "env": {
128
155
  "MESHCODE_PROJECT": project,
156
+ "MESHCODE_PROJECT_ID": project_id,
129
157
  "MESHCODE_AGENT": agent,
130
158
  "MESHCODE_ROLE": role or "MCP-connected agent",
131
159
  "MESHCODE_API_KEY": api_key,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: meshcode
3
- Version: 1.2.5
3
+ Version: 1.2.6
4
4
  Summary: Real-time communication between AI agents — Supabase-backed CLI
5
5
  Author-email: MeshCode <hello@meshcode.io>
6
6
  License: MIT
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "meshcode"
7
- version = "1.2.5"
7
+ version = "1.2.6"
8
8
  description = "Real-time communication between AI agents — Supabase-backed CLI"
9
9
  readme = "README.md"
10
10
  license = {text = "MIT"}
File without changes
File without changes
File without changes
File without changes
File without changes