@nwire/mcp
v0.15.1
Published
Nwire MCP (Model Context Protocol) server — exposes the kernel's CommandRouter as MCP tools over stdio. AI clients (Claude, Cursor, …) drive nwire commands the same way the CLI and Studio do.
Readme
@nwire/mcp
Model Context Protocol — Nwire wires as MCP tools.
pnpm add @nwire/mcp @nwire/app @nwire/endpoint @nwire/wiresAs an adopter
The 0.10 adopter consumes wires whose binding.$adapter === "mcp" and
exposes them as MCP tools — same wire, same handler, served alongside
HTTP and queue under one endpoint:
import { createApp } from "@nwire/app";
import { endpoint } from "@nwire/endpoint";
import { tool } from "@nwire/wires/mcp";
import { httpKoa } from "@nwire/koa";
import { mcpAdapter } from "@nwire/mcp";
import { z } from "zod";
const app = createApp({ appName: "tasks" });
app.wire(
tool("create-task", {
description: "Create a task",
input: z.object({ title: z.string() }),
}),
async (input) => ({ id: createId(), title: input.title }),
);
const mcp = mcpAdapter();
await endpoint("tasks", { port: 3000 })
.use(httpKoa({ prefix: "/api" }))
.use(mcp)
.mount(app)
.run();
// In-process introspection — no stdio server required:
mcp.list(); // [{ name, description, inputSchema }]
await mcp.call("create-task", { title: "x" });Stdio server (legacy serveMcp)
The original serveMcp() entry — JSON-RPC 2.0 over stdin/stdout, suitable
for direct Claude Desktop / Cursor / IDE plugin integration — stays
available:
import { serveMcp } from "@nwire/mcp";
import { createKernel } from "./kernel";
const kernel = createKernel();
kernel.router.register("dev", devHandler);
await serveMcp({ kernel, serverName: "my-app" });
// Process speaks MCP over stdin/stdout; stderr is for logs.Claude Desktop config:
{ "mcpServers": { "my-app": { "command": "node", "args": ["./mcp.js"] } } }Surface
mcpAdapter(config?)— 0.10 adopterserveMcp(options)— stdio JSON-RPC server (legacy)inspectTools,findInspectTool— read-only introspection toolswriteTools,findWriteTool— mutating tools that drive/__nwire/*
Related
@nwire/wires—tool()binding helper@nwire/endpoint— adopter lifecycle hostexamples/multi-transport— MCP alongside HTTP + queue
