Convert Notion OpenAPI Endpoints to an MCP Server
Wire Claude Desktop, Cursor, or Antigravity to Notion databases and wiki pages with a tiny, transparent MCP server you control.
MCP Tool Selection
10 / 10 Free12 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.
List workspace tasks with status & assignee filters
Create a new engineering or CRM task
Get task details and subtasks
Update task status, priority, or assignee
Permanently delete a task
List active workspace projects
Create a new project milestone
Search CRM contacts by email or company
Add a new CRM contact
List pipeline deals and ARR values
Attach a call summary or note to a deal
GDPR purge a CRM contact record
1#!/usr/bin/env node2/**3* Generated by Spec2MCP (https://spec2mcp.com)4* Server: workspace-crm-tasks-api v2.1.05* Tools exposed: 106*/7import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";8import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";9import { z } from "zod";1011const 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> {14return API_KEY ? { "X-Workspace-Key": API_KEY } : {};15}1617interface UpstreamRequest {18method: string;19path: string;20query?: URLSearchParams;21body?: Record<string, unknown>;22}2324async function callUpstream(req: UpstreamRequest) {25const qs = req.query && req.query.toString() ? `?${req.query.toString()}` : "";26const url = `${BASE_URL}${req.path}${qs}`;2728const headers: Record<string, string> = {29Accept: "application/json",30"User-Agent": "spec2mcp/workspace-crm-tasks-api",31...buildAuthHeaders(),32};3334if (req.body !== undefined) {35headers["Content-Type"] = "application/json";36}3738try {39const controller = new AbortController();40const timer = setTimeout(() => controller.abort(), 20_000);41const response = await fetch(url, {42method: req.method,43headers,44body: req.body !== undefined ? JSON.stringify(req.body) : undefined,45signal: controller.signal,46});47clearTimeout(timer);4849const rawText = await response.text();50let formatted = rawText;51try {52formatted = JSON.stringify(JSON.parse(rawText), null, 2);53} catch {54// keep raw text if upstream returned non-JSON55}5657if (!response.ok) {58return {59isError: true,60content: [61{62type: "text" as const,63text: `HTTP ${response.status} ${response.statusText} from ${req.method} ${req.path}\n${formatted}`,64},65],66};67}6869return {70content: [71{72type: "text" as const,73text: formatted || `HTTP ${response.status} (empty body)`,74},75],76};77} catch (err) {78const message = err instanceof Error ? err.message : String(err);79return {80isError: true,81content: [82{83type: "text" as const,84text: `Network error calling ${req.method} ${url}: ${message}`,85},86],87};88}89}9091const server = new McpServer({92name: "workspace-crm-tasks-api",93version: "2.1.0",94});9596server.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{105title: "List workspace tasks with status & assignee filters",106readOnlyHint: true,107destructiveHint: false,108idempotentHint: true,109openWorldHint: true,110},111async (args) => {112const query = new URLSearchParams();113if (args["status"] !== undefined) query.set("status", String(args["status"]));114if (args["assignee_id"] !== undefined) query.set("assignee_id", String(args["assignee_id"]));115if (args["limit"] !== undefined) query.set("limit", String(args["limit"]));116return callUpstream({117method: "GET",118path: "/tasks",119query,120});121}122);123124server.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{134title: "Create a new engineering or CRM task",135readOnlyHint: false,136destructiveHint: false,137idempotentHint: false,138openWorldHint: true,139},140async (args) => {141const bodyPayload: Record<string, unknown> = {};142if (args["title"] !== undefined) bodyPayload["title"] = args["title"];143if (args["project_id"] !== undefined) bodyPayload["project_id"] = args["project_id"];144if (args["priority"] !== undefined) bodyPayload["priority"] = args["priority"];145if (args["due_date"] !== undefined) bodyPayload["due_date"] = args["due_date"];146return callUpstream({147method: "POST",148path: "/tasks",149body: bodyPayload,150});151}152);153154server.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{161title: "Get task details and subtasks",162readOnlyHint: true,163destructiveHint: false,164idempotentHint: true,165openWorldHint: true,166},167async (args) => {168return callUpstream({169method: "GET",170path: `/tasks/${encodeURIComponent(String(args["task_id"]))}`,171});172}173);174175server.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{185title: "Update task status, priority, or assignee",186readOnlyHint: false,187destructiveHint: false,188idempotentHint: false,189openWorldHint: true,190},191async (args) => {192const bodyPayload: Record<string, unknown> = {};193if (args["status"] !== undefined) bodyPayload["status"] = args["status"];194if (args["priority"] !== undefined) bodyPayload["priority"] = args["priority"];195if (args["assignee_id"] !== undefined) bodyPayload["assignee_id"] = args["assignee_id"];196return callUpstream({197method: "PATCH",198path: `/tasks/${encodeURIComponent(String(args["task_id"]))}`,199body: bodyPayload,200});201}202);203204server.tool(205"delete_task",206"Permanently delete a task [DELETE /tasks/{task_id}]",207{208"task_id": z.string().describe("Task ID to delete"),209confirm_destructive_action: z.boolean().describe("Safety guard: must be explicitly set to true to execute this DELETE operation."),210},211{212title: "Permanently delete a task",213readOnlyHint: false,214destructiveHint: true,215idempotentHint: false,216openWorldHint: true,217},218async (args) => {219if (!args.confirm_destructive_action) {220return {221isError: true,222content: [{ type: "text", text: "Blocked by safety guard: set confirm_destructive_action=true after user confirmation." }],223};224}225return callUpstream({226method: "DELETE",227path: `/tasks/${encodeURIComponent(String(args["task_id"]))}`,228});229}230);231232server.tool(233"list_projects",234"List active workspace projects [GET /projects]",235{236"archived": z.boolean().describe("Include archived projects").optional(),237},238{239title: "List active workspace projects",240readOnlyHint: true,241destructiveHint: false,242idempotentHint: true,243openWorldHint: true,244},245async (args) => {246const query = new URLSearchParams();247if (args["archived"] !== undefined) query.set("archived", String(args["archived"]));248return callUpstream({249method: "GET",250path: "/projects",251query,252});253}254);255256server.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{264title: "Create a new project milestone",265readOnlyHint: false,266destructiveHint: false,267idempotentHint: false,268openWorldHint: true,269},270async (args) => {271const bodyPayload: Record<string, unknown> = {};272if (args["name"] !== undefined) bodyPayload["name"] = args["name"];273if (args["lead_id"] !== undefined) bodyPayload["lead_id"] = args["lead_id"];274return callUpstream({275method: "POST",276path: "/projects",277body: bodyPayload,278});279}280);281282server.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{290title: "Search CRM contacts by email or company",291readOnlyHint: true,292destructiveHint: false,293idempotentHint: true,294openWorldHint: true,295},296async (args) => {297const query = new URLSearchParams();298if (args["q"] !== undefined) query.set("q", String(args["q"]));299if (args["stage"] !== undefined) query.set("stage", String(args["stage"]));300return callUpstream({301method: "GET",302path: "/contacts",303query,304});305}306);307308server.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{317title: "Add a new CRM contact",318readOnlyHint: false,319destructiveHint: false,320idempotentHint: false,321openWorldHint: true,322},323async (args) => {324const bodyPayload: Record<string, unknown> = {};325if (args["email"] !== undefined) bodyPayload["email"] = args["email"];326if (args["full_name"] !== undefined) bodyPayload["full_name"] = args["full_name"];327if (args["company"] !== undefined) bodyPayload["company"] = args["company"];328return callUpstream({329method: "POST",330path: "/contacts",331body: bodyPayload,332});333}334);335336server.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{343title: "List pipeline deals and ARR values",344readOnlyHint: true,345destructiveHint: false,346idempotentHint: true,347openWorldHint: true,348},349async (args) => {350const query = new URLSearchParams();351if (args["stage"] !== undefined) query.set("stage", String(args["stage"]));352return callUpstream({353method: "GET",354path: "/deals",355query,356});357}358);359360async function main() {361const transport = new StdioServerTransport();362await server.connect(transport);363console.error("workspace-crm-tasks-api MCP server listening on stdio (10 tools)");364}365366main().catch((err) => {367console.error("Fatal MCP server error:", err);368process.exit(1);369});370
How to export & compile your Notion API OpenAPI spec
Paste a Notion OpenAPI JSON subset targeting /v1/search, /v1/databases/{id}/query, and /v1/pages.
High-Signal Notion API MCP Tools to Expose First
| Method | Endpoint Path | MCP Tool Name | Purpose |
|---|---|---|---|
| POST | /v1/search | search_notion_workspace | Find pages and databases by title |
| POST | /v1/databases/{database_id}/query | query_notion_database | Filter structured database rows |
| POST | /v1/pages | create_notion_page | Publish RFCs or meeting summaries |
Best Practices for Notion API
- Remember to add the Notion-Version: 2022-06-28 header inside callUpstream()—Notion rejects requests without it.
- Share only specific Notion pages or databases with your internal integration so your MCP server enforces workspace boundaries naturally.
- Expose /v1/search and /v1/blocks/{block_id}/children together so agents can discover a page ID and then read its content.
Common Notion API MCP Gotchas
- Notion requires the custom header Notion-Version on every call in addition to Authorization: Bearer.
- Notion's block-children response can be deeply nested JSON; cap page_size at 20–50 to avoid overflowing agent context windows.
- Archiving a Notion page is done via PATCH /v1/pages/{id} with archived: true—flag it with a confirmation guard.
Notion API to MCP Server — Frequently Asked Questions
Where do I get a Notion API token for my MCP server?
Create an Internal Integration at notion.so/my-integrations, copy the secret token, and invite that integration to the specific Notion pages you want accessible.
Does Spec2MCP support Notion's POST-based search and database query endpoints?
Yes. Spec2MCP extracts JSON requestBody properties from POST endpoints into typed Zod or FastMCP arguments.
Can I run the Notion MCP server in Python FastMCP instead of Node.js?
Yes—switch to the server.py tab and copy the uv-based mcp.json configuration.
Related OpenAPI-to-MCP Converters
View all 20Airtable Personal Access Token (Bearer pat...)
HTTP Basic Auth (your-email@company.com:JIRA_API_TOKEN)
HubSpot Private App Bearer Token (pat-na1-...)
Bearer, API Key Header/Query, or Basic via process.env
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.
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
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
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