Add support for loading tool handlers from external files in MCP server core#5085
Add support for loading tool handlers from external files in MCP server core#5085
Conversation
…er core Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
…lization error handling Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
|
|
||
| // Wrap the handler to ensure it returns the expected MCP response format | ||
| // and handles both sync and async handlers | ||
| tool.handler = async args => { |
There was a problem hiding this comment.
@copilot move creation of handler into own function to avoid bloating the closure.
There was a problem hiding this comment.
Extracted handler wrapper to createWrappedHandler(server, toolName, handlerFn) function at line 213. This avoids closure bloat by passing only the required parameters. Commit: ac2f332
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
|
@copilot add support for handlers pointing to a shell script (.sh). In that case, use the same convention as a custom github action to populate the env vars with the inputs and read the output from the output env vars as well, just like custom actions. |
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Added shell script (.sh) handler support using GitHub Actions convention:
Added 4 new tests covering shell script execution, multiple outputs, error handling, and input name conversion. Commit: cfe72e5 |
|
🤖 ALERT: Smoke Copilot No Firewall failed. ANOMALY_DETECTED. REPAIR_REQUIRED. |
|
💥 WHOOSH! Smoke Claude springs into action on this pull request! [Panel 1 begins...] |
|
🔮 The ancient spirits stir... Smoke Codex awakens to divine this pull request... |
|
💀 Blimey! Changeset Generator failed and walked the plank! No treasure today, matey! ☠️ |
|
📰 DEVELOPING STORY: Smoke Copilot reports failed. Our correspondents are investigating the incident... |
Smoke Test SummaryTest Run: 2025-11-29T16:41:14Z
|
|
Latest merged PRs:
|
|
@copilot update smoke agentic workflows to try to write under /tmp/gh-aw/agent folder |
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
|
@copilot recompile workflows |
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
|
📰 DEVELOPING STORY: Smoke Copilot reports failed. Our correspondents are investigating the incident... |
|
🤖 SYSTEM_INIT: Smoke Copilot No Firewall ACTIVATED. PROCESSING pull request. ALL SUBSYSTEMS ONLINE. |
|
🎉 Yo ho ho! Changeset Generator found the treasure and completed successfully! ⚓💰 |
|
🔮 The ancient spirits stir... Smoke Codex awakens to divine this pull request... |
|
💥 WHOOSH! Smoke Claude springs into action on this pull request! [Panel 1 begins...] |
Smoke Test ResultsLast 2 merged PRs:
Test Results:
Status: PASS
|
Smoke Test SummaryTest Run: 2025-11-29T17:23:28Z Test Results
|
|
Latest merged PRs:
|
mcp_server_core.cjsto:loadToolHandlers(tools, basePath)that loads handler functions from file pathscreateWrappedHandlerfunction to avoid closure bloatdebugErrormethod for refactored error handling with automatic Error castinghandleMessageandprocessReadBufferto be async to support async handlersmcp_server_core.test.cjsOriginal prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.
Changeset
handlerfile path (supports sync/async handlers, ES module default exports, shell-script handlers, path traversal protection, serialization fallback, and logging). Tests and workflows updated.Smoke Test Summary
Test Run: 2025-11-29T17:23:26Z
Status: PASS
Summary: All smoke tests passed - GitHub MCP, file writing, bash tools, and Playwright validated