Release candidate — 1.0.0-rc.9
StitchAPI

Call one stitch as a function, a CLI command, and an agent tool

One definition, four front doors — in-process, shell, HTTP, and MCP — with nothing about the stitch changing.

Task

You have defined an API call once. You want to use it in app code, run it ad-hoc from the shell, and let an agent call it — without redefining it three times.

Example

One way: define the stitch once with a name, then reach it through each surface.

// stitches.ts — define it once, export it by name.
import {  } from 'stitchapi';

export const  = <{ : number; : string }>({
    : 'getUser',
    : 'https://api.example.com',
    : '/users/{id}',
});

// In app code: call it as a typed async function.
const  = await ({ : { : 1 } });

From the shell, the CLI loads the module and runs it by name:

stitch run getUser --id 1

To an agent over MCP, the single run_stitch tool covers it:

{
    "name": "run_stitch",
    "input": { "name": "getUser", "input": { "params": { "id": 1 } } }
}

How it works

One definition, four surfaces. The in-process function awaits or .stream()s it; the CLI (stitch run) loads the module and runs it by name; MCP exposes it to agents through the single run_stitch tool; and it can be served over HTTP. The export name, getUser, is what the CLI, HTTP and MCP resolve. The configured name labels the stitch's traces. Nothing else about the definition changes between front doors.

See also

On this page