Commit 9cf3a39
authored
fix(call-actor): synthesize structuredContent on MCP server pass-through (#859)
## Context
`call-actor` with MCP-server pass-through syntax (`actor:
"apify/actors-mcp-server:search-apify-docs"`) fails on master with `MCP
error -32600: Tool call-actor has an output schema but did not return
structured content`. Repro with `mcpc --json @apify tools-call
call-actor actor:='"apify/actors-mcp-server:search-apify-docs"'
input:='{"query":"weather"}'`. Regression introduced in #415 (`f9512c4`,
2026-01-29) when `outputSchema` was added to `call-actor`; the
MCP-pass-through code in `handleMcpToolCall` has been returning `{
content }` only since #274 (2025-09-18). Both ingredients sat dormant
until the SDK on `^1.25.2` (already enforcing since 1.11.4) saw them
combined.
## Solution
In `handleMcpToolCall`, synthesize a sentinel `RunResponse` matching
`getActorRunOutputSchema.required` (`runId: 'mcp-passthrough'`,
`actorId: baseActorName`, `status`, `storages: {}`, `summary`,
`nextStep`) and forward `result.isError` from the remote tool. The
remote tool's payload still flows through `content`. Stacks on #853.
## Worth your attention
- **Sentinel runId** — `'mcp-passthrough'` is a deliberate non-Apify
literal so logs / dashboards never mistake it for a real run id. Open to
`mcp-passthrough:${mcpToolName}` for greppability per tool if preferred.
- **Integration coverage** — the existing happy-path test for this code
path didn't catch the regression because it never calls
`client.listTools()`, so the SDK never builds the validator cache. The
new test at `tests/integration/suite.ts:813` calls `listTools()` first
to mirror real clients (mcpc, Claude Desktop), which is the only way to
surface this class of bug at the integration layer.
- **Not the architectural fix** — `call-actor` doing two unrelated
things (Apify run vs. MCP tool pass-through) under one tool name is the
root cause; this PR keeps that shape and just makes the response
spec-compliant. Follow-up tracked in #860 (see comment).
## Follow-up
- Split `call-actor` MCP pass-through into a dedicated tool, or move to
code-mode as the default. Issue: #8601 parent 586faf7 commit 9cf3a39
2 files changed
Lines changed: 61 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
327 | 327 | | |
328 | 328 | | |
329 | 329 | | |
330 | | - | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
331 | 349 | | |
332 | 350 | | |
333 | 351 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
804 | 804 | | |
805 | 805 | | |
806 | 806 | | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
| 841 | + | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
807 | 849 | | |
808 | 850 | | |
809 | 851 | | |
| |||
0 commit comments