protomcp
v0.3.0
Published
Write MCP tools in TypeScript. No MCP knowledge required.
Maintainers
Readme
protomcp
TypeScript SDK for protomcp -- build MCP servers with tools, resources, and prompts in one file, one command.
Install
npm install protomcpYou also need the pmcp CLI:
brew install msilverblatt/tap/protomcpQuick Start
// server.ts
import { tool, resource, prompt, ToolResult } from 'protomcp';
import { z } from 'zod';
tool({
name: 'add',
description: 'Add two numbers',
args: z.object({ a: z.number(), b: z.number() }),
handler: ({ a, b }) => new ToolResult({ result: String(a + b) }),
});
resource({
uri: 'config://app',
description: 'App configuration',
handler: (uri) => ({ uri, text: '{"debug": false, "version": "2.1"}' }),
});
prompt({
name: 'explain',
description: 'Explain a concept',
arguments: [{ name: 'topic', required: true }],
handler: (args) => [{ role: 'user', content: `Explain ${args.topic} in simple terms` }],
});pmcp dev server.tsTool Groups
Group related actions under a single tool with per-action schemas:
import { toolGroup, ToolResult } from 'protomcp';
import { z } from 'zod';
toolGroup({
name: 'math',
description: 'Math operations',
actions: {
add: {
description: 'Add two numbers',
args: z.object({ a: z.number(), b: z.number() }),
handler: ({ a, b }) => new ToolResult({ result: String(a + b) }),
},
multiply: {
description: 'Multiply two numbers',
args: z.object({ a: z.number(), b: z.number() }),
handler: ({ a, b }) => new ToolResult({ result: String(a * b) }),
},
},
});Documentation
License
MIT
