chore(server): migrate McpServer.tool() → registerTool() (#705)#763
Conversation
) Replaces every use of the deprecated MCP SDK `.tool()` overload with the supported `registerTool(name, config, handler)` form: - src/lib/server/create-adcp-server.ts — AdcpToolMap loop and get_adcp_capabilities; annotations now declared at register time instead of via post-registration .update() - src/lib/server/test-controller.ts + src/lib/testing/comply-controller.ts — comply_test_controller registration - src/lib/testing/stubs/governance-agent-stub.ts — 5 governance tools - examples/error-compliant-server.ts — canonical seller template - JSDoc / prose comments updated to the new form Deliberately skips `outputSchema` on framework-registered tools: the MCP SDK's client-side callTool validates structuredContent against outputSchema regardless of isError (@modelcontextprotocol/sdk/dist/esm/client/index.js:504). Our adcpError() envelope carries structuredContent + isError: true, which would fail every client validation. Dispatcher-level AJV validation (#727) covers response drift; customTools may opt into SDK validation explicitly via customTools[*].outputSchema (covered by regression test). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Upstream refresh adds a universal-macros note to `URLAsset.url` and
splits SI `context` into `intent` (natural-language handoff) plus
`context` (protocol envelope). Updates:
- src/lib/types/{core,tools,schemas}.generated.ts — regenerated
- src/lib/adapters/si-session-manager.ts — reads request.intent
instead of request.context; renames the inner parameter to match
- docs/{llms.txt,TYPE-SUMMARY.md} — regenerated
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
# Conflicts: # docs/llms.txt # src/lib/adapters/si-session-manager.ts # src/lib/types/core.generated.ts # src/lib/types/schemas.generated.ts
…tive-agent SKILL Expert review feedback (PR #763): - security-reviewer M1 / code-reviewer Consider: document on `AdcpCustomToolConfig.outputSchema` that a too-strict schema silently breaks client-side validation for every buyer, and cross-reference the framework-wide rationale block - debugger Nit: skill copy-paste examples for manual `preview_creative` registration now use `server.registerTool(...)` instead of the deprecated `server.tool(...)` so new agents land on the non-deprecated API. The other skill docs that mention `server.tool()` are anti-pattern call-outs ("don't use X") and stay as-is. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Ran through code-reviewer, security-reviewer, and debugger. All three said ship. code-reviewer (APPROVE):
security-reviewer (Ship, 0 Must Fix):
debugger (No runtime regressions):
Follow-ups not in this PR:
|
Reviewer spot-check caught holdouts outside src/ and examples/:
- scripts/generate-agent-docs.ts — the server-quick-start example
emitted into docs/llms.txt still showed `server.tool(...)`. Every
agent reading the reference docs was being pointed at the deprecated
API. Now emits `server.registerTool(name, { description, inputSchema },
handler)`.
- test/oauth-client-credentials-integration.test.js
- test/request-signing-agent-integration.test.js (4 sites)
- test/lib/serve-tasks.test.js (3 sites)
- test/lib/mcp-tasks-compat.test.js (2 sites)
test-agents/** was grep-clean already. Verification:
`grep -R 'server\.tool(\|mcp\.tool(' src/ examples/ test/ test-agents/ scripts/ bin/`
returns empty.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Reviewer spot-check items landed. 1. test-agents/** etc. —
Landed in e4f6ef9. Verification: empty. 2. Upstream SDK issue filed: modelcontextprotocol/typescript-sdk#1943. Two-line fix — add If they merge, the regression test in Tests: 5179 pass / 0 fail. Prettier clean. |
Summary
Replaces every use of the MCP SDK's deprecated
.tool()overload withregisterTool(name, config, handler)acrosssrc/andexamples/. Behavior is unchanged. Closes #705.Scope
Real call sites migrated:
src/lib/server/create-adcp-server.ts— AdcpToolMap loop +get_adcp_capabilities.annotationsnow declared at register time instead of via post-registration.update().src/lib/server/test-controller.ts+src/lib/testing/comply-controller.ts—comply_test_controller.src/lib/testing/stubs/governance-agent-stub.ts— 5 sites.examples/error-compliant-server.ts— canonical seller template.Doc comments / JSDoc updated across
responses.ts,errors.ts,serve.ts,adcp-server.ts,test-controller.ts,comply-controller.ts,tool-request-schemas.ts, andindex.ts.Verification:
grep -r 'server\.tool(\|mcp\.tool(' src/ examples/is empty.outputSchemadeliberately not wired on framework toolsThe issue asks for
outputSchemaon every AdCP tool. While investigating I found a hard blocker in the current MCP SDK:The server-side validator at
mcp.js:193correctly skips onisError; the client-side path does not. Until the SDK gates the client check symmetrically, wiringoutputSchemawould turn every AdCP error into a client validation failure.What covers drift in the meantime:
customToolsopt-in: callers who explicitly passoutputSchemastill get SDK-level validation for their own tool. A new regression test (test/server-create-adcp-server.test.js) proves the plumbing survives the migration.Test plan
npm test— 5164 pass / 0 failnpm run format:checkcleancustomTools:registerTool passes annotations through to the SDK tool definition— fails loudly if someone reverts to.tool()(no annotations param)customTools with outputSchema store the schema on the SDK tool definition— proves the config-object plumbing still reaches the SDKcomply-controller.test.jsfake server updated to theregisterToolshapeFollow-up
!isError. If fixed upstream, we can wireoutputSchemain a follow-up PR.🤖 Generated with Claude Code