mcp-scripting

Write JavaScript to discover, inspect, and orchestrate MCP tool calls.

Updated Aug 2, 2026
One-click install
npx skills add https://github.com/mikalv/pi-extensions --skill mcp-scripting-mikalv
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: mcp-scripting
Source: https://github.com/mikalv/pi-extensions/tree/main/packages/pi-mcp-adapter/skills/mcp-scripting
Command: npx skills add https://github.com/mikalv/pi-extensions --skill mcp-scripting-mikalv

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Calling multiple MCP tools one at a time is slow and inflexible when a task needs loops, filtering, chaining, or fan-out across many tool invocations. This Skill teaches how to write ordinary JavaScript that runs through the mcpScript runtime to orchestrate multi-call MCP workflows in a single execution. ## Core Features & Use Cases - Tool Discovery and Inspection: Search for candidate tools with tools.search and inspect exact schemas with tools.describe before calling. - Programmatic Orchestration: Use plain JavaScript loops, conditionals, and Promise utilities to chain, filter, and fan out MCP tool calls with structured error handling on each result. - Use Case: Imagine you need to search GitHub for open bug issues, then enrich each result with data from another MCP server. Write one script that searches for the right tools, describes their schemas, calls them in sequence, and emits progress along the way. ## Quick Start Write a JavaScript snippet that searches for an MCP tool, describes it, and calls it, then run it through mcpScript.

Frequently Asked Questions about mcp-scripting

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I call multiple MCP tools in one script?▼

Write ordinary JavaScript using loops and Promise utilities, then pass the source as the code argument to mcpScript. Inside the script, use tools.search to find tools, tools.describe to inspect schemas, and tools.call to invoke them with error handling on each result.

When should I use mcpScript instead of a single mcp call?▼

Use mcpScript for multi-call work involving loops, filtering, chaining, or fan-out between calls. Use the plain mcp tool for a single search, describe, status check, auth action, or one tool call.

How do I handle errors from MCP tool calls in a script?▼

Each tools.call resolves to either { ok: true, data } or { ok: false, error }, so check the ok flag and return or branch on failures. Failed calls do not stop the script, so explicit handling is required.

Why does Object.keys(tools) throw an error?▼

The tools object is a non-enumerable proxy, so enumeration methods like Object.keys throw by design. Always use tools.search for discovery instead of inspecting the proxy directly.

What is the timeout limit for mcpScript execution?▼

The default script timeout is 30 seconds, after which the worker is terminated, including for infinite loops. Design scripts to complete within this window and avoid unbounded iteration.

How do I call an MCP tool whose name contains hyphens?▼

Use bracket syntax such as tools["server_tool-name"](args) for hyphenated flat paths. If a path collides with reserved names like search, call, describe, or then, invoke it via tools.call("exact-path", args).