mcp-server-scaffold
Skill8 starsChanged 9 months agoMITView on GitHub
Generate Model Context Protocol (MCP) tool servers from API descriptions, enabling AI assistants to connect to external services
- Reads credentials
- Installs packages
1 other project uses a version of this.
Adopted by
Most recently taken up by
- jpantsjoha/ai-native-developer-experiencetheir own version, first seen Aug 7, 2026
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 1
- jpantsjoha/ai-native-developer-experience★ 12same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository9 other files it gives its agents.
The file
We split this skill into the rules it gives an agent
6 rules. About 0 are common, 6 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈6
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 19
Use this skill when building MCP servers to connect AI assistants to APIs, databases, or custom tools.
- Distinctive: line 303
Purpose: Test MCP server tools and validate responses.
- Distinctive: line 345
Scenario: Create MCP server for GitHub API
- Distinctive: line 528
Always specify required fields and types:
- Distinctive: line 603
Before deploying MCP server:
- Distinctive: line 685
Test tools with mock API
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
mcp-server-scaffold
Trigger
Use this skill when building MCP servers to connect AI assistants to APIs, databases, or custom tools.
Trigger phrases:
- "Create MCP server for [API]"
- "Generate MCP tool server"
- "Build MCP connector for [service]"
- "Scaffold MCP server from OpenAPI"
- "Connect Claude to [API]"
Overview
The Model Context Protocol (MCP) is an open standard for connecting AI assistants to tools and data sources. This skill generates production-ready MCP servers from API descriptions (OpenAPI/Swagger), custom tool specs, or database schemas.
What gets generated:
- MCP server implementation (TypeScript or Python)
- Tool definitions with JSON schemas
- Error handling and validation
- Authentication/authorization logic
- Testing utilities
- Docker deployment config
Not for: Building APIs themselves - this assumes you have an API and want to expose it via MCP.
How to Use
Quick Start
- Parse API description:
python scripts/openapi_parser.py api-spec.yaml --output parsed.json - Generate MCP server:
python scripts/mcp_generator.py parsed.json \ --language typescript \ --output mcp-server/ - Test the server:
python scripts/server_tester.py mcp-server/ --test-all
Python Tools
scripts/openapi_parser.py— Parse OpenAPI/Swagger specs and extract tool definitionsscripts/mcp_generator.py— Generate MCP server code (TypeScript or Python)scripts/server_tester.py— Test MCP server tools and validate responses
Reference Docs
references/mcp-protocol-guide.md— MCP protocol overview and conceptsreferences/tool-design-patterns.md— Best practices for MCP tool design
Templates & Assets
assets/openapi-example.yaml— Sample OpenAPI specassets/tool-definition-template.json— Manual tool definition formatassets/docker-compose.yaml— Deployment configuration
Architecture Decisions
Why OpenAPI as Input
OpenAPI specs already describe:
- Endpoints and methods
- Request/response schemas
- Authentication requirements
- Error responses
Conversion: OpenAPI endpoint → MCP tool
# OpenAPI
/users/{id}:
get:
summary: Get user by ID
parameters:
- name: id
in: path
required: true
schema:
type: string→ MCP Tool:
{
name: "get_user",
description: "Get user by ID",
inputSchema: {
type: "object",
properties: {
id: { type: "string" }
},
required: ["id"]
}
}Tool Naming Convention
OpenAPI: GET /api/v1/users/{id}/profile
MCP Tool: get_user_profile
Rules:
- Method + path segments
- Snake_case
- Remove version prefixes
- Parameterized paths become tool inputs
Error Handling Strategy
MCP servers should return structured errors:
{
error: {
code: -32603, // JSON-RPC error code
message: "API error",
data: {
status: 404,
body: "User not found"
}
}
}Categories:
-32700Parse error (malformed request)-32600Invalid request (missing required params)-32601Method not found (unknown tool)-32603Internal error (API failure, network error)
Authentication Patterns
Pattern 1: API Key (most common)
const apiKey = process.env.API_KEY;
headers['Authorization'] = `Bearer ${apiKey}`;Pattern 2: OAuth 2.0
const token = await refreshToken();
headers['Authorization'] = `Bearer ${token}`;Pattern 3: Custom Auth
headers['X-Custom-Auth'] = computeSignature(request);Best practice: Store credentials in environment variables, never hardcode.
Rate Limiting
MCP servers should handle rate limits gracefully:
async function callWithRetry(fn, maxRetries = 3) {
for (let i = 0; i < maxRetries; i++) {
try {
return await fn();
} catch (err) {
if (err.status === 429) {
const delay = Math.pow(2, i) * 1000; // Exponential backoff
await sleep(delay);
continue;
}
throw err;
}
}
}Generated MCP Server Structure
TypeScript Server
mcp-server/
├── src/
│ ├── index.ts # Server entry point
│ ├── tools/ # Tool implementations
│ │ ├── get_user.ts
│ │ ├── create_user.ts
│ │ └── ...
│ ├── client.ts # API client wrapper
│ ├── types.ts # TypeScript types
│ └── validation.ts # Input validation
├── tests/
│ ├── tools.test.ts # Tool tests
│ └── integration.test.ts
├── package.json
├── tsconfig.json
├── .env.example
└── README.mdPython Server
mcp-server/
├── src/
│ ├── __init__.py
│ ├── server.py # Server entry point
│ ├── tools/ # Tool implementations
│ │ ├── get_user.py
│ │ ├── create_user.py
│ │ └── ...
│ ├── client.py # API client wrapper
│ └── validation.py # Input validation
├── tests/
│ ├── test_tools.py
│ └── test_integration.py
├── requirements.txt
├── .env.example
└── README.mdPython Tool Details
1. OpenAPI Parser
Purpose: Parse OpenAPI/Swagger specs and extract MCP tool definitions.
Usage:
python scripts/openapi_parser.py api-spec.yaml --output parsed.jsonOutput:
{
"info": {
"title": "User API",
"version": "1.0.0",
"baseUrl": "https://api.example.com"
},
"auth": {
"type": "bearer",
"headerName": "Authorization"
},
"tools": [
{
"name": "get_user",
"description": "Get user by ID",
"method": "GET",
"path": "/users/{id}",
"parameters": {
"path": ["id"],
"query": [],
"body": null
},
"inputSchema": { ... },
"responseSchema": { ... }
}
]
}2. MCP Generator
Purpose: Generate MCP server code from parsed API spec.
Usage:
python scripts/mcp_generator.py parsed.json \
--language typescript \
--output mcp-server/ \
--with-dockerOptions:
--language- typescript or python (default: typescript)--output- Output directory--with-docker- Generate Dockerfile and docker-compose.yaml--auth-env-var- Name of env var for auth (default: API_KEY)
Generates:
- Server entry point
- Tool implementations (one file per tool)
- API client wrapper
- Type definitions
- Tests
- Deployment config
3. Server Tester
Purpose: Test MCP server tools and validate responses.
Usage:
python scripts/server_tester.py mcp-server/ \
--test-all \
--mock-api \
--output test-report.jsonTests:
- Tool schema validation
- Input validation (required fields, types)
- Error handling (missing params, invalid types)
- Response schema validation
- End-to-end with mock API
Output:
{
"summary": {
"total_tools": 5,
"passed": 4,
"failed": 1
},
"results": [
{
"tool": "get_user",
"tests": {
"schema_valid": true,
"input_validation": true,
"response_validation": true,
"error_handling": false
},
"errors": ["Missing 404 error handling"]
}
]
}Workflow Example
Scenario: Create MCP server for GitHub API
Step 1: Get OpenAPI spec
# GitHub publishes OpenAPI specs
curl -o github-api.yaml https://github.com/github/rest-api-description/releases/latest/download/api.github.com.yamlStep 2: Parse spec
python scripts/openapi_parser.py github-api.yaml \
--filter "repos,issues" \
--output github-parsed.jsonOutput: 50 tools extracted (filtered to repos and issues endpoints)
Step 3: Generate MCP server
python scripts/mcp_generator.py github-parsed.json \
--language typescript \
--output github-mcp-server/ \
--auth-env-var GITHUB_TOKENOutput: TypeScript MCP server with 50 tools
Step 4: Configure authentication
cd github-mcp-server/
cp .env.example .env
echo "GITHUB_TOKEN=ghp_your_token_here" >> .envStep 5: Test tools
python scripts/server_tester.py github-mcp-server/ \
--test-all \
--output test-report.jsonOutput: 48/50 tools passing (2 require org access)
Step 6: Deploy
cd github-mcp-server/
npm install
npm run build
npm startStep 7: Connect to Claude Desktop
Add to claude_desktop_config.json:
{
"mcpServers": {
"github": {
"command": "node",
"args": ["/path/to/github-mcp-server/dist/index.js"],
"env": {
"GITHUB_TOKEN": "ghp_your_token_here"
}
}
}
}Now Claude can call GitHub tools: "Create an issue in my repo", "List my repositories", etc.
Common Patterns
Pattern 1: Pagination Handling
Many APIs return paginated results. MCP tools should handle this:
async function listUsers(params: { limit?: number, cursor?: string }) {
const response = await api.get('/users', {
params: {
limit: params.limit || 100,
cursor: params.cursor
}
});
return {
users: response.data,
nextCursor: response.nextCursor,
hasMore: !!response.nextCursor
};
}MCP Tool:
{
"name": "list_users",
"inputSchema": {
"type": "object",
"properties": {
"limit": { "type": "number", "default": 100 },
"cursor": { "type": "string" }
}
}
}Pattern 2: Batch Operations
For efficiency, support batch operations:
async function batchGetUsers(params: { ids: string[] }) {
// Split into chunks of 50 (API limit)
const chunks = chunkArray(params.ids, 50);
const results = [];
for (const chunk of chunks) {
const response = await api.post('/users/batch', { ids: chunk });
results.push(...response.data);
}
return results;
}Pattern 3: Webhook Integration
Some MCP servers can register webhooks:
async function registerWebhook(params: { event: string, url: string }) {
return await api.post('/webhooks', {
event: params.event,
url: params.url,
secret: process.env.WEBHOOK_SECRET
});
}Pattern 4: Caching
Cache frequently accessed data:
const cache = new Map();
async function getUser(params: { id: string }) {
const cacheKey = `user:${params.id}`;
if (cache.has(cacheKey)) {
return cache.get(cacheKey);
}
const user = await api.get(`/users/${params.id}`);
cache.set(cacheKey, user, { ttl: 300 }); // 5 min TTL
return user;
}Tool Design Best Practices
1. Clear Descriptions
Bad:
{
"name": "get_data",
"description": "Gets data"
}Good:
{
"name": "get_user_profile",
"description": "Retrieves detailed user profile including name, email, created date, and account settings. Requires user ID."
}2. Explicit Input Schemas
Always specify required fields and types:
{
"inputSchema": {
"type": "object",
"properties": {
"userId": {
"type": "string",
"description": "Unique user identifier"
},
"includeSettings": {
"type": "boolean",
"description": "Whether to include account settings",
"default": false
}
},
"required": ["userId"]
}
}3. Structured Errors
Return actionable error messages:
if (!params.userId) {
throw {
code: -32600,
message: "Missing required parameter: userId",
data: {
parameter: "userId",
type: "string",
description: "Unique user identifier"
}
};
}4. Response Normalization
Normalize API responses to consistent structure:
async function getUser(params) {
try {
const response = await api.get(`/users/${params.id}`);
return {
success: true,
data: response.data,
metadata: {
requestId: response.headers['x-request-id'],
rateLimit: {
remaining: response.headers['x-ratelimit-remaining'],
reset: response.headers['x-ratelimit-reset']
}
}
};
} catch (err) {
return {
success: false,
error: {
message: err.message,
status: err.status,
code: err.code
}
};
}
}Quality Checklist
Before deploying MCP server:
- All tools have clear descriptions
- Input schemas specify required fields
- Authentication configured via env vars
- Error handling for all API failures
- Rate limiting with exponential backoff
- Tests cover all tools
- Response schemas validated
- Logging enabled for debugging
- Docker deployment ready
- README with setup instructions
When to Use vs. Direct API Calls
| Use MCP Server | Use Direct API |
| AI assistant integration | Simple scripts |
| Multiple tools from one API | One-off requests |
| Reusable across projects | Project-specific code |
| Need structured error handling | Quick prototypes |
| Authentication abstraction needed | Full control required |
Deployment Options
Option 1: Local (Development)
npm start
# Runs on localhost, accessible to Claude DesktopOption 2: Docker (Production)
docker-compose up -d
# Containerized, easy to deployOption 3: Cloud (Serverless)
// Deploy to AWS Lambda, Vercel, etc.
export const handler = mcpServer.handler;Monitoring
Track MCP server health:
const metrics = {
totalRequests: 0,
successfulRequests: 0,
failedRequests: 0,
averageLatency: 0
};
function recordMetrics(tool: string, success: boolean, latency: number) {
metrics.totalRequests++;
if (success) metrics.successfulRequests++;
else metrics.failedRequests++;
// Update average latency
metrics.averageLatency =
(metrics.averageLatency * (metrics.totalRequests - 1) + latency) / metrics.totalRequests;
console.log(`[${tool}] ${success ? 'OK' : 'FAIL'} ${latency}ms`);
}References
- MCP Protocol Spec:
references/mcp-protocol-guide.md - Tool Design Patterns:
references/tool-design-patterns.md - MCP TypeScript SDK: https://github.com/modelcontextprotocol/typescript-sdk
- MCP Python SDK: https://github.com/modelcontextprotocol/python-sdk
- OpenAPI Specification: https://swagger.io/specification/
Credits
Michael Lynn — mlynn.org · @mlynn · LinkedIn · GitHub
Next steps after generating server:
- Test tools with mock API
- Configure authentication
- Deploy and connect to Claude Desktop
- Monitor usage and errors
- Iterate on tool descriptions based on usage
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

