UNPKG

systemprompt-mcp-notion

Version:

A specialized Model Context Protocol (MCP) server that integrates Notion into your AI workflows. This server enables seamless access to Notion through MCP, allowing AI agents to interact with pages, databases, and comments.

27 lines (26 loc) 948 B
import { NOTION_TOOLS, TOOL_ERROR_MESSAGES } from "../constants/tools.js"; import { validateWithErrors } from "./validation.js"; /** * Validates a tool request and returns the tool configuration if valid */ export function validateToolRequest(request) { if (!request.params?.name) { throw new Error("Invalid tool request: missing tool name"); } const tool = NOTION_TOOLS.find((t) => t.name === request.params.name); if (!tool) { throw new Error(`${TOOL_ERROR_MESSAGES.UNKNOWN_TOOL} ${request.params.name}`); } // Validate arguments against the tool's schema if present if (tool.inputSchema && request.params.arguments) { validateWithErrors(request.params.arguments, tool.inputSchema); } return tool; } /** * Gets the schema for a tool by name */ export function getToolSchema(toolName) { const tool = NOTION_TOOLS.find((t) => t.name === toolName); return tool?.inputSchema; }