@apexmcp/sdk
v1.0.4
Published
Developer-first SDK for building MCP (Model Context Protocol) servers in the ApexMCP ecosystem.
Downloads
549
Maintainers
Readme
@apexmcp/sdk
Developer-first SDK for building MCP (Model Context Protocol) servers in the ApexMCP ecosystem.
Goals
- Tiny: a working MCP server in <10 LOC
- Elegant: fluent builder API with good defaults
- Extensible: plugins/hooks, plus escape hatches to the underlying
McpServer - Compatible: built on the official
@modelcontextprotocol/sdk
Quick start (STDIO)
import { apex, t } from '@apexmcp/sdk';
const server = apex
.createServer('my-server', '0.1.0')
.tool({
name: 'hello',
description: 'Say hello',
input: t.Object({ name: t.String() }),
handler: ({ name }) => apex.text(`Hello ${name}`, { name }),
});
await server.listenStdio();Quick start (HTTP-only, Deno Deploy)
import { apex, t } from '@apexmcp/sdk';
const server = apex
.createServer('my-server', '0.1.0')
.tool({
name: 'hello',
description: 'Say hello',
input: t.Object({ name: t.String() }),
handler: ({ name }) => apex.text(`Hello ${name}`, { name }),
});
export const fetch = server.fetch; // serves MCP on /mcp (and /health)Mount into an existing router (example: Hono)
import { Hono } from 'hono';
import { apex, t } from '@apexmcp/sdk';
const server = apex
.createServer('my-server', '0.1.0')
.tool({
name: 'hello',
description: 'Say hello',
input: t.Object({ name: t.String() }),
handler: ({ name }) => apex.text(`Hello ${name}`, { name }),
});
const app = new Hono();
const { mcp, health } = server.routes();
app.all('/mcp', c => mcp(c.req.raw));
app.get('/health', c => health(c.req.raw));
export const fetch = app.fetch;API highlights
apex.createServer(name, version, options?)server.tool({ name, description, input, handler, ... })server.resource({ name, uri, mimeType?, handler, ... })server.use(plugin)server.onShutdown(fn)server.fetch/server.asFetch({ mcpPath, healthPath })server.routes()(router-friendly{ mcp, health })server.mcp(escape hatch to the official MCP server)
