Commit 576b0fa
fix(connect-studio): make the connect command actually work end-to-end
Two real bugs surfaced by testing the generated command against a live
local Studio (Claude Code → HTTP 400, then 0 tools):
1. Aggregate org resolution (HTTP 400). `/api/:org/mcp` →
handleVirtualMcpRequest resolved the org ONLY from x-org-id/x-org-slug
headers, which external MCP clients (Claude Code/Desktop) never send —
the org is in the URL path, already in ctx.organization via
resolveOrgFromPath. Fall back to it so the endpoint stops 400ing with
"Agent ID or organization ID is required".
2. Empty toolset. The bare aggregate resolves to the Decopilot agent,
which is a pure orchestrator with connections:[] (routes via subtask) —
so an external client sees ZERO tools. Point the connect URL at
`/api/:org/mcp/self` instead: the org's real management surface (Library
files, agents, connections, automations, brand, AI providers, secrets).
Verified live: initialize + tools/list (142 tools) + a real
ORGANIZATION_LIST call all succeed over the API-key command.
Also: derive the MCP server name in the command from the host
(`belo-horizonte.localhost` locally, `studio.decocms.com` in prod) so each
deployment gets a distinct entry and adding two never collides.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent 81265d8 commit 576b0fa
3 files changed
Lines changed: 38 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
50 | | - | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
51 | 57 | | |
52 | 58 | | |
53 | 59 | | |
| |||
60 | 66 | | |
61 | 67 | | |
62 | 68 | | |
63 | | - | |
| 69 | + | |
64 | 70 | | |
65 | 71 | | |
66 | 72 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| |||
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
14 | | - | |
15 | | - | |
16 | 15 | | |
17 | 16 | | |
18 | 17 | | |
| |||
32 | 31 | | |
33 | 32 | | |
34 | 33 | | |
| 34 | + | |
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
40 | | - | |
| 40 | + | |
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
45 | | - | |
| 45 | + | |
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
| |||
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
57 | | - | |
| 57 | + | |
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
62 | | - | |
| 62 | + | |
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
| |||
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
81 | | - | |
| 81 | + | |
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
8 | | - | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
9 | 17 | | |
10 | | - | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
11 | 29 | | |
12 | 30 | | |
13 | 31 | | |
14 | 32 | | |
15 | 33 | | |
16 | | - | |
| 34 | + | |
17 | 35 | | |
18 | 36 | | |
19 | 37 | | |
| |||
27 | 45 | | |
28 | 46 | | |
29 | 47 | | |
30 | | - | |
| 48 | + | |
31 | 49 | | |
0 commit comments