Some checks failed
build-packages / resolve bundled mosh-client (push) Has been cancelled
build-packages / resolve bundled et-client (push) Has been cancelled
build-packages / build-macos (push) Has been cancelled
build-packages / build-windows (push) Has been cancelled
build-packages / build-linux-x64 (push) Has been cancelled
build-packages / build-linux-arm64 (push) Has been cancelled
build-packages / release (push) Has been cancelled
build-packages / update Nix release metadata (push) Has been cancelled
build-packages / bump homebrew tap (push) Has been cancelled
test / lint-and-test (push) Has been cancelled
AI automation / Route event (push) Has been cancelled
AI automation / Hand reopened issue to maintainers (push) Has been cancelled
AI automation / Clean source issue state (push) Has been cancelled
AI automation / Reconcile handoffs (push) Has been cancelled
AI automation / Classify issue (push) Has been cancelled
AI automation / Claude Code smoke (push) Has been cancelled
AI automation / Review issue follow-up (push) Has been cancelled
AI automation / Publish issue follow-up (push) Has been cancelled
AI automation / Implement with Claude Code (push) Has been cancelled
AI automation / Publish implement PR (push) Has been cancelled
AI automation / Continue queued issue comments (push) Has been cancelled
AI automation / Codex review loop (push) Has been cancelled
AI automation / Publish Codex fix (push) Has been cancelled
AI automation / Clear Codex dispatch marker (push) Has been cancelled
AI automation / Own PR re-request Codex (push) Has been cancelled
AI automation / External PR re-request Codex (push) Has been cancelled
AI automation / Poll Codex reaction / retry (push) Has been cancelled
build-et-binaries / build-linux-x64 (push) Has been cancelled
build-et-binaries / build-linux-arm64 (push) Has been cancelled
build-et-binaries / build-macos-universal (push) Has been cancelled
build-et-binaries / build-windows-x64 (push) Has been cancelled
build-et-binaries / release (push) Has been cancelled
58 lines
2.1 KiB
JavaScript
58 lines
2.1 KiB
JavaScript
"use strict";
|
|
|
|
/**
|
|
* Build the netcatty-mcp-server config to inject into an SDK agent as an
|
|
* EXTERNAL MCP server. Reuses mcpServerBridge.buildMcpServerConfig (unchanged)
|
|
* so the approval/scope/blocklist layer is identical across integrations.
|
|
*
|
|
* Returns an array of netcatty MCP server configs (0 or 1 entry):
|
|
* { name, type:'stdio', command, args, env:[{name,value}, ...] }
|
|
* Each driver converts this neutral shape into its SDK's MCP format.
|
|
*/
|
|
async function buildInjectedMcpServers({
|
|
mcpServerBridge,
|
|
chatSessionId,
|
|
toolIntegrationMode,
|
|
}) {
|
|
try {
|
|
// Start the netcatty control host for BOTH modes. getOrCreateHost binds the
|
|
// TCP server and writes the netcatty-tool-cli discovery file on bind:
|
|
// - mcp mode: the host is injected below as an MCP server.
|
|
// - skills mode: the agent reaches the host through that discovery file via
|
|
// the netcatty CLI. Skipping this in skills mode left no host for the CLI
|
|
// to find, so every `netcatty-tool-cli` call failed with APP_NOT_RUNNING.
|
|
const mcpPort = await mcpServerBridge.getOrCreateHost();
|
|
// Skills mode drives the netcatty CLI, not an injected MCP server.
|
|
if (toolIntegrationMode !== "mcp") return [];
|
|
const scopedIds = mcpServerBridge.getScopedSessionIds(chatSessionId);
|
|
const netcattyMcpConfig = mcpServerBridge.buildMcpServerConfig(
|
|
mcpPort,
|
|
scopedIds,
|
|
chatSessionId,
|
|
);
|
|
return [netcattyMcpConfig];
|
|
} catch (err) {
|
|
console.error("[sdk] Failed to ensure netcatty host / inject MCP server:", err?.message || err);
|
|
return [];
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Convert the neutral env-pair array ([{name,value}]) used by
|
|
* buildMcpServerConfig into a plain {KEY:VALUE} object, which is what the
|
|
* claude/codex/copilot SDKs expect for an MCP server's env field.
|
|
*/
|
|
function mcpEnvPairsToObject(envPairs) {
|
|
const out = {};
|
|
if (Array.isArray(envPairs)) {
|
|
for (const pair of envPairs) {
|
|
if (pair && typeof pair.name === "string" && typeof pair.value === "string") {
|
|
out[pair.name] = pair.value;
|
|
}
|
|
}
|
|
}
|
|
return out;
|
|
}
|
|
|
|
module.exports = { buildInjectedMcpServers, mcpEnvPairsToObject };
|