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.

30 lines (29 loc) 1.17 kB
import { server } from "../server.js"; import { ERROR_MESSAGES } from "../constants/notion.js"; import { validateRequest } from "../utils/validation.js"; import { handleCallback } from "../utils/message-handlers.js"; export async function sendSamplingRequest(request) { try { // Validate the request first validateRequest(request); const result = await server.createMessage({ ...request.params, messages: request.params.messages, }); const callback = request.params._meta?.callback; if (callback && typeof callback === "string") { return await handleCallback(callback, result); } return result; } catch (error) { // Log the error for debugging console.error(ERROR_MESSAGES.SAMPLING.REQUEST_FAILED, error instanceof Error ? error.message : error); // If it's already an Error object, throw it directly if (error instanceof Error) { throw error; } // For other errors, throw a formatted error throw new Error(`${ERROR_MESSAGES.SAMPLING.REQUEST_FAILED}${error || "Unknown error"}`); } }