بنقرة واحدة
calling-mcp-tools-via-subprocess
Bypasses a flaky MCP broker by spawning the server directly.
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
Bypasses a flaky MCP broker by spawning the server directly.
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
استنادا إلى تصنيف SOC المهني
Flags risky shell commands and unsafe tree ops.
Detects high-confidence security risks in code.
Surfaces the dojo's non-negotiable prime directives.
Activates the dojo framework at the start of a session.
Plans multi-step work before writing code.
Captures lessons and promotes recurring patterns.
| name | calling-mcp-tools-via-subprocess |
| description | Bypasses a flaky MCP broker by spawning the server directly. |
| tier | optional |
| category | integration |
| created_by | human |
| platforms | ["windows","macos","linux"] |
| tags | ["mcp","subprocess","reliability"] |
| author | Andreas Wasita (@andreaswasita) |
Bypasses a flaky MCP broker by spawning the server binary directly and speaking JSON-RPC over stdio, using the dojo helpers mcp/scripts/mcp-subprocess.js and mcp-subprocess.ps1. Does NOT replace using-mcp for normal operation — broker is the fast path; subprocess is the reliable fallback.
tools/call hangs or times out.mcp/scripts/mcp-subprocess.js and mcp/scripts/mcp-subprocess.ps1.az login, gh auth).powershell Copilot tool to run the helper.1. Resolve the server binary path.
2. Call the helper with binary, tool name, and JSON args.
3. Receive parsed `result.content` text.
4. Wrap recurring calls in a per-server module to keep skill code clean.
5. Cache results in-session (or to `.cache/mcp/`) since startup is 200–800ms.
| Helper | Use from |
|---|---|
node mcp/scripts/mcp-subprocess.js call <bin> <tool> <jsonArgs> | bash / cmd / CI |
Invoke-McpTool -Bin <bin> -Tool <name> -Params @{...} | PowerShell |
| Binary location | Source |
|---|---|
~/.copilot/installed-plugins/_direct/<vendor>--<name>/dist/index.js | Copilot CLI |
~/.npm/_npx/<hash>/node_modules/<pkg>/dist/index.js | npx cache |
Global install: npm i -g <pkg> then which <pkg> | Most reliable |
| Auth source | Set before spawn |
|---|---|
| Azure / MSX | az login |
| GitHub | gh auth login OR $env:GITHUB_PERSONAL_ACCESS_TOKEN |
| Kubernetes | Current kubeconfig context |
Pick the most reliable location from the table. For production scripts, npm i -g <pkg> once and pin the version — do not depend on the npx cache.
bash:
node mcp/scripts/mcp-subprocess.js call "$BIN" get_my_deals '{"limit":10}'
PowerShell:
. mcp/scripts/mcp-subprocess.ps1
Invoke-McpTool -Bin "C:\path\to\server\index.js" -Tool "get_my_deals" -Params @{ limit = 10 }
Both helpers do exactly:
node <bin> with piped stdio.initialize (id=1).tools/call (id=2)."id":2.result.content text.Do not sprinkle subprocess calls through skills. Wrap each server in one module:
// scripts/github-mcp.js
const { callTool } = require("../mcp/scripts/mcp-subprocess.js");
const BIN = require("path").join(process.env.HOME, ".npm", "_npx", "...", "server-github", "dist", "index.js");
exports.searchRepos = (q) => callTool(BIN, "search_repositories", { query: q });
Subprocess startup costs 200–800ms per call. For multi-call flows:
(tool, JSON.stringify(args))..cache/mcp/<server>.json for long-running scripts.async function callWithFallback(toolName, args) {
try {
return await nativeMcpCall(toolName, args);
} catch (err) {
console.error(`Broker failed (${err.message}); falling back to subprocess.`);
return await callTool(BIN, toolName, args);
}
}
Test the subprocess path in CI even if your IDE uses the broker.
npx -y per invocation in production scripts. Install once.callTool scattered across skills.grep the call sites).