Skip to main content
Glama

Notion MCP Server

by yihaoWang
errors.ts1.22 kB
import { ErrorCode, McpError } from "@modelcontextprotocol/sdk/types.js"; export class ErrorHandler { static handleToolError(toolName: string, error: unknown): never { const message = error instanceof Error ? error.message : String(error); throw new McpError( ErrorCode.InternalError, `Error executing ${toolName}: ${message}` ); } static handleInvalidParams(message: string): never { throw new McpError(ErrorCode.InvalidParams, message); } static handleMethodNotFound(methodName: string): never { throw new McpError(ErrorCode.MethodNotFound, `Unknown tool: ${methodName}`); } } export class ValidationError extends Error { constructor(message: string) { super(message); this.name = 'ValidationError'; } } export class Validator { static validateRequired(value: any, fieldName: string): void { if (value === undefined || value === null || value === '') { throw new ValidationError(`${fieldName} is required`); } } static validateString(value: any, fieldName: string): void { this.validateRequired(value, fieldName); if (typeof value !== 'string') { throw new ValidationError(`${fieldName} must be a string`); } } }

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/yihaoWang/notion-mcp-server'

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