Repository navigation
Commit 465ea3c
authored
feat(mcp): type mcp block replies from declared output schemas (#9466)
* feat(mcp): type mcp block replies from declared output schemas
MCP servers may declare an outputSchema on a tool and return
structuredContent, but discovery copied only name, description and
inputSchema, so no surface showed a reply shape and the MCP block declared
only content. Agents building workflows guessed field names, and a
reference such as <mcp.structuredContent.x> failed validation even when the
tool returned it.
- Discovery keeps a declared outputSchema on McpTool; the tool cache carries
it, and managed connections persist it in the existing mcp_tools jsonb
snapshot (type only, no migration).
- Surfaced on GET /api/v2/mcp-servers/{id}/tools (and so the CLI's
mcp-servers tools list), mcp_list_operations, the editor tool list, and the
integration catalog (synced contract, optional field). The v2 tool shape is
strict, so keeping the field without declaring it would have turned
discovery into a 500.
- The MCP block gains a hidden, server-managed toolOutputSchema sub-block: a
structure-only snapshot of the selected operation's schema, bound to the
server and operation it was taken for. The editor writes it when an
operation is picked; applyWorkflowOperations writes it for agent edits,
through the same authorized discovery use cases, best effort and only when
the snapshot is missing or stale.
- With a matching snapshot, the block declares a typed structuredContent
output beside content, so the run's reference check, lint (which now walks
paths below structuredContent and names the declared fields) and the tag
paths all read the declared shape, and workflows deps fills mock leaves
from it. Without one, outputs are exactly as before.
* fix(mcp): address review on mcp output schema snapshots
- Read the MCP target with the block's saved canonical modes in lint,
workflows deps and effective outputs, so a dormant basic/advanced member
never selects or drops the snapshot.
- Expand repeated bracket indices before the nested lint check, as the run
resolves them.
- Stop expanding a schema once its node budget is spent and leave that object
open, instead of saving an untyped node per remaining field.
- Keep every declared field name, constructor and __proto__ included.
- Snapshot only blocks the edit changed, and discover best effort, so an
unreachable server neither slows unrelated edits nor gets marked unhealthy.
* fix(mcp): keep declared fields in deps whole reads and sample __proto__ fields safely
workflows deps now adds an operation's declared fields wherever a consumer reads a structuredContent value whole, beside the paths it reads by name. Trigger mock payloads define sampled fields with Object.fromEntries, so a declared __proto__ field stays a field instead of replacing the sample's prototype.
* fix(mcp): carry a whole structuredContent read through nested deps mocks
A whole read now adds every declared field below it, through nested objects and array items, even where the consumer also reads a nested path by name.1 parent 075c4ff commit 465ea3c
44 files changed
Lines changed: 1450 additions & 49 deletions
File tree
- apps
- docs
- sim
- app
- api/v2/mcp-servers/[mcpServerId]/tools
- workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/mcp-server-modal
- blocks/blocks
- executor/utils
- hooks/mcp
- lib
- api/contracts
- v2
- credential-groups
- credentials
- application
- internal/mcp
- mcp
- application
- mothership
- agent-cli
- engines
- chat
- generated
- integrations/application
- workflows
- application
- blocks
- editing
- triggers
- serializer
- tools
- generated
- mcp
- packages
- db
- sim-cli/src/generated
- scripts
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15190 | 15190 | | |
15191 | 15191 | | |
15192 | 15192 | | |
| 15193 | + | |
| 15194 | + | |
| 15195 | + | |
| 15196 | + | |
| 15197 | + | |
| 15198 | + | |
| 15199 | + | |
| 15200 | + | |
| 15201 | + | |
| 15202 | + | |
| 15203 | + | |
| 15204 | + | |
| 15205 | + | |
| 15206 | + | |
| 15207 | + | |
| 15208 | + | |
| 15209 | + | |
| 15210 | + | |
| 15211 | + | |
| 15212 | + | |
| 15213 | + | |
| 15214 | + | |
| 15215 | + | |
| 15216 | + | |
| 15217 | + | |
| 15218 | + | |
| 15219 | + | |
| 15220 | + | |
| 15221 | + | |
| 15222 | + | |
| 15223 | + | |
| 15224 | + | |
| 15225 | + | |
15193 | 15226 | | |
15194 | 15227 | | |
15195 | 15228 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
232 | 232 | | |
233 | 233 | | |
234 | 234 | | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
235 | 263 | | |
236 | 264 | | |
237 | 265 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
5 | 9 | | |
6 | 10 | | |
7 | 11 | | |
| |||
35 | 39 | | |
36 | 40 | | |
37 | 41 | | |
| 42 | + | |
38 | 43 | | |
39 | 44 | | |
40 | 45 | | |
| |||
68 | 73 | | |
69 | 74 | | |
70 | 75 | | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
71 | 81 | | |
72 | 82 | | |
73 | 83 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
2 | 3 | | |
3 | 4 | | |
4 | 5 | | |
| |||
123 | 124 | | |
124 | 125 | | |
125 | 126 | | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
126 | 136 | | |
127 | 137 | | |
128 | 138 | | |
| |||
157 | 167 | | |
158 | 168 | | |
159 | 169 | | |
160 | | - | |
| 170 | + | |
| 171 | + | |
161 | 172 | | |
162 | 173 | | |
163 | 174 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
101 | 101 | | |
102 | 102 | | |
103 | 103 | | |
104 | | - | |
| 104 | + | |
| 105 | + | |
105 | 106 | | |
106 | 107 | | |
107 | 108 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| 31 | + | |
31 | 32 | | |
32 | 33 | | |
33 | 34 | | |
| |||
55 | 56 | | |
56 | 57 | | |
57 | 58 | | |
| 59 | + | |
58 | 60 | | |
59 | 61 | | |
60 | 62 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
97 | 97 | | |
98 | 98 | | |
99 | 99 | | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
100 | 105 | | |
101 | 106 | | |
102 | 107 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
332 | 332 | | |
333 | 333 | | |
334 | 334 | | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
335 | 360 | | |
336 | 361 | | |
337 | 362 | | |
338 | 363 | | |
339 | 364 | | |
340 | 365 | | |
| 366 | + | |
341 | 367 | | |
342 | 368 | | |
343 | 369 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
| |||
118 | 119 | | |
119 | 120 | | |
120 | 121 | | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
| 122 | + | |
126 | 123 | | |
127 | 124 | | |
128 | 125 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
201 | 201 | | |
202 | 202 | | |
203 | 203 | | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
204 | 231 | | |
205 | 232 | | |
206 | 233 | | |
| |||
0 commit comments