@agent-native/core 0.128.3 → 0.129.0
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.
- package/corpus/README.md +2 -2
- package/corpus/core/CHANGELOG.md +91 -0
- package/corpus/core/docs/content/template-design-collaboration-and-full-apps.mdx +3 -1
- package/corpus/core/package.json +6 -3
- package/corpus/core/src/a2a/client.ts +18 -4
- package/corpus/core/src/a2a/server.ts +19 -3
- package/corpus/core/src/a2a/types.ts +7 -0
- package/corpus/core/src/action.ts +43 -16
- package/corpus/core/src/agent/engine/ai-sdk-engine.ts +14 -10
- package/corpus/core/src/agent/production-agent.ts +41 -3
- package/corpus/core/src/agent/thread-data-builder.ts +5 -0
- package/corpus/core/src/chat-threads/migrations.ts +53 -0
- package/corpus/core/src/cli/create.ts +4 -0
- package/corpus/core/src/cli/skills-content/design-visual-edit-skill.ts +36 -16
- package/corpus/core/src/cli/skills.ts +16 -0
- package/corpus/core/src/client/AgentPanel.tsx +9 -5
- package/corpus/core/src/client/AssistantChat.tsx +138 -46
- package/corpus/core/src/client/MultiTabAssistantChat.tsx +16 -10
- package/corpus/core/src/client/agent-chat-adapter.ts +21 -3
- package/corpus/core/src/client/analytics.ts +159 -102
- package/corpus/core/src/client/chat/legacy-chart-shorthand.tsx +479 -0
- package/corpus/core/src/client/chat/markdown-renderer.tsx +23 -3
- package/corpus/core/src/client/chat/message-components.tsx +12 -5
- package/corpus/core/src/client/chat/runtime.ts +2 -1
- package/corpus/core/src/client/chat/tool-call-display.tsx +25 -2
- package/corpus/core/src/client/chat-model-groups.ts +3 -0
- package/corpus/core/src/client/client-status-requests.ts +161 -0
- package/corpus/core/src/client/settings/VoiceTranscriptionSection.tsx +2 -2
- package/corpus/core/src/client/sse-event-processor.ts +15 -3
- package/corpus/core/src/client/use-agent-engine-configured.ts +54 -50
- package/corpus/core/src/client/use-chat-models.ts +16 -11
- package/corpus/core/src/client/use-chat-threads.ts +32 -9
- package/corpus/core/src/client/use-session.ts +4 -5
- package/corpus/core/src/db/client.ts +83 -8
- package/corpus/core/src/db/ensure-additive-columns.ts +31 -20
- package/corpus/core/src/db/migrations.ts +22 -2
- package/corpus/core/src/extensions/actions.ts +1 -1
- package/corpus/core/src/mcp/approval-store.ts +99 -0
- package/corpus/core/src/mcp/build-server.ts +579 -303
- package/corpus/core/src/mcp/embed-app.ts +1 -1
- package/corpus/core/src/mcp/oauth-client-metadata.ts +380 -0
- package/corpus/core/src/mcp/oauth-route.ts +57 -52
- package/corpus/core/src/mcp/screen-memory-stdio.ts +400 -378
- package/corpus/core/src/mcp/server.ts +29 -145
- package/corpus/core/src/mcp/stdio.ts +72 -80
- package/corpus/core/src/mcp-client/manager.ts +6 -10
- package/corpus/core/src/mcp-client/oauth-client.ts +127 -36
- package/corpus/core/src/mcp-client/oauth-routes.ts +16 -6
- package/corpus/core/src/mcp-client/routes.ts +6 -5
- package/corpus/core/src/server/agent-capabilities.ts +20 -0
- package/corpus/core/src/server/agent-chat/action-filters-a2a.ts +27 -0
- package/corpus/core/src/server/agent-chat-plugin.ts +18 -0
- package/corpus/core/src/server/transcribe-voice.ts +14 -5
- package/corpus/core/src/templates/default/.agents/skills/security/SKILL.md +13 -2
- package/corpus/core/src/templates/workspace-core/.agents/skills/authentication/SKILL.md +5 -2
- package/corpus/core/src/templates/workspace-core/.agents/skills/external-agents/SKILL.md +18 -0
- package/corpus/core/src/templates/workspace-core/.agents/skills/security/SKILL.md +13 -2
- package/corpus/templates/analytics/.agents/skills/data-querying/SKILL.md +12 -0
- package/corpus/templates/analytics/.agents/skills/security/SKILL.md +13 -2
- package/corpus/templates/analytics/actions/generate-chart.ts +2 -2
- package/corpus/templates/analytics/app/components/dashboard/DashboardPanelSkeleton.tsx +1 -10
- package/corpus/templates/analytics/app/global.css +0 -31
- package/corpus/templates/analytics/app/lib/sql-query.ts +46 -20
- package/corpus/templates/analytics/changelog/2026-07-28-analytics-dashboard-loading-states-now-use-a-simpler-standar.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-28-analytics-dashboards-now-load-first-party-charts-reliably-in.md +6 -0
- package/corpus/templates/analytics/server/lib/first-party-analytics-cache.ts +42 -16
- package/corpus/templates/analytics/server/lib/first-party-analytics.ts +4 -2
- package/corpus/templates/analytics/shared/sql-query-limits.ts +1 -0
- package/corpus/templates/assets/.agents/skills/security/SKILL.md +13 -2
- package/corpus/templates/brain/.agents/skills/security/SKILL.md +13 -2
- package/corpus/templates/calendar/.agents/skills/security/SKILL.md +13 -2
- package/corpus/templates/chat/.agents/skills/security/SKILL.md +13 -2
- package/corpus/templates/clips/.agents/skills/security/SKILL.md +13 -2
- package/corpus/templates/clips/app/components/player/player-controls.tsx +3 -6
- package/corpus/templates/clips/app/routes/r.$recordingId.tsx +6 -2
- package/corpus/templates/clips/app/routes/share.$shareId.tsx +3 -1
- package/corpus/templates/clips/changelog/2026-07-28-copied-share-links-no-longer-leave-an-unnecessary-confirmati.md +6 -0
- package/corpus/templates/clips/changelog/2026-07-28-playback-skip-controls-no-longer-show-overlapping-numbers.md +6 -0
- package/corpus/templates/clips/changelog/2026-07-28-public-clips-share-buttons-now-use-a-clean-text-only-label.md +6 -0
- package/corpus/templates/clips/desktop/src/app.tsx +14 -17
- package/corpus/templates/clips/desktop/src/overlays/live-audio-bars.tsx +3 -1
- package/corpus/templates/clips/desktop/src/styles.css +13 -10
- package/corpus/templates/clips/desktop/src-tauri/src/recording_indicator.rs +2 -2
- package/corpus/templates/clips/desktop/src-tauri/src/whisper_speech.rs +36 -0
- package/corpus/templates/content/.agents/skills/security/SKILL.md +13 -2
- package/corpus/templates/content/actions/_builder-cms-read-client.ts +155 -34
- package/corpus/templates/content/actions/_builder-docs-client.ts +151 -30
- package/corpus/templates/content/actions/stage-builder-source-bulk-update.ts +5 -2
- package/corpus/templates/content/app/root.tsx +35 -14
- package/corpus/templates/content/changelog/2026-07-28-builder-backed-files-media-fields-now-accept-direct-file-url.md +6 -0
- package/corpus/templates/content/changelog/2026-07-28-builder-content-reads-now-negotiate-the-newest-mcp-protocol-.md +6 -0
- package/corpus/templates/content/changelog/2026-07-28-public-content-pages-load-faster-before-the-optional-ask-sid.md +6 -0
- package/corpus/templates/design/.agents/skills/security/SKILL.md +13 -2
- package/corpus/templates/design/.agents/skills/visual-edit/SKILL.md +36 -16
- package/corpus/templates/design/.generated/bridge/editor-chrome.generated.ts +42 -3
- package/corpus/templates/design/actions/open-visual-edit.ts +2 -1
- package/corpus/templates/design/app/components/design/CanvasContextMenu.tsx +2 -2
- package/corpus/templates/design/app/components/design/DesignCanvas.tsx +14 -15
- package/corpus/templates/design/app/components/design/ResponsiveInteractBar.tsx +314 -0
- package/corpus/templates/design/app/components/design/bridge/editor-chrome.bridge.ts +88 -3
- package/corpus/templates/design/app/components/design/keyboard-shortcuts.ts +1 -1
- package/corpus/templates/design/app/hooks/useDesignHotkeys.ts +7 -6
- package/corpus/templates/design/app/i18n-data.ts +56 -11
- package/corpus/templates/design/app/i18n-responsive-interact.ts +183 -0
- package/corpus/templates/design/app/lib/agent-chat.ts +60 -0
- package/corpus/templates/design/app/pages/design-editor/responsive-interact.ts +89 -0
- package/corpus/templates/design/changelog/2026-07-28-design-edits-can-be-applied-through-the-host-coding-agent-fr.md +6 -0
- package/corpus/templates/design/changelog/2026-07-28-interact-mode-can-preview-designs-in-responsive-device-sizes.md +6 -0
- package/corpus/templates/design/changelog/2026-07-28-interact-mode-now-opens-a-full-screen-responsive-preview-wit.md +6 -0
- package/corpus/templates/design/changelog/2026-07-28-show-or-hide-design-editing-chrome-with-cmd-on-apple-devices.md +2 -2
- package/corpus/templates/design/changelog/2026-07-28-visual-edit-now-always-shows-the-live-running-app-in-the-can.md +6 -0
- package/corpus/templates/dispatch/.agents/skills/security/SKILL.md +13 -2
- package/corpus/templates/forms/.agents/skills/security/SKILL.md +13 -2
- package/corpus/templates/macros/.agents/skills/security/SKILL.md +13 -2
- package/corpus/templates/mail/.agents/skills/security/SKILL.md +13 -2
- package/corpus/templates/plan/.agents/skills/security/SKILL.md +13 -2
- package/corpus/templates/slides/.agents/skills/security/SKILL.md +13 -2
- package/corpus/templates/tasks/.agents/skills/security/SKILL.md +13 -2
- package/corpus/toolkit/CHANGELOG.md +13 -0
- package/corpus/toolkit/package.json +1 -1
- package/corpus/toolkit/src/chat-history.css +1 -2
- package/corpus/toolkit/src/composer/TiptapComposer.tsx +45 -0
- package/dist/a2a/client.d.ts +7 -0
- package/dist/a2a/client.d.ts.map +1 -1
- package/dist/a2a/client.js +8 -3
- package/dist/a2a/client.js.map +1 -1
- package/dist/a2a/server.d.ts.map +1 -1
- package/dist/a2a/server.js +18 -3
- package/dist/a2a/server.js.map +1 -1
- package/dist/a2a/types.d.ts +7 -0
- package/dist/a2a/types.d.ts.map +1 -1
- package/dist/a2a/types.js.map +1 -1
- package/dist/action.d.ts +15 -1
- package/dist/action.d.ts.map +1 -1
- package/dist/action.js +39 -16
- package/dist/action.js.map +1 -1
- package/dist/agent/engine/ai-sdk-engine.d.ts.map +1 -1
- package/dist/agent/engine/ai-sdk-engine.js +14 -10
- package/dist/agent/engine/ai-sdk-engine.js.map +1 -1
- package/dist/agent/production-agent.d.ts.map +1 -1
- package/dist/agent/production-agent.js +35 -7
- package/dist/agent/production-agent.js.map +1 -1
- package/dist/agent/thread-data-builder.d.ts +2 -0
- package/dist/agent/thread-data-builder.d.ts.map +1 -1
- package/dist/agent/thread-data-builder.js +3 -0
- package/dist/agent/thread-data-builder.js.map +1 -1
- package/dist/chat-threads/migrations.d.ts +21 -0
- package/dist/chat-threads/migrations.d.ts.map +1 -0
- package/dist/chat-threads/migrations.js +45 -0
- package/dist/chat-threads/migrations.js.map +1 -0
- package/dist/cli/create.d.ts.map +1 -1
- package/dist/cli/create.js +4 -0
- package/dist/cli/create.js.map +1 -1
- package/dist/cli/skills-content/design-visual-edit-skill.d.ts +1 -1
- package/dist/cli/skills-content/design-visual-edit-skill.d.ts.map +1 -1
- package/dist/cli/skills-content/design-visual-edit-skill.js +36 -16
- package/dist/cli/skills-content/design-visual-edit-skill.js.map +1 -1
- package/dist/cli/skills.d.ts.map +1 -1
- package/dist/cli/skills.js +15 -0
- package/dist/cli/skills.js.map +1 -1
- package/dist/client/AgentPanel.d.ts.map +1 -1
- package/dist/client/AgentPanel.js +6 -5
- package/dist/client/AgentPanel.js.map +1 -1
- package/dist/client/AssistantChat.d.ts +37 -0
- package/dist/client/AssistantChat.d.ts.map +1 -1
- package/dist/client/AssistantChat.js +41 -8
- package/dist/client/AssistantChat.js.map +1 -1
- package/dist/client/MultiTabAssistantChat.d.ts.map +1 -1
- package/dist/client/MultiTabAssistantChat.js +11 -10
- package/dist/client/MultiTabAssistantChat.js.map +1 -1
- package/dist/client/agent-chat-adapter.d.ts.map +1 -1
- package/dist/client/agent-chat-adapter.js +19 -3
- package/dist/client/agent-chat-adapter.js.map +1 -1
- package/dist/client/analytics.d.ts.map +1 -1
- package/dist/client/analytics.js +150 -101
- package/dist/client/analytics.js.map +1 -1
- package/dist/client/chat/legacy-chart-shorthand.d.ts +29 -0
- package/dist/client/chat/legacy-chart-shorthand.d.ts.map +1 -0
- package/dist/client/chat/legacy-chart-shorthand.js +330 -0
- package/dist/client/chat/legacy-chart-shorthand.js.map +1 -0
- package/dist/client/chat/markdown-renderer.d.ts.map +1 -1
- package/dist/client/chat/markdown-renderer.js +8 -2
- package/dist/client/chat/markdown-renderer.js.map +1 -1
- package/dist/client/chat/message-components.d.ts +2 -1
- package/dist/client/chat/message-components.d.ts.map +1 -1
- package/dist/client/chat/message-components.js +11 -4
- package/dist/client/chat/message-components.js.map +1 -1
- package/dist/client/chat/runtime.d.ts.map +1 -1
- package/dist/client/chat/runtime.js +2 -1
- package/dist/client/chat/runtime.js.map +1 -1
- package/dist/client/chat/tool-call-display.d.ts +4 -1
- package/dist/client/chat/tool-call-display.d.ts.map +1 -1
- package/dist/client/chat/tool-call-display.js +14 -8
- package/dist/client/chat/tool-call-display.js.map +1 -1
- package/dist/client/chat-model-groups.d.ts.map +1 -1
- package/dist/client/chat-model-groups.js +3 -0
- package/dist/client/chat-model-groups.js.map +1 -1
- package/dist/client/client-status-requests.d.ts +14 -0
- package/dist/client/client-status-requests.d.ts.map +1 -0
- package/dist/client/client-status-requests.js +126 -0
- package/dist/client/client-status-requests.js.map +1 -0
- package/dist/client/settings/VoiceTranscriptionSection.js +1 -1
- package/dist/client/settings/VoiceTranscriptionSection.js.map +1 -1
- package/dist/client/sse-event-processor.d.ts +7 -0
- package/dist/client/sse-event-processor.d.ts.map +1 -1
- package/dist/client/sse-event-processor.js +8 -3
- package/dist/client/sse-event-processor.js.map +1 -1
- package/dist/client/use-agent-engine-configured.d.ts.map +1 -1
- package/dist/client/use-agent-engine-configured.js +29 -43
- package/dist/client/use-agent-engine-configured.js.map +1 -1
- package/dist/client/use-chat-models.d.ts.map +1 -1
- package/dist/client/use-chat-models.js +11 -11
- package/dist/client/use-chat-models.js.map +1 -1
- package/dist/client/use-chat-threads.d.ts.map +1 -1
- package/dist/client/use-chat-threads.js +23 -7
- package/dist/client/use-chat-threads.js.map +1 -1
- package/dist/client/use-session.d.ts.map +1 -1
- package/dist/client/use-session.js +4 -4
- package/dist/client/use-session.js.map +1 -1
- package/dist/collab/awareness.d.ts +2 -2
- package/dist/collab/awareness.d.ts.map +1 -1
- package/dist/db/client.d.ts.map +1 -1
- package/dist/db/client.js +48 -4
- package/dist/db/client.js.map +1 -1
- package/dist/db/ensure-additive-columns.d.ts.map +1 -1
- package/dist/db/ensure-additive-columns.js +32 -21
- package/dist/db/ensure-additive-columns.js.map +1 -1
- package/dist/db/migrations.d.ts +9 -0
- package/dist/db/migrations.d.ts.map +1 -1
- package/dist/db/migrations.js +14 -3
- package/dist/db/migrations.js.map +1 -1
- package/dist/extensions/actions.js +1 -1
- package/dist/extensions/actions.js.map +1 -1
- package/dist/mcp/approval-store.d.ts +16 -0
- package/dist/mcp/approval-store.d.ts.map +1 -0
- package/dist/mcp/approval-store.js +85 -0
- package/dist/mcp/approval-store.js.map +1 -0
- package/dist/mcp/build-server.d.ts +1 -34
- package/dist/mcp/build-server.d.ts.map +1 -1
- package/dist/mcp/build-server.js +220 -23
- package/dist/mcp/build-server.js.map +1 -1
- package/dist/mcp/embed-app.js +1 -1
- package/dist/mcp/embed-app.js.map +1 -1
- package/dist/mcp/oauth-client-metadata.d.ts +15 -0
- package/dist/mcp/oauth-client-metadata.d.ts.map +1 -0
- package/dist/mcp/oauth-client-metadata.js +297 -0
- package/dist/mcp/oauth-client-metadata.js.map +1 -0
- package/dist/mcp/oauth-route.d.ts.map +1 -1
- package/dist/mcp/oauth-route.js +39 -53
- package/dist/mcp/oauth-route.js.map +1 -1
- package/dist/mcp/screen-memory-stdio.d.ts.map +1 -1
- package/dist/mcp/screen-memory-stdio.js +304 -296
- package/dist/mcp/screen-memory-stdio.js.map +1 -1
- package/dist/mcp/server.d.ts +12 -25
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/mcp/server.js +24 -133
- package/dist/mcp/server.js.map +1 -1
- package/dist/mcp/stdio.d.ts.map +1 -1
- package/dist/mcp/stdio.js +36 -35
- package/dist/mcp/stdio.js.map +1 -1
- package/dist/mcp-client/manager.d.ts.map +1 -1
- package/dist/mcp-client/manager.js +6 -6
- package/dist/mcp-client/manager.js.map +1 -1
- package/dist/mcp-client/oauth-client.d.ts +13 -17
- package/dist/mcp-client/oauth-client.d.ts.map +1 -1
- package/dist/mcp-client/oauth-client.js +74 -16
- package/dist/mcp-client/oauth-client.js.map +1 -1
- package/dist/mcp-client/oauth-routes.d.ts +2 -2
- package/dist/mcp-client/oauth-routes.d.ts.map +1 -1
- package/dist/mcp-client/oauth-routes.js +16 -6
- package/dist/mcp-client/oauth-routes.js.map +1 -1
- package/dist/mcp-client/routes.js +5 -5
- package/dist/mcp-client/routes.js.map +1 -1
- package/dist/notifications/routes.d.ts +1 -1
- package/dist/progress/routes.d.ts +1 -1
- package/dist/resources/handlers.d.ts +1 -1
- package/dist/secrets/routes.d.ts +9 -9
- package/dist/server/agent-capabilities.d.ts.map +1 -1
- package/dist/server/agent-capabilities.js +21 -0
- package/dist/server/agent-capabilities.js.map +1 -1
- package/dist/server/agent-chat/action-filters-a2a.d.ts +14 -0
- package/dist/server/agent-chat/action-filters-a2a.d.ts.map +1 -1
- package/dist/server/agent-chat/action-filters-a2a.js +16 -0
- package/dist/server/agent-chat/action-filters-a2a.js.map +1 -1
- package/dist/server/agent-chat-plugin.d.ts.map +1 -1
- package/dist/server/agent-chat-plugin.js +11 -1
- package/dist/server/agent-chat-plugin.js.map +1 -1
- package/dist/server/transcribe-voice.js +12 -6
- package/dist/server/transcribe-voice.js.map +1 -1
- package/dist/templates/chat/.agents/skills/security/SKILL.md +13 -2
- package/dist/templates/default/.agents/skills/security/SKILL.md +13 -2
- package/dist/templates/workspace-core/.agents/skills/authentication/SKILL.md +5 -2
- package/dist/templates/workspace-core/.agents/skills/external-agents/SKILL.md +18 -0
- package/dist/templates/workspace-core/.agents/skills/security/SKILL.md +13 -2
- package/docs/content/template-design-collaboration-and-full-apps.mdx +3 -1
- package/package.json +7 -4
- package/src/a2a/client.ts +18 -4
- package/src/a2a/server.ts +19 -3
- package/src/a2a/types.ts +7 -0
- package/src/action.ts +43 -16
- package/src/agent/engine/ai-sdk-engine.ts +14 -10
- package/src/agent/production-agent.ts +41 -3
- package/src/agent/thread-data-builder.ts +5 -0
- package/src/chat-threads/migrations.ts +53 -0
- package/src/cli/create.ts +4 -0
- package/src/cli/skills-content/design-visual-edit-skill.ts +36 -16
- package/src/cli/skills.ts +16 -0
- package/src/client/AgentPanel.tsx +9 -5
- package/src/client/AssistantChat.tsx +138 -46
- package/src/client/MultiTabAssistantChat.tsx +16 -10
- package/src/client/agent-chat-adapter.ts +21 -3
- package/src/client/analytics.ts +159 -102
- package/src/client/chat/legacy-chart-shorthand.tsx +479 -0
- package/src/client/chat/markdown-renderer.tsx +23 -3
- package/src/client/chat/message-components.tsx +12 -5
- package/src/client/chat/runtime.ts +2 -1
- package/src/client/chat/tool-call-display.tsx +25 -2
- package/src/client/chat-model-groups.ts +3 -0
- package/src/client/client-status-requests.ts +161 -0
- package/src/client/settings/VoiceTranscriptionSection.tsx +2 -2
- package/src/client/sse-event-processor.ts +15 -3
- package/src/client/use-agent-engine-configured.ts +54 -50
- package/src/client/use-chat-models.ts +16 -11
- package/src/client/use-chat-threads.ts +32 -9
- package/src/client/use-session.ts +4 -5
- package/src/db/client.ts +83 -8
- package/src/db/ensure-additive-columns.ts +31 -20
- package/src/db/migrations.ts +22 -2
- package/src/extensions/actions.ts +1 -1
- package/src/mcp/approval-store.ts +99 -0
- package/src/mcp/build-server.ts +579 -303
- package/src/mcp/embed-app.ts +1 -1
- package/src/mcp/oauth-client-metadata.ts +380 -0
- package/src/mcp/oauth-route.ts +57 -52
- package/src/mcp/screen-memory-stdio.ts +400 -378
- package/src/mcp/server.ts +29 -145
- package/src/mcp/stdio.ts +72 -80
- package/src/mcp-client/manager.ts +6 -10
- package/src/mcp-client/oauth-client.ts +127 -36
- package/src/mcp-client/oauth-routes.ts +16 -6
- package/src/mcp-client/routes.ts +6 -5
- package/src/server/agent-capabilities.ts +20 -0
- package/src/server/agent-chat/action-filters-a2a.ts +27 -0
- package/src/server/agent-chat-plugin.ts +18 -0
- package/src/server/transcribe-voice.ts +14 -5
- package/src/templates/chat/.agents/skills/security/SKILL.md +13 -2
- package/src/templates/default/.agents/skills/security/SKILL.md +13 -2
- package/src/templates/workspace-core/.agents/skills/authentication/SKILL.md +5 -2
- package/src/templates/workspace-core/.agents/skills/external-agents/SKILL.md +18 -0
- package/src/templates/workspace-core/.agents/skills/security/SKILL.md +13 -2
|
@@ -46,33 +46,6 @@ export {
|
|
|
46
46
|
};
|
|
47
47
|
export type { MCPConfig, MCPCallerIdentity, MCPRequestMeta };
|
|
48
48
|
|
|
49
|
-
// ---------------------------------------------------------------------------
|
|
50
|
-
// Runtime detection — Node fast-path vs. web-standard fallback
|
|
51
|
-
// ---------------------------------------------------------------------------
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Resolve the underlying Node `http` req/res pair if (and only if) we're
|
|
55
|
-
* running on a real Node HTTP server (local dev, `node` Nitro preset). On the
|
|
56
|
-
* web-standard runtime (Nitro 3 / Netlify web runtime, Cloudflare, Deno, Bun)
|
|
57
|
-
* BOTH of these are undefined — that's the signal to take the web fallback
|
|
58
|
-
* instead of returning 501.
|
|
59
|
-
*/
|
|
60
|
-
function getNodeReqRes(event: H3Event): {
|
|
61
|
-
nodeReq: any | undefined;
|
|
62
|
-
nodeRes: any | undefined;
|
|
63
|
-
} {
|
|
64
|
-
const e = event as any;
|
|
65
|
-
const nodeReq = e.node?.req ?? e.req?.runtime?.node?.req;
|
|
66
|
-
const nodeRes = e.node?.res ?? e.req?.runtime?.node?.res;
|
|
67
|
-
return { nodeReq, nodeRes };
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
function shouldUseNodeFastPath(event: H3Event): boolean {
|
|
71
|
-
if (process.env.AGENT_NATIVE_MCP_NODE_FAST_PATH !== "1") return false;
|
|
72
|
-
const { nodeReq, nodeRes } = getNodeReqRes(event);
|
|
73
|
-
return Boolean(nodeReq && nodeRes);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
49
|
/**
|
|
77
50
|
* Derive the request origin + the markdown deep-link target from the inbound
|
|
78
51
|
* headers. Identical logic for both the Node and web paths so the absolute
|
|
@@ -254,29 +227,20 @@ function buildUnauthorizedBody(event: H3Event): {
|
|
|
254
227
|
/**
|
|
255
228
|
* Handle a single `{routePrefix}/mcp` request on either runtime.
|
|
256
229
|
*
|
|
257
|
-
* -
|
|
258
|
-
*
|
|
259
|
-
*
|
|
260
|
-
*
|
|
261
|
-
* `Response` as a normal h3 return value. This is used for Nitro local dev
|
|
262
|
-
* too; the direct Node writer can otherwise race h3 and double-write.
|
|
263
|
-
* - **Opt-in Node fast-path:** set `AGENT_NATIVE_MCP_NODE_FAST_PATH=1` to
|
|
264
|
-
* delegate directly to the SDK's `StreamableHTTPServerTransport`.
|
|
230
|
+
* Builds one request-scoped MCP `Server` from the verified caller identity and
|
|
231
|
+
* drives it through the SDK's v2 `createMcpHandler`. That entry serves native
|
|
232
|
+
* 2026-07-28 envelopes and stateless 2025-era traffic from the same factory,
|
|
233
|
+
* so protocol generations cannot drift apart.
|
|
265
234
|
*
|
|
266
|
-
*
|
|
267
|
-
*
|
|
268
|
-
*
|
|
269
|
-
* via `createMCPServerForRequest` and both transports funnel into the same
|
|
270
|
-
* `WebStandardStreamableHTTPServerTransport.handleRequest(webRequest, {
|
|
271
|
-
* parsedBody })` with the same options.
|
|
235
|
+
* The handler is Web Standard on every runtime. H3 owns the Node response when
|
|
236
|
+
* one exists, avoiding the double-write race from a transport writing directly
|
|
237
|
+
* to `node.res`.
|
|
272
238
|
*
|
|
273
239
|
* Returns:
|
|
274
240
|
* - `undefined` when the request targets a sub-route (so management/status
|
|
275
241
|
* routes mounted under `/_agent-native/mcp/*` handle it themselves) — the
|
|
276
242
|
* h3 mount falls through to the next handler.
|
|
277
|
-
* - a Web `Response`
|
|
278
|
-
* auth-error path) otherwise. The Node path also sets `_handled` so h3
|
|
279
|
-
* doesn't double-write.
|
|
243
|
+
* - a Web `Response` or an auth-error object otherwise.
|
|
280
244
|
*/
|
|
281
245
|
export async function handleMcpRequest(
|
|
282
246
|
event: H3Event,
|
|
@@ -330,26 +294,9 @@ export async function handleMcpRequest(
|
|
|
330
294
|
return buildUnauthorizedBody(event);
|
|
331
295
|
}
|
|
332
296
|
|
|
333
|
-
//
|
|
334
|
-
//
|
|
335
|
-
//
|
|
336
|
-
// that stream dies and the client reports "session expired" / "not
|
|
337
|
-
// connected". The spec lets a server that offers no GET stream answer 405, so
|
|
338
|
-
// the client falls back to plain POST request/response. Reject GET here
|
|
339
|
-
// instead of letting the SDK open a doomed stream.
|
|
340
|
-
if (method === "DELETE") {
|
|
341
|
-
setResponseStatus(event, 204);
|
|
342
|
-
return "";
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
if (method !== "POST") {
|
|
346
|
-
setResponseStatus(event, 405);
|
|
347
|
-
return { error: "Method not allowed" };
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
// Read body for POST (GET has no body). Read it via the h3 helper exactly
|
|
351
|
-
// once; both transports accept it as a pre-parsed body so the request
|
|
352
|
-
// stream is never consumed twice.
|
|
297
|
+
// Read POST bodies through h3 exactly once. `createMcpHandler` accepts the
|
|
298
|
+
// parsed value, so neither its modern classifier nor its legacy fallback
|
|
299
|
+
// consumes the request stream a second time.
|
|
353
300
|
const body = method === "POST" ? await readBody(event) : undefined;
|
|
354
301
|
|
|
355
302
|
// Optional diagnostics for host capability negotiation. Keep disabled by
|
|
@@ -372,13 +319,7 @@ export async function handleMcpRequest(
|
|
|
372
319
|
}
|
|
373
320
|
}
|
|
374
321
|
|
|
375
|
-
|
|
376
|
-
// server from the SAME config + verified identity + request meta, so
|
|
377
|
-
// tools/list, tools/call, and the deep-link `_meta` are identical. A
|
|
378
|
-
// connected real caller (connect-minted token / `mcp install` /
|
|
379
|
-
// ACCESS_TOKEN / production) gets the full action surface even in local
|
|
380
|
-
// dev; unauthenticated dev probes stay sparse. See `external-agents` skill.
|
|
381
|
-
const server = await createMCPServerForRequest(config, authResult.identity, {
|
|
322
|
+
const serverRequestMeta: MCPRequestMeta = {
|
|
382
323
|
...requestMeta,
|
|
383
324
|
fullSurface: authResult.fullSurface === true,
|
|
384
325
|
inlineMcpApps:
|
|
@@ -389,76 +330,23 @@ export async function handleMcpRequest(
|
|
|
389
330
|
// When the caller minted their token with --full-catalog (catalog_scope:
|
|
390
331
|
// "full" JWT claim), bypass the connector-catalog tier filter.
|
|
391
332
|
...(authResult.fullCatalog === true ? { fullCatalog: true } : {}),
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
// the tools/call result and reports "session expired". JSON mode awaits
|
|
405
|
-
// the result inside the request lifecycle and returns it as one body.
|
|
406
|
-
enableJsonResponse: true,
|
|
407
|
-
});
|
|
408
|
-
await server.connect(transport);
|
|
409
|
-
try {
|
|
410
|
-
// The SDK transport writes directly to the Node response. Node-only by
|
|
411
|
-
// construction; we only reach here when real Node req/res exist.
|
|
412
|
-
await transport.handleRequest(nodeReq, nodeRes, body);
|
|
413
|
-
} catch (err: any) {
|
|
414
|
-
// The SDK transport writes directly to the Node response. If the socket
|
|
415
|
-
// is already closed/ended (client disconnected, or the host stream
|
|
416
|
-
// layer also flushed), Node throws ERR_STREAM_WRITE_AFTER_END *after*
|
|
417
|
-
// the MCP payload was already delivered correctly. Swallow that benign
|
|
418
|
-
// post-flush write so an external agent disconnecting mid-stream can
|
|
419
|
-
// never take down the server process; rethrow anything else.
|
|
420
|
-
if (err?.code !== "ERR_STREAM_WRITE_AFTER_END") throw err;
|
|
421
|
-
if (process.env.DEBUG)
|
|
422
|
-
console.log(
|
|
423
|
-
"[mcp] ignored post-flush ERR_STREAM_WRITE_AFTER_END (client disconnected)",
|
|
424
|
-
);
|
|
425
|
-
}
|
|
426
|
-
// Prevent H3 from double-writing the response
|
|
427
|
-
(event as any)._handled = true;
|
|
428
|
-
return undefined;
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
// ---- Web-standard response path (Nitro local dev, Netlify web runtime, CF,
|
|
432
|
-
// Deno, Bun) ---------------------------------------------------------------
|
|
433
|
-
//
|
|
434
|
-
// `StreamableHTTPServerTransport` is itself just a thin wrapper that
|
|
435
|
-
// converts the Node req/res to a web Request/Response and delegates to
|
|
436
|
-
// `WebStandardStreamableHTTPServerTransport.handleRequest(webRequest, {
|
|
437
|
-
// parsedBody })`. Using the web transport directly with the SAME options +
|
|
438
|
-
// the same pre-read `parsedBody` produces byte-identical protocol output
|
|
439
|
-
// (including the deep-link `_meta` built inside createMCPServerForRequest),
|
|
440
|
-
// and works on every web runtime because it returns a Web `Response`
|
|
441
|
-
// (JSON for request/response, or an SSE `ReadableStream` body which h3
|
|
442
|
-
// streams natively).
|
|
443
|
-
const { WebStandardStreamableHTTPServerTransport } =
|
|
444
|
-
await import("@modelcontextprotocol/sdk/server/webStandardStreamableHttp.js");
|
|
445
|
-
const transport = new WebStandardStreamableHTTPServerTransport({
|
|
446
|
-
sessionIdGenerator: undefined, // stateless — same as the Node path
|
|
447
|
-
// JSON request/response (not SSE) — see the Node fast-path note above.
|
|
448
|
-
// This is the serverless-safe framing: the result is computed and returned
|
|
449
|
-
// within the request, never pushed onto a stream after the instance froze.
|
|
450
|
-
enableJsonResponse: true,
|
|
451
|
-
});
|
|
452
|
-
await server.connect(transport);
|
|
333
|
+
};
|
|
334
|
+
const { createMcpHandler } = await import("@modelcontextprotocol/server");
|
|
335
|
+
const handler = createMcpHandler(
|
|
336
|
+
() =>
|
|
337
|
+
createMCPServerForRequest(config, authResult.identity, serverRequestMeta),
|
|
338
|
+
{
|
|
339
|
+
legacy: "stateless",
|
|
340
|
+
// Ordinary calls stay single-body JSON unless a handler emits a related
|
|
341
|
+
// message before its result. Subscription/listen remains SSE.
|
|
342
|
+
responseMode: "auto",
|
|
343
|
+
},
|
|
344
|
+
);
|
|
453
345
|
const webRequest = buildWebRequest(event, method);
|
|
454
|
-
|
|
455
|
-
// synthesized request has no body, so only pass the option for POST (where
|
|
456
|
-
// we actually have a parsed body). For GET the transport reads no body.
|
|
457
|
-
const response = await transport.handleRequest(
|
|
346
|
+
return handler.fetch(
|
|
458
347
|
webRequest,
|
|
459
348
|
method === "POST" ? { parsedBody: body } : undefined,
|
|
460
349
|
);
|
|
461
|
-
return response;
|
|
462
350
|
}
|
|
463
351
|
|
|
464
352
|
// ---------------------------------------------------------------------------
|
|
@@ -471,14 +359,10 @@ export async function handleMcpRequest(
|
|
|
471
359
|
* Endpoints: `/mcp` (public) and `/_agent-native/mcp` (compatibility).
|
|
472
360
|
* A custom route prefix only mounts that custom endpoint.
|
|
473
361
|
*
|
|
474
|
-
* Uses
|
|
475
|
-
*
|
|
476
|
-
*
|
|
477
|
-
*
|
|
478
|
-
* server uses the SDK's Node transport; the web-standard runtime (Nitro 3 /
|
|
479
|
-
* Netlify web runtime, Cloudflare, Deno, Bun) uses the SDK's web-standard
|
|
480
|
-
* transport. Both build the same server and produce identical JSON-RPC
|
|
481
|
-
* output.
|
|
362
|
+
* Uses the v2 Web Standard per-request handler with native 2026-07-28 serving
|
|
363
|
+
* and stateless 2025-era fallback. It carries no in-memory protocol session
|
|
364
|
+
* across invocations and works unchanged on Node, Nitro/Netlify web runtimes,
|
|
365
|
+
* Cloudflare, Deno, and Bun.
|
|
482
366
|
*
|
|
483
367
|
* Auth: Bearer token matching ACCESS_TOKEN/ACCESS_TOKENS or JWT via A2A_SECRET.
|
|
484
368
|
* No auth required when neither is configured (dev mode).
|
|
@@ -24,8 +24,6 @@
|
|
|
24
24
|
* of the serverless bundle.
|
|
25
25
|
*/
|
|
26
26
|
|
|
27
|
-
import type { ServerCapabilities } from "@modelcontextprotocol/sdk/types.js";
|
|
28
|
-
|
|
29
27
|
import {
|
|
30
28
|
MCP_LEGACY_ROUTE_PREFIX,
|
|
31
29
|
MCP_PUBLIC_ROUTE_PREFIX,
|
|
@@ -143,19 +141,10 @@ async function runProxy(opts: RunMCPStdioOptions): Promise<void> {
|
|
|
143
141
|
}
|
|
144
142
|
const target = `${origin}${mcpSubpath}`;
|
|
145
143
|
|
|
146
|
-
const { Client } =
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
const {
|
|
150
|
-
const { StdioServerTransport } =
|
|
151
|
-
await import("@modelcontextprotocol/sdk/server/stdio.js");
|
|
152
|
-
const {
|
|
153
|
-
ListToolsRequestSchema,
|
|
154
|
-
CallToolRequestSchema,
|
|
155
|
-
ListResourcesRequestSchema,
|
|
156
|
-
ReadResourceRequestSchema,
|
|
157
|
-
ListResourceTemplatesRequestSchema,
|
|
158
|
-
} = await import("@modelcontextprotocol/sdk/types.js");
|
|
144
|
+
const { Client, StreamableHTTPClientTransport } =
|
|
145
|
+
await import("@modelcontextprotocol/client");
|
|
146
|
+
const { Server } = await import("@modelcontextprotocol/server");
|
|
147
|
+
const { serveStdio } = await import("@modelcontextprotocol/server/stdio");
|
|
159
148
|
|
|
160
149
|
// --- Upstream HTTP client -------------------------------------------------
|
|
161
150
|
const clientTransport = new StreamableHTTPClientTransport(new URL(target), {
|
|
@@ -163,69 +152,72 @@ async function runProxy(opts: RunMCPStdioOptions): Promise<void> {
|
|
|
163
152
|
});
|
|
164
153
|
const client = new Client(
|
|
165
154
|
{ name: "agent-native-mcp-proxy", version: "1.0.0" },
|
|
166
|
-
{
|
|
155
|
+
{
|
|
156
|
+
capabilities: {},
|
|
157
|
+
versionNegotiation: { mode: "auto" },
|
|
158
|
+
},
|
|
167
159
|
);
|
|
168
160
|
await client.connect(clientTransport);
|
|
169
161
|
log(`Proxying stdio ⇄ ${target} (app: ${appId})`);
|
|
170
162
|
|
|
171
163
|
// --- Downstream stdio server ---------------------------------------------
|
|
172
164
|
const upstreamCapabilities = client.getServerCapabilities();
|
|
173
|
-
const capabilities:
|
|
165
|
+
const capabilities: NonNullable<
|
|
166
|
+
ReturnType<typeof client.getServerCapabilities>
|
|
167
|
+
> = { tools: {} };
|
|
174
168
|
if (upstreamCapabilities?.resources) capabilities.resources = {};
|
|
175
169
|
if (upstreamCapabilities?.extensions) {
|
|
176
170
|
capabilities.extensions = upstreamCapabilities.extensions;
|
|
177
171
|
}
|
|
178
172
|
|
|
179
|
-
const
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
173
|
+
const stdio = serveStdio(
|
|
174
|
+
() => {
|
|
175
|
+
const server = new Server(
|
|
176
|
+
{ name: `agent-native-${appId}`, version: "1.0.0" },
|
|
177
|
+
{ capabilities },
|
|
178
|
+
);
|
|
183
179
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
180
|
+
server.setRequestHandler("tools/list", async (request: any) => {
|
|
181
|
+
return client.listTools(request.params);
|
|
182
|
+
});
|
|
187
183
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
184
|
+
server.setRequestHandler("tools/call", async (request: any) => {
|
|
185
|
+
// Forward the call verbatim; the upstream appends the deep-link block.
|
|
186
|
+
return client.callTool(request.params);
|
|
187
|
+
});
|
|
192
188
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
return client.listResources(request.params);
|
|
198
|
-
},
|
|
199
|
-
);
|
|
200
|
-
|
|
201
|
-
server.setRequestHandler(
|
|
202
|
-
ListResourceTemplatesRequestSchema,
|
|
203
|
-
async (request: any) => {
|
|
204
|
-
return client.listResourceTemplates(request.params);
|
|
205
|
-
},
|
|
206
|
-
);
|
|
189
|
+
if (upstreamCapabilities?.resources) {
|
|
190
|
+
server.setRequestHandler("resources/list", async (request: any) => {
|
|
191
|
+
return client.listResources(request.params);
|
|
192
|
+
});
|
|
207
193
|
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
}
|
|
194
|
+
server.setRequestHandler(
|
|
195
|
+
"resources/templates/list",
|
|
196
|
+
async (request: any) => {
|
|
197
|
+
return client.listResourceTemplates(request.params);
|
|
198
|
+
},
|
|
199
|
+
);
|
|
215
200
|
|
|
216
|
-
|
|
217
|
-
|
|
201
|
+
server.setRequestHandler("resources/read", async (request: any) => {
|
|
202
|
+
return client.readResource(request.params);
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
return server;
|
|
206
|
+
},
|
|
207
|
+
{ legacy: "serve" },
|
|
208
|
+
);
|
|
218
209
|
|
|
219
210
|
// Keep the proxy alive until the client/transport closes.
|
|
220
211
|
await new Promise<void>((resolve) => {
|
|
221
212
|
const done = () => resolve();
|
|
222
|
-
stdioTransport.onclose = done;
|
|
223
213
|
clientTransport.onclose = done;
|
|
214
|
+
process.stdin.once("end", done);
|
|
224
215
|
process.once("SIGINT", done);
|
|
225
216
|
process.once("SIGTERM", done);
|
|
226
217
|
});
|
|
227
218
|
|
|
228
219
|
try {
|
|
220
|
+
await stdio.close();
|
|
229
221
|
await client.close();
|
|
230
222
|
} catch {
|
|
231
223
|
// best-effort
|
|
@@ -264,44 +256,44 @@ async function runStandalone(opts: RunMCPStdioOptions): Promise<void> {
|
|
|
264
256
|
|
|
265
257
|
const { autoDiscoverActions } = await import("../server/action-discovery.js");
|
|
266
258
|
const { createMCPServerForRequest } = await import("./build-server.js");
|
|
267
|
-
const {
|
|
268
|
-
await import("@modelcontextprotocol/sdk/server/stdio.js");
|
|
259
|
+
const { serveStdio } = await import("@modelcontextprotocol/server/stdio");
|
|
269
260
|
|
|
270
261
|
const actions = await autoDiscoverActions(cwd);
|
|
271
262
|
log(
|
|
272
263
|
`Standalone: discovered ${Object.keys(actions).length} action(s) in ${cwd}`,
|
|
273
264
|
);
|
|
274
265
|
|
|
275
|
-
const
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
266
|
+
const stdio = serveStdio(
|
|
267
|
+
() =>
|
|
268
|
+
createMCPServerForRequest(
|
|
269
|
+
{
|
|
270
|
+
name: appId.charAt(0).toUpperCase() + appId.slice(1),
|
|
271
|
+
appId,
|
|
272
|
+
description: `Agent-native ${appId} app (standalone MCP)`,
|
|
273
|
+
actions,
|
|
274
|
+
// No askAgent in standalone — there is no running engine/runtime here.
|
|
275
|
+
// builtin cross-app tools stay on so `list_apps` / `open_app` /
|
|
276
|
+
// `create_workspace_app` / `list_templates` still work from disk.
|
|
277
|
+
},
|
|
278
|
+
// No verified identity in standalone (no inbound auth header). Runs with
|
|
279
|
+
// platform-default scope, same as a tokenless local HTTP mount.
|
|
280
|
+
undefined,
|
|
281
|
+
{
|
|
282
|
+
origin,
|
|
283
|
+
clientName: "agent-native-mcp-standalone",
|
|
284
|
+
// Compact by default; opt into the full catalog with the env flag.
|
|
285
|
+
fullCatalog: process.env.AGENT_NATIVE_MCP_FULL_CATALOG === "1",
|
|
286
|
+
},
|
|
287
|
+
),
|
|
288
|
+
{ legacy: "serve" },
|
|
294
289
|
);
|
|
295
290
|
|
|
296
|
-
const transport = new StdioServerTransport();
|
|
297
|
-
await server.connect(transport);
|
|
298
|
-
|
|
299
291
|
await new Promise<void>((resolve) => {
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
process.once("
|
|
303
|
-
process.once("SIGTERM", done);
|
|
292
|
+
process.stdin.once("end", resolve);
|
|
293
|
+
process.once("SIGINT", resolve);
|
|
294
|
+
process.once("SIGTERM", resolve);
|
|
304
295
|
});
|
|
296
|
+
await stdio.close();
|
|
305
297
|
}
|
|
306
298
|
|
|
307
299
|
/**
|
|
@@ -228,8 +228,7 @@ export class McpClientManager {
|
|
|
228
228
|
// If we previously loaded without stdio and now need it, top up.
|
|
229
229
|
if (needStdio && !this.sdk.StdioClientTransport && isNode()) {
|
|
230
230
|
try {
|
|
231
|
-
const stdioMod =
|
|
232
|
-
await import("@modelcontextprotocol/sdk/client/stdio.js");
|
|
231
|
+
const stdioMod = await import("@modelcontextprotocol/client/stdio");
|
|
233
232
|
this.sdk.StdioClientTransport = stdioMod.StdioClientTransport;
|
|
234
233
|
} catch (err: any) {
|
|
235
234
|
console.warn(
|
|
@@ -240,15 +239,11 @@ export class McpClientManager {
|
|
|
240
239
|
return this.sdk;
|
|
241
240
|
}
|
|
242
241
|
try {
|
|
243
|
-
const clientMod =
|
|
244
|
-
await import("@modelcontextprotocol/sdk/client/index.js");
|
|
245
|
-
const httpMod =
|
|
246
|
-
await import("@modelcontextprotocol/sdk/client/streamableHttp.js");
|
|
242
|
+
const clientMod = await import("@modelcontextprotocol/client");
|
|
247
243
|
let StdioClientTransport: any = null;
|
|
248
244
|
if (needStdio && isNode()) {
|
|
249
245
|
try {
|
|
250
|
-
const stdioMod =
|
|
251
|
-
await import("@modelcontextprotocol/sdk/client/stdio.js");
|
|
246
|
+
const stdioMod = await import("@modelcontextprotocol/client/stdio");
|
|
252
247
|
StdioClientTransport = stdioMod.StdioClientTransport;
|
|
253
248
|
} catch (err: any) {
|
|
254
249
|
console.warn(
|
|
@@ -259,7 +254,7 @@ export class McpClientManager {
|
|
|
259
254
|
this.sdk = {
|
|
260
255
|
Client: clientMod.Client,
|
|
261
256
|
StdioClientTransport,
|
|
262
|
-
StreamableHTTPClientTransport:
|
|
257
|
+
StreamableHTTPClientTransport: clientMod.StreamableHTTPClientTransport,
|
|
263
258
|
};
|
|
264
259
|
return this.sdk;
|
|
265
260
|
} catch (err: any) {
|
|
@@ -450,6 +445,7 @@ export class McpClientManager {
|
|
|
450
445
|
},
|
|
451
446
|
},
|
|
452
447
|
},
|
|
448
|
+
versionNegotiation: { mode: "auto" },
|
|
453
449
|
} as any,
|
|
454
450
|
);
|
|
455
451
|
const recordConnectionError: ErrorSink = () => {};
|
|
@@ -459,7 +455,7 @@ export class McpClientManager {
|
|
|
459
455
|
// Attach a transport-level error handler before connect() so the SDK's
|
|
460
456
|
// internal fire-and-forget paths (initial SSE stream open, scheduled
|
|
461
457
|
// reconnects, message-handler-triggered reconnects — see processStream()
|
|
462
|
-
// in @modelcontextprotocol/
|
|
458
|
+
// in @modelcontextprotocol/client) cannot leak as
|
|
463
459
|
// unhandled promise rejections. On AWS Lambda the long-lived socket
|
|
464
460
|
// gets reaped ~60s after the function returns; without this handler the
|
|
465
461
|
// resulting `socket hang up` surfaces as an unhandledRejection and
|