You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Iteration three: generate a runnable MCP server from the design
New 'MCP server' export emits a complete TypeScript project — static MCP
runtime (stdio) + generated per-operation data. Each tool proxies to its real
OpenAPI operation (path/query/header/body mapping), resources and prompts are
served, and auth is derived from the spec's security scheme. Download the zip,
npm install && npm run dev, and it serves.
Verified: generated against the live API Evangelist OpenAPI, installed the real
@modelcontextprotocol/sdk (1.29), tsc --noEmit clean, and an MCP client drove
it end to end — tools/resources/prompts list, prompt render, and live upstream
tool calls (get_service_info, search_network) returned real API responses.
Also fixed a latent tsc-only Blob typing error in zip.ts (iteration one).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: README.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,6 +15,7 @@ An OpenAPI tells developers what your API can do. Agents need more. Toolsmith is
15
15
- an **MCP server design** — tools, resources, prompts, and sampling in the shapes MCP clients see
16
16
- a registry-ready **server.json** ([2025-09-29 schema](https://static.modelcontextprotocol.io/schemas/2025-09-29/server.schema.json)) for the official MCP Registry
17
17
- an **Agent Skills bundle** — one [`SKILL.md`](https://agentskills.io/specification) per skill, zipped by directory, with an [agent-skills-discovery](https://github.com/cloudflare/agent-skills-discovery-rfc) v0.2.0 `index.json` ready for `.well-known/agent-skills/`
18
+
- a **runnable MCP server** — a complete TypeScript project (official [`@modelcontextprotocol/sdk`](https://github.com/modelcontextprotocol/typescript-sdk), stdio) where every tool proxies to its real OpenAPI operation with path/query/header/body mapping and auth derived from the spec's security scheme; `npm install && npm run dev` and it serves. The runtime is static; only the operation data is generated, so you can regenerate as the design evolves.
18
19
- the **APIs.json properties** that wire the artifacts to your provider listing
Copy file name to clipboardExpand all lines: src/engine.ts
+265Lines changed: 265 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -421,3 +421,268 @@ export function emitApisJsonProps(doc: any): any {
421
421
{type: 'AgentSkills',url: 'https://example.com/.well-known/agent-skills/index.json',description: `Agent Skills for working with ${title} competently.`},
422
422
];
423
423
}
424
+
425
+
// ---- MCP server scaffold (runnable TypeScript codegen) -------------------------
426
+
// Turn the design into a complete, runnable stdio MCP server that proxies each tool
427
+
// to its real OpenAPI operation. The runtime (src/index.ts) is static; only the
428
+
// operation data and auth (src/operations.ts) are generated from the design.
429
+
exportconstMCP_SDK_RANGE='^1.12.0';
430
+
431
+
// Derive an applyAuth(headers, query) body + .env keys from the OpenAPI security scheme.
body: ' if (process.env.API_TOKEN) headers["authorization"] = "Bearer " + process.env.API_TOKEN;',
466
+
env: ['API_TOKEN='],
467
+
note: declared
468
+
? 'Bearer token: set `API_TOKEN`.'
469
+
: 'No security scheme was declared in the OpenAPI — the scaffold falls back to an optional `API_TOKEN` bearer. Edit `applyAuth` in `src/operations.ts` if your API differs.',
470
+
};
471
+
}
472
+
473
+
constINDEX_TS=`#!/usr/bin/env node
474
+
// Generated by Toolsmith (toolsmith.apicommons.org). This runtime is static — it reads
475
+
// the generated operation data in ./operations.ts and serves it over MCP (stdio),
476
+
// proxying each tool call to the upstream REST API.
477
+
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
478
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
? ['','## Sampling','','These tools were designed to use sampling (asking the client\'s model to reason over results). The generated handlers return the raw upstream response; add a sampling round-trip with `server.createMessage(...)` where you want the server to summarize or transform before replying:','', ...sampling.map((x)=>`- \`${x.tool}\`${x.purpose ? ` — ${x.purpose}` : ''}`)].join('\n')
637
+
: '';
638
+
639
+
constreadme=[
640
+
`# ${title} MCP Server`,
641
+
'',
642
+
`Generated by [Toolsmith](https://toolsmith.apicommons.org) from the enriched OpenAPI for **${title}**. A stdio [MCP](https://modelcontextprotocol.io) server that proxies each tool to the upstream REST API at \`${baseUrl}\`.`,
openapi: 'Your OpenAPI with the agent layer embedded — x-mcp on each operation, x-agent-skills alongside, x-mcp-server at the root.',
399
399
mcp: 'The MCP server design — tools, resources, prompts, and sampling in the shapes clients see. Hand this to whoever builds or generates the server.',
400
400
serverjson: 'A registry-ready server.json (2025-09-29 schema) for publishing to the official MCP Registry.',
401
+
scaffold: 'A complete, runnable TypeScript MCP server — each tool wired to its OpenAPI operation, with resources, prompts, and auth from the spec. Download the project, then npm install && npm run dev.',
401
402
skills: 'One SKILL.md per skill, each in its own directory, plus an agent-skills-discovery index.json (v0.2.0, the format apis.io serves at .well-known/agent-skills/). Download bundles it all as a zip.',
402
403
apisjson: 'APIs.json property entries wiring these artifacts to your provider listing (swap in your real URLs).',
currentOut=hasTool ? files.map((f)=>`━━ ${f.path} ━━\n${f.content}`).join('\n') : 'No MCP tools designed yet — draft some on the Design tab, then generate the server.';
<p>An OpenAPI tells developers what your API can do. Agents need more: an <strong>MCP tool</strong> for each operation with an honest input schema and behavior annotations, the <strong>resources</strong> and <strong>prompts</strong> that give it context, <strong>sampling</strong> guidance where the server should lean on the client's model — and <strong>Agent Skills</strong> that teach an agent to apply each tool competently.</p>
440
451
<p>Toolsmith is the workbench for that layer. Load an OpenAPI (the API Evangelist and APIs.io APIs are one click away), <strong>draft</strong> a design for every operation deterministically, then refine each tool, resource, prompt, and skill by hand. The design lives inside your OpenAPI as <code>x-mcp</code> and <code>x-agent-skills</code> extensions, so the enriched contract is the single artifact of record.</p>
441
-
<p>Export the <strong>enriched OpenAPI</strong>, an <strong>MCP server design</strong>, a registry-ready <strong>server.json</strong>, an <strong>Agent Skills bundle</strong>, and the <strong>APIs.json properties</strong> that wire it all to your provider listing. It pairs with <a href="https://contextgate.apicommons.org" target="_blank" rel="noopener">Context Gate</a> and the <a href="https://validator.apicommons.org" target="_blank" rel="noopener">Validator</a>.</p>
452
+
<p>Export the <strong>enriched OpenAPI</strong>, an <strong>MCP server design</strong>, a registry-ready <strong>server.json</strong>, an <strong>Agent Skills bundle</strong>, and the <strong>APIs.json properties</strong> that wire it all to your provider listing — or generate a <strong>complete, runnable MCP server</strong> in TypeScript, every tool wired to its OpenAPI operation, ready to <code>npm install && npm run dev</code>. It pairs with <a href="https://contextgate.apicommons.org" target="_blank" rel="noopener">Context Gate</a> and the <a href="https://validator.apicommons.org" target="_blank" rel="noopener">Validator</a>.</p>
442
453
<p class="muted small">Runs entirely in your browser — your API definitions never leave the page. Work is saved locally as you edit.</p>
0 commit comments