Skip to main content
Glama

notion-mcp-server

batchMixedOperations.ts1.74 kB
import { notion } from "../services/notion.js"; import { BatchMixedOperationsParams } from "../types/blocks.js"; import { handleNotionError } from "../utils/error.js"; import { CallToolResult } from "@modelcontextprotocol/sdk/types.js"; export const batchMixedOperations = async ( params: BatchMixedOperationsParams ): Promise<CallToolResult> => { try { const results = []; const operationCounts = { append: 0, update: 0, delete: 0, }; for (const op of params.operations) { let response; switch (op.operation) { case "append": response = await notion.blocks.children.append({ block_id: op.blockId, children: op.children, }); operationCounts.append++; break; case "update": response = await notion.blocks.update({ block_id: op.blockId, ...op.data, }); operationCounts.update++; break; case "delete": response = await notion.blocks.delete({ block_id: op.blockId, }); operationCounts.delete++; break; } results.push({ operation: op.operation, blockId: op.blockId, success: true, response, }); } return { content: [ { type: "text", text: `Successfully performed ${params.operations.length} operations (${operationCounts.append} append, ${operationCounts.update} update, ${operationCounts.delete} delete)`, }, { type: "text", text: JSON.stringify(results, null, 2), }, ], }; } catch (error) { return handleNotionError(error); } };

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/awkoy/notion-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server