Skip to main content
Glama

SystemPrompt MCP Notion Server

sampling.ts1.27 kB
import { server } from "../server.js"; import type { CreateMessageRequest, CreateMessageResult, } from "@modelcontextprotocol/sdk/types.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: CreateMessageRequest ): Promise<CreateMessageResult> { 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"}` ); } }

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/Ejb503/systemprompt-mcp-notion'

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