@mr-aftab-ahmad-khan/create-mcp-server 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md ADDED
@@ -0,0 +1,9 @@
1
+ # Changelog
2
+
3
+ ## [0.1.0] — 2026-05-15
4
+
5
+ ### Added
6
+
7
+ - Interactive scaffolder with `blank`, `postgres`, `stripe`, `rest`, and `filesystem` templates.
8
+ - stdio and SSE transports, optional API-key auth middleware.
9
+ - Emits `package.json`, `tsconfig.json`, `README.md`, `.env.example`, and a Claude Desktop config snippet.
package/LICENSE ADDED
@@ -0,0 +1,15 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 create-mcp-server contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND.
package/README.md ADDED
@@ -0,0 +1,329 @@
1
+ # create-mcp-server
2
+
3
+ [![npm version](https://img.shields.io/npm/v/%40mr-aftab-ahmad-khan%2Fcreate-mcp-server.svg)](https://www.npmjs.com/package/@mr-aftab-ahmad-khan/create-mcp-server)
4
+ [![license](https://img.shields.io/npm/l/%40mr-aftab-ahmad-khan%2Fcreate-mcp-server.svg)](./LICENSE)
5
+ [![TypeScript](https://img.shields.io/badge/types-TypeScript-blue.svg)](https://www.typescriptlang.org/)
6
+
7
+ **MCP is the new standard for AI tool use.** Claude, ChatGPT, Cursor, and Windsurf all support it. Most developers don't know how to ship an MCP server. This scaffolder fixes that in 30 seconds:
8
+
9
+ ```bash
10
+ npx @mr-aftab-ahmad-khan/create-mcp-server my-server
11
+ ```
12
+
13
+ Pick a template — **Postgres**, **Stripe**, **REST API wrapper**, **File System**, or **Blank** — and you get a working server with proper `tools/list` / `tools/call` handlers, env config, a ready-to-paste Claude Desktop config snippet, and (optionally) an API-key auth middleware.
14
+
15
+ ---
16
+
17
+ ## Installation
18
+
19
+ ```bash
20
+ # Use directly, no global install needed:
21
+ npx @mr-aftab-ahmad-khan/create-mcp-server my-server
22
+
23
+ # Or install once:
24
+ npm install -g @mr-aftab-ahmad-khan/create-mcp-server
25
+ create-mcp-server my-server
26
+ ```
27
+
28
+ ---
29
+
30
+ ## Quick Start
31
+
32
+ ```bash
33
+ npx @mr-aftab-ahmad-khan/create-mcp-server my-pg
34
+ # ? Template: postgres
35
+ cd my-pg
36
+ echo "DATABASE_URL=postgres://localhost/db" > .env
37
+ npm install
38
+ npm run build
39
+ npm start
40
+ # postgres-mcp: connected
41
+ ```
42
+
43
+ Add to Claude Desktop:
44
+
45
+ ```json
46
+ {
47
+ "mcpServers": {
48
+ "my-pg": {
49
+ "command": "node",
50
+ "args": ["/abs/path/to/my-pg/dist/index.js"],
51
+ "env": { "DATABASE_URL": "postgres://localhost/db" }
52
+ }
53
+ }
54
+ }
55
+ ```
56
+
57
+ ---
58
+
59
+ ## Core Usage Examples
60
+
61
+ ### 1. Postgres + Claude Desktop
62
+
63
+ ```bash
64
+ npx @mr-aftab-ahmad-khan/create-mcp-server pg-mcp --template postgres
65
+ cd pg-mcp && npm install && npm run build
66
+ # Add the snippet above to ~/Library/Application Support/Claude/claude_desktop_config.json
67
+ ```
68
+
69
+ ### 2. Stripe + MCP inspector
70
+
71
+ ```bash
72
+ npx @mr-aftab-ahmad-khan/create-mcp-server stripe-mcp --template stripe
73
+ echo "STRIPE_SECRET_KEY=sk_test_..." > stripe-mcp/.env
74
+ cd stripe-mcp && npm install && npm run build
75
+ npx @modelcontextprotocol/inspector node dist/index.js
76
+ ```
77
+
78
+ ### 3. Adding a custom tool to the Blank template
79
+
80
+ ```ts
81
+ TOOLS.push({
82
+ name: "uppercase",
83
+ description: "Uppercase a string",
84
+ inputSchema: { type: "object", properties: { text: { type: "string" } }, required: ["text"] },
85
+ });
86
+
87
+ server.setRequestHandler(CallToolRequestSchema, async (request) => {
88
+ if (request.params.name === "uppercase") {
89
+ const args = z.object({ text: z.string() }).parse(request.params.arguments);
90
+ return { content: [{ type: "text", text: args.text.toUpperCase() }] };
91
+ }
92
+ // ... fall through to existing handlers
93
+ });
94
+ ```
95
+
96
+ ### 4. Adding a Resource
97
+
98
+ ```ts
99
+ import { ListResourcesRequestSchema, ReadResourceRequestSchema } from "@modelcontextprotocol/sdk/types.js";
100
+
101
+ server.setRequestHandler(ListResourcesRequestSchema, async () => ({
102
+ resources: [{ uri: "config://app", name: "App config", mimeType: "application/json" }],
103
+ }));
104
+
105
+ server.setRequestHandler(ReadResourceRequestSchema, async (req) => ({
106
+ contents: [{ uri: req.params.uri, mimeType: "application/json", text: '{"hello":"world"}' }],
107
+ }));
108
+ ```
109
+
110
+ ### 5. SSE transport
111
+
112
+ ```bash
113
+ npx @mr-aftab-ahmad-khan/create-mcp-server my-sse --template blank --transport sse
114
+ ```
115
+
116
+ ### 6. REST wrapper with OpenAPI
117
+
118
+ ```bash
119
+ npx @mr-aftab-ahmad-khan/create-mcp-server my-rest --template rest
120
+ cp my-api.openapi.json my-rest/openapi.json
121
+ cd my-rest && npm install && npm run build && npm start
122
+ ```
123
+
124
+ ---
125
+
126
+ ## Template Reference
127
+
128
+ ### `postgres`
129
+
130
+ - **Tools**: `query`, `list_tables`, `describe_table`, `insert`, `update`
131
+ - **Env**: `DATABASE_URL`
132
+ - **Files**: `src/index.ts`, `package.json` (with `pg`), `.env.example`, `tsconfig.json`, `README.md`
133
+ - **Claude Desktop snippet**: included in generated README
134
+
135
+ ### `stripe`
136
+
137
+ - **Tools**: `list_customers`, `get_customer`, `list_invoices`, `create_payment_link`, `get_balance`
138
+ - **Env**: `STRIPE_SECRET_KEY`
139
+
140
+ ### `rest`
141
+
142
+ - **Tools**: auto-generated from your `openapi.json`
143
+ - **Env**: `OPENAPI_SPEC_PATH`, `API_BASE_URL`, `API_BEARER_TOKEN`, `API_KEY_HEADER`, `API_KEY`
144
+
145
+ ### `filesystem`
146
+
147
+ - **Tools**: `read_file`, `write_file`, `list_directory`, `search_files`, `get_file_info`
148
+ - **Env**: `SANDBOX_ROOT` (server refuses to read/write outside)
149
+
150
+ ### `blank`
151
+
152
+ - One `echo` tool. Inline comments explaining each MCP concept.
153
+
154
+ ---
155
+
156
+ ## MCP Concepts Explained
157
+
158
+ - **Tools** — actions the client (e.g. Claude) can call. Declared via `tools/list`, executed via `tools/call`. Inputs are JSON Schema; outputs are `{ content: [{ type: "text", text }] }`.
159
+ - **Resources** — read-only data the client can fetch by URI. Declared via `resources/list`, fetched via `resources/read`.
160
+ - **Prompts** — pre-canned prompts the client can offer to the user.
161
+ - **stdio transport** — the server is a local subprocess; messages are JSON-RPC over stdin/stdout.
162
+ - **SSE transport** — the server is a remote HTTP service; messages stream over Server-Sent Events.
163
+
164
+ Claude Desktop discovers servers via its config file at `~/Library/Application Support/Claude/claude_desktop_config.json` (macOS) or `%APPDATA%\Claude\claude_desktop_config.json` (Windows).
165
+
166
+ ---
167
+
168
+ ## Adding Custom Tools
169
+
170
+ ```ts
171
+ import { CallToolRequestSchema, ListToolsRequestSchema, type Tool } from "@modelcontextprotocol/sdk/types.js";
172
+ import { z } from "zod";
173
+
174
+ const TOOLS: Tool[] = [{
175
+ name: "run_report",
176
+ description: "Run the weekly KPI report",
177
+ inputSchema: {
178
+ type: "object",
179
+ properties: { quarter: { type: "string", pattern: "^Q[1-4]-\\d{4}$" } },
180
+ required: ["quarter"],
181
+ },
182
+ }];
183
+
184
+ server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: TOOLS }));
185
+
186
+ server.setRequestHandler(CallToolRequestSchema, async (request) => {
187
+ if (request.params.name === "run_report") {
188
+ const args = z.object({ quarter: z.string() }).parse(request.params.arguments);
189
+ const rows = await db.query("SELECT * FROM kpi WHERE quarter = $1", [args.quarter]);
190
+ return { content: [{ type: "text", text: JSON.stringify(rows, null, 2) }] };
191
+ }
192
+ return { content: [{ type: "text", text: "Unknown tool" }], isError: true };
193
+ });
194
+ ```
195
+
196
+ ---
197
+
198
+ ## TypeScript Types
199
+
200
+ ```ts
201
+ import type { Tool, Resource, CallToolRequest, ListToolsResponse } from "@modelcontextprotocol/sdk/types.js";
202
+
203
+ const myTool: Tool = {
204
+ name: "do_thing",
205
+ description: "Does the thing",
206
+ inputSchema: { type: "object", properties: { x: { type: "number" } }, required: ["x"] },
207
+ };
208
+
209
+ async function handle(req: CallToolRequest): Promise<{ content: { type: "text"; text: string }[] }> {
210
+ return { content: [{ type: "text", text: "ok" }] };
211
+ }
212
+ ```
213
+
214
+ ---
215
+
216
+ ## CLI Reference
217
+
218
+ ```
219
+ create-mcp-server [name] [options]
220
+
221
+ Options:
222
+ --template <name> blank | postgres | stripe | rest | filesystem
223
+ --transport <t> stdio | sse (default: stdio)
224
+ --language <lang> typescript | javascript (default: typescript)
225
+ --auth Include an x-api-key auth middleware
226
+ -y, --yes Skip prompts (use defaults / flags only)
227
+ ```
228
+
229
+ Non-interactive:
230
+
231
+ ```bash
232
+ npx @mr-aftab-ahmad-khan/create-mcp-server my-pg --template postgres --transport stdio --language typescript --auth --yes
233
+ ```
234
+
235
+ ---
236
+
237
+ ## Real-World Recipe — Production Postgres MCP Server
238
+
239
+ ```bash
240
+ # 1. Scaffold
241
+ npx @mr-aftab-ahmad-khan/create-mcp-server kpi-mcp --template postgres --auth --yes
242
+ cd kpi-mcp
243
+ ```
244
+
245
+ ```ts
246
+ // 2. Add a safe custom tool
247
+ TOOLS.push({
248
+ name: "run_report",
249
+ description: "Run a parameterized KPI report",
250
+ inputSchema: {
251
+ type: "object",
252
+ properties: { quarter: { type: "string" } },
253
+ required: ["quarter"],
254
+ },
255
+ });
256
+ ```
257
+
258
+ ```bash
259
+ # 3. Configure
260
+ echo "DATABASE_URL=postgres://app:secret@db.internal:5432/kpi" > .env
261
+ echo "MCP_API_KEY=$(openssl rand -hex 32)" >> .env
262
+
263
+ # 4. Build and start under PM2
264
+ npm install && npm run build
265
+ pm2 start dist/index.js --name kpi-mcp
266
+ ```
267
+
268
+ ```json
269
+ // 5. Claude Desktop config (remote SSE example)
270
+ {
271
+ "mcpServers": {
272
+ "kpi-mcp": {
273
+ "command": "node",
274
+ "args": ["/srv/kpi-mcp/dist/index.js"],
275
+ "env": { "DATABASE_URL": "postgres://...", "MCP_API_KEY": "..." }
276
+ }
277
+ }
278
+ }
279
+ ```
280
+
281
+ Claude can now ask: _"Run the Q1-2026 KPI report and summarise the trends."_
282
+
283
+ ---
284
+
285
+ ## Connecting to Different AI Clients
286
+
287
+ ### Claude Desktop
288
+
289
+ ```json
290
+ { "mcpServers": { "x": { "command": "node", "args": ["/abs/path/dist/index.js"] } } }
291
+ ```
292
+
293
+ ### Cursor
294
+
295
+ `~/.cursor/mcp.json`:
296
+
297
+ ```json
298
+ { "mcpServers": { "x": { "command": "node", "args": ["/abs/path/dist/index.js"] } } }
299
+ ```
300
+
301
+ ### Windsurf
302
+
303
+ Same shape under `~/.codeium/windsurf/mcp_config.json`.
304
+
305
+ ### Any MCP-compatible client (SSE)
306
+
307
+ ```json
308
+ { "mcpServers": { "x": { "url": "https://mcp.example.com/sse", "headers": { "x-api-key": "..." } } } }
309
+ ```
310
+
311
+ ---
312
+
313
+ ## Comparison Table
314
+
315
+ | Feature | Manual MCP setup | mcp-framework | **create-mcp-server** |
316
+ | --------------------- | :--------------: | :-----------: | :-------------------: |
317
+ | Templates | ❌ | ⚠️ | ✅ |
318
+ | stdio + SSE | DIY | ✅ | ✅ |
319
+ | TypeScript | DIY | ✅ | ✅ |
320
+ | Claude Desktop snippet| ❌ | ❌ | ✅ |
321
+ | OpenAPI wrapper | ❌ | ❌ | ✅ |
322
+ | Auth middleware | DIY | ❌ | ✅ |
323
+ | Tests included | ❌ | ❌ | ✅ |
324
+
325
+ ---
326
+
327
+ ## License
328
+
329
+ MIT