All Integrations/Backend Framework

Convert @nestjs/swagger OpenAPI JSON to MCP

NestJS apps using @nestjs/swagger already emit rock-solid OpenAPI 3.0 schemas with DTO classes and decorators. Compile /api-json directly into an MCP server.

NestJS JwtAuthGuard (Bearer) or ApiKeyGuard headerRecommended: TypeScript SDK + Zod
Presets:
Context Footprint~958 tok
Lean context footprintOpenAPI 3.0.3

MCP Tool Selection

10 / 10 Free

12 endpoints parsed • 1 safety-guarded

12 endpoints detected — Free tier compiles up to 10

Unlock unlimited endpoints, hosted Remote MCP URL, OAuth2 proxy & GitHub CI auto-sync with Pro Cloud.

GET/tasks~126t

List workspace tasks with status & assignee filters

tool:
readOnly3 params
POST/tasks~130t

Create a new engineering or CRM task

tool:
4 params
GET/tasks/{task_id}~67t

Get task details and subtasks

tool:
readOnly1 param
PATCH/tasks/{task_id}~135t

Update task status, priority, or assignee

tool:
4 params
DELETE/tasks/{task_id}~70t

Permanently delete a task

tool:
1 param
GET/projects~72t

List active workspace projects

tool:
readOnly1 param
POST/projects~86t

Create a new project milestone

tool:
2 params
GET/contacts~100t

Search CRM contacts by email or company

tool:
readOnly2 params
POST/contacts~103t

Add a new CRM contact

tool:
3 params
GET/deals~69t

List pipeline deals and ARR values

tool:
readOnly1 param
POST/deals/{deal_id}/notes~92t

Attach a call summary or note to a deal

tool:
2 params
DELETE/contacts/{contact_id}~75t

GDPR purge a CRM contact record

tool:
1 param
src/index.ts370 lines
1#!/usr/bin/env node
2/**
3 * Generated by Spec2MCP (https://spec2mcp.com)
4 * Server: workspace-crm-tasks-api v2.1.0
5 * Tools exposed: 10
6 */
7import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
8import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
9import { z } from "zod";
10
11const BASE_URL = (process.env.WORKSPACE_CRM_TASKS_API_BASE_URL ?? "https://api.workspace-crm.example.com/v2").replace(/\/+$/, "");
12const API_KEY = process.env.WORKSPACE_CRM_TASKS_API_API_KEY ?? "";
13function buildAuthHeaders(): Record<string, string> {
14 return API_KEY ? { "X-Workspace-Key": API_KEY } : {};
15}
16
17interface UpstreamRequest {
18 method: string;
19 path: string;
20 query?: URLSearchParams;
21 body?: Record<string, unknown>;
22}
23
24async function callUpstream(req: UpstreamRequest) {
25 const qs = req.query && req.query.toString() ? `?${req.query.toString()}` : "";
26 const url = `${BASE_URL}${req.path}${qs}`;
27
28 const headers: Record<string, string> = {
29 Accept: "application/json",
30 "User-Agent": "spec2mcp/workspace-crm-tasks-api",
31 ...buildAuthHeaders(),
32 };
33
34 if (req.body !== undefined) {
35 headers["Content-Type"] = "application/json";
36 }
37
38 try {
39 const controller = new AbortController();
40 const timer = setTimeout(() => controller.abort(), 20_000);
41 const response = await fetch(url, {
42 method: req.method,
43 headers,
44 body: req.body !== undefined ? JSON.stringify(req.body) : undefined,
45 signal: controller.signal,
46 });
47 clearTimeout(timer);
48
49 const rawText = await response.text();
50 let formatted = rawText;
51 try {
52 formatted = JSON.stringify(JSON.parse(rawText), null, 2);
53 } catch {
54 // keep raw text if upstream returned non-JSON
55 }
56
57 if (!response.ok) {
58 return {
59 isError: true,
60 content: [
61 {
62 type: "text" as const,
63 text: `HTTP ${response.status} ${response.statusText} from ${req.method} ${req.path}\n${formatted}`,
64 },
65 ],
66 };
67 }
68
69 return {
70 content: [
71 {
72 type: "text" as const,
73 text: formatted || `HTTP ${response.status} (empty body)`,
74 },
75 ],
76 };
77 } catch (err) {
78 const message = err instanceof Error ? err.message : String(err);
79 return {
80 isError: true,
81 content: [
82 {
83 type: "text" as const,
84 text: `Network error calling ${req.method} ${url}: ${message}`,
85 },
86 ],
87 };
88 }
89}
90
91const server = new McpServer({
92 name: "workspace-crm-tasks-api",
93 version: "2.1.0",
94});
95
96server.tool(
97 "list_tasks",
98 "List workspace tasks with status & assignee filters [GET /tasks]",
99 {
100 "status": z.enum(["backlog", "in_progress", "done", "canceled"]).describe("Task workflow state").optional(),
101 "assignee_id": z.string().describe("Filter by team member ID").optional(),
102 "limit": z.number().int().describe("Page size (default 25)").optional(),
103 },
104 {
105 title: "List workspace tasks with status & assignee filters",
106 readOnlyHint: true,
107 destructiveHint: false,
108 idempotentHint: true,
109 openWorldHint: true,
110 },
111 async (args) => {
112 const query = new URLSearchParams();
113 if (args["status"] !== undefined) query.set("status", String(args["status"]));
114 if (args["assignee_id"] !== undefined) query.set("assignee_id", String(args["assignee_id"]));
115 if (args["limit"] !== undefined) query.set("limit", String(args["limit"]));
116 return callUpstream({
117 method: "GET",
118 path: "/tasks",
119 query,
120 });
121 }
122);
123
124server.tool(
125 "create_task",
126 "Create a new engineering or CRM task [POST /tasks]",
127 {
128 "title": z.string().describe("Short task title"),
129 "project_id": z.string().describe("Parent project ID"),
130 "priority": z.number().int().describe("Priority 1 (urgent) to 4 (low)").optional(),
131 "due_date": z.string().describe("ISO-8601 due date").optional(),
132 },
133 {
134 title: "Create a new engineering or CRM task",
135 readOnlyHint: false,
136 destructiveHint: false,
137 idempotentHint: false,
138 openWorldHint: true,
139 },
140 async (args) => {
141 const bodyPayload: Record<string, unknown> = {};
142 if (args["title"] !== undefined) bodyPayload["title"] = args["title"];
143 if (args["project_id"] !== undefined) bodyPayload["project_id"] = args["project_id"];
144 if (args["priority"] !== undefined) bodyPayload["priority"] = args["priority"];
145 if (args["due_date"] !== undefined) bodyPayload["due_date"] = args["due_date"];
146 return callUpstream({
147 method: "POST",
148 path: "/tasks",
149 body: bodyPayload,
150 });
151 }
152);
153
154server.tool(
155 "get_task",
156 "Get task details and subtasks [GET /tasks/{task_id}]",
157 {
158 "task_id": z.string().describe("Task ID"),
159 },
160 {
161 title: "Get task details and subtasks",
162 readOnlyHint: true,
163 destructiveHint: false,
164 idempotentHint: true,
165 openWorldHint: true,
166 },
167 async (args) => {
168 return callUpstream({
169 method: "GET",
170 path: `/tasks/${encodeURIComponent(String(args["task_id"]))}`,
171 });
172 }
173);
174
175server.tool(
176 "update_task",
177 "Update task status, priority, or assignee [PATCH /tasks/{task_id}]",
178 {
179 "task_id": z.string().describe("Task ID"),
180 "status": z.enum(["backlog", "in_progress", "done", "canceled"]).describe("New task status").optional(),
181 "priority": z.number().int().describe("Priority 1-4").optional(),
182 "assignee_id": z.string().describe("Assigned member ID").optional(),
183 },
184 {
185 title: "Update task status, priority, or assignee",
186 readOnlyHint: false,
187 destructiveHint: false,
188 idempotentHint: false,
189 openWorldHint: true,
190 },
191 async (args) => {
192 const bodyPayload: Record<string, unknown> = {};
193 if (args["status"] !== undefined) bodyPayload["status"] = args["status"];
194 if (args["priority"] !== undefined) bodyPayload["priority"] = args["priority"];
195 if (args["assignee_id"] !== undefined) bodyPayload["assignee_id"] = args["assignee_id"];
196 return callUpstream({
197 method: "PATCH",
198 path: `/tasks/${encodeURIComponent(String(args["task_id"]))}`,
199 body: bodyPayload,
200 });
201 }
202);
203
204server.tool(
205 "delete_task",
206 "Permanently delete a task [DELETE /tasks/{task_id}]",
207 {
208 "task_id": z.string().describe("Task ID to delete"),
209 confirm_destructive_action: z.boolean().describe("Safety guard: must be explicitly set to true to execute this DELETE operation."),
210 },
211 {
212 title: "Permanently delete a task",
213 readOnlyHint: false,
214 destructiveHint: true,
215 idempotentHint: false,
216 openWorldHint: true,
217 },
218 async (args) => {
219 if (!args.confirm_destructive_action) {
220 return {
221 isError: true,
222 content: [{ type: "text", text: "Blocked by safety guard: set confirm_destructive_action=true after user confirmation." }],
223 };
224 }
225 return callUpstream({
226 method: "DELETE",
227 path: `/tasks/${encodeURIComponent(String(args["task_id"]))}`,
228 });
229 }
230);
231
232server.tool(
233 "list_projects",
234 "List active workspace projects [GET /projects]",
235 {
236 "archived": z.boolean().describe("Include archived projects").optional(),
237 },
238 {
239 title: "List active workspace projects",
240 readOnlyHint: true,
241 destructiveHint: false,
242 idempotentHint: true,
243 openWorldHint: true,
244 },
245 async (args) => {
246 const query = new URLSearchParams();
247 if (args["archived"] !== undefined) query.set("archived", String(args["archived"]));
248 return callUpstream({
249 method: "GET",
250 path: "/projects",
251 query,
252 });
253 }
254);
255
256server.tool(
257 "create_project",
258 "Create a new project milestone [POST /projects]",
259 {
260 "name": z.string().describe("Project name"),
261 "lead_id": z.string().describe("Project lead user ID").optional(),
262 },
263 {
264 title: "Create a new project milestone",
265 readOnlyHint: false,
266 destructiveHint: false,
267 idempotentHint: false,
268 openWorldHint: true,
269 },
270 async (args) => {
271 const bodyPayload: Record<string, unknown> = {};
272 if (args["name"] !== undefined) bodyPayload["name"] = args["name"];
273 if (args["lead_id"] !== undefined) bodyPayload["lead_id"] = args["lead_id"];
274 return callUpstream({
275 method: "POST",
276 path: "/projects",
277 body: bodyPayload,
278 });
279 }
280);
281
282server.tool(
283 "search_crm_contacts",
284 "Search CRM contacts by email or company [GET /contacts]",
285 {
286 "q": z.string().describe("Search keyword").optional(),
287 "stage": z.enum(["lead", "qualified", "customer", "churned"]).describe("Lifecycle stage").optional(),
288 },
289 {
290 title: "Search CRM contacts by email or company",
291 readOnlyHint: true,
292 destructiveHint: false,
293 idempotentHint: true,
294 openWorldHint: true,
295 },
296 async (args) => {
297 const query = new URLSearchParams();
298 if (args["q"] !== undefined) query.set("q", String(args["q"]));
299 if (args["stage"] !== undefined) query.set("stage", String(args["stage"]));
300 return callUpstream({
301 method: "GET",
302 path: "/contacts",
303 query,
304 });
305 }
306);
307
308server.tool(
309 "create_crm_contact",
310 "Add a new CRM contact [POST /contacts]",
311 {
312 "email": z.string().describe("Contact work email"),
313 "full_name": z.string().describe("Full name"),
314 "company": z.string().describe("Company name").optional(),
315 },
316 {
317 title: "Add a new CRM contact",
318 readOnlyHint: false,
319 destructiveHint: false,
320 idempotentHint: false,
321 openWorldHint: true,
322 },
323 async (args) => {
324 const bodyPayload: Record<string, unknown> = {};
325 if (args["email"] !== undefined) bodyPayload["email"] = args["email"];
326 if (args["full_name"] !== undefined) bodyPayload["full_name"] = args["full_name"];
327 if (args["company"] !== undefined) bodyPayload["company"] = args["company"];
328 return callUpstream({
329 method: "POST",
330 path: "/contacts",
331 body: bodyPayload,
332 });
333 }
334);
335
336server.tool(
337 "list_deals",
338 "List pipeline deals and ARR values [GET /deals]",
339 {
340 "stage": z.string().describe("Pipeline stage slug").optional(),
341 },
342 {
343 title: "List pipeline deals and ARR values",
344 readOnlyHint: true,
345 destructiveHint: false,
346 idempotentHint: true,
347 openWorldHint: true,
348 },
349 async (args) => {
350 const query = new URLSearchParams();
351 if (args["stage"] !== undefined) query.set("stage", String(args["stage"]));
352 return callUpstream({
353 method: "GET",
354 path: "/deals",
355 query,
356 });
357 }
358);
359
360async function main() {
361 const transport = new StdioServerTransport();
362 await server.connect(transport);
363 console.error("workspace-crm-tasks-api MCP server listening on stdio (10 tools)");
364}
365
366main().catch((err) => {
367 console.error("Fatal MCP server error:", err);
368 process.exit(1);
369});
370
$ npm install && npm run build && WORKSPACE_CRM_TASKS_API_API_KEY=... node build/index.js
10 tools • ~958 tokens

How to export & compile your NestJS Swagger OpenAPI spec

Open http://localhost:3000/api-json (or your SwaggerModule jsonDocumentUrl), save it, and drop it into Spec2MCP.

$curl -s http://localhost:3000/api-json -o nest-openapi.json

High-Signal NestJS Swagger MCP Tools to Expose First

MethodEndpoint PathMCP Tool Name
GET/api/taskslist_tasks
POST/api/taskscreate_task
PATCH/api/tasks/{id}update_task

Best Practices for NestJS Swagger

  • NestJS controller method names become operationId (e.g., TasksController_findAll)—use Spec2MCP's inline tool-name editor to shorten them to crisp names like list_tasks.
  • Decorate DTO properties with @ApiProperty({ description: '...' }) so Zod descriptions give Claude clear guidance.
  • Group related NestJS controllers into domain-focused MCP servers rather than exposing your entire monolithic Swagger document.

Common NestJS Swagger MCP Gotchas

  • Default NestJS operationIds include the controller prefix (UsersController_create), which looks noisy to LLMs—rename them in the workbench before exporting.
  • Class-validator DTOs with @ApiBearerAuth() emit bearer securitySchemes that Spec2MCP detects automatically.
  • Watch for global route prefixes (app.setGlobalPrefix('api')) and make sure they are included either in paths or BASE_URL—not duplicated in both.

NestJS Swagger to MCP Server — Frequently Asked Questions

How do I export JSON from @nestjs/swagger?

When you call SwaggerModule.setup('api', app, document), NestJS automatically serves the raw OpenAPI JSON at /api-json.

Can Spec2MCP resolve NestJS DTO $ref schemas?

Yes. Spec2MCP recursively resolves #/components/schemas/CreateTaskDto references and expands all properties into Zod fields.

Can I add the generated MCP server into my NestJS monorepo?

Yes—drop src/index.ts and package.json into apps/mcp-server or packages/mcp and build it with TypeScript.

Related OpenAPI-to-MCP Converters

View all 20
Transparent Developer Pricing

Free locally forever. Upgrade when your team goes remote.

Compile focused local TypeScript & Python MCP servers in your browser for $0. Move to Pro Cloud or Team when you need unlimited endpoints, hosted Remote MCP URLs, OAuth2 proxying, and CI sync.

Free Local Studio
$0/ forever

Everything solo engineers need to turn REST APIs into local stdio MCP servers with zero login.

  • Local TypeScript SDK + Zod codegen
  • Local Python FastMCP + httpx codegen
  • Up to 10 endpoints per MCP server
  • Live context-window token estimator
  • Destructive action confirmation guards
  • Claude Desktop, Cursor, Windsurf & Antigravity mcp.json
  • 100% client-side — specs stay in browser
Use Free Studio Now
Most Popular
Pro Cloud
$29/ month

Compile unlimited endpoints and publish a hosted Remote MCP URL with encrypted credential vaulting.

  • Unlimited OpenAPI endpoints & tool grouping
  • 1-click hosted Remote MCP endpoint (Streamable HTTP)
  • Encrypted OAuth2 & API-Key secret vault
  • Custom tool presets & OpenAPI overlay persistence
  • Response payload truncation to stop context blowups
  • Priority email & Discord support
Team
$79/ month

Built for engineering orgs keeping internal MCP servers automatically synced with OpenAPI repos.

  • Everything in Pro Cloud
  • GitHub / GitLab CI auto-sync on OpenAPI PR merges
  • Per-tool invocation audit logs & latency metrics
  • Per-user rate limits & destructive-tool approval policies
  • Role-based access across engineering & ops teams
  • Dedicated onboarding & custom auth helpers