Skip to main content
Glama

Optimized Memory MCP Server V2

by AgentWong
errors.py2.49 kB
"""Error handling utilities for MCP server.""" from datetime import datetime from typing import Any # Standard MCP error codes RESOURCE_NOT_FOUND = "RESOURCE_NOT_FOUND" TOOL_NOT_FOUND = "TOOL_NOT_FOUND" INVALID_RESOURCE = "INVALID_RESOURCE" INVALID_ARGUMENTS = "INVALID_ARGUMENTS" ENTITY_CREATE_ERROR = "ENTITY_CREATE_ERROR" DB_CONSTRAINT_ERROR = "DB_CONSTRAINT_ERROR" DB_TIMEOUT_ERROR = "DB_TIMEOUT_ERROR" VALIDATION_ERROR = "VALIDATION_ERROR" CONFIGURATION_ERROR = "CONFIGURATION_ERROR" INTERNAL_ERROR = "INTERNAL_ERROR" CONCURRENT_MODIFICATION = "CONCURRENT_MODIFICATION" class MCPError(Exception): """Base exception for MCP server errors.""" def __init__(self, message: str, code: str = INTERNAL_ERROR, details: dict[str, Any] | None = None): self.message = message self.code = code self.details = details or {} super().__init__(message) class ResourceError(MCPError): """Raised when there is a resource access error.""" def __init__(self, message: str, details: dict[str, Any] | None = None): super().__init__(message, RESOURCE_NOT_FOUND, details) class ValidationError(MCPError): """Raised when there is a validation error.""" def __init__(self, message: str, details: dict[str, Any] | None = None): super().__init__(message, VALIDATION_ERROR, details) class DatabaseError(MCPError): """Raised when there is a database error.""" def __init__(self, message: str, code: str = DB_CONSTRAINT_ERROR, details: dict[str, Any] | None = None): super().__init__(message, code, details) class ToolError(MCPError): """Raised when there is a tool execution error.""" def __init__(self, message: str, details: dict[str, Any] | None = None): super().__init__(message, TOOL_NOT_FOUND, details) class ConfigurationError(MCPError): """Raised when there is a configuration error.""" def __init__(self, message: str, details: dict[str, Any] | None = None): super().__init__(message, CONFIGURATION_ERROR, details) class InvalidResourceError(MCPError): """Raised when a resource request is invalid.""" def __init__(self, message: str, details: dict[str, Any] | None = None): super().__init__(message, INVALID_RESOURCE, details) class EntityError(MCPError): """Raised when there is an entity creation/update error.""" def __init__(self, message: str, details: dict[str, Any] | None = None): super().__init__(message, ENTITY_CREATE_ERROR, details)

Latest Blog Posts

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/AgentWong/optimized-memory-mcp-serverv2'

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