openai-assistants-mcp
Version:
OpenAI Assistants MCP Server - A Model Context Protocol server providing OpenAI Assistants API tools and resources. Features comprehensive assistant management, thread operations, message handling, and run execution with seamless stdio transport for Claud
185 lines • 4.81 kB
text/typescript
/**
* Base MCP Handler class that consolidates all deployment targets
*
* This class implements the core MCP protocol logic and can be extended
* or adapted for different deployment environments through the adapter pattern.
*/
export class BaseMCPHandler {
constructor(config: any, transportAdapter: any);
config: any;
transportAdapter: any;
openaiService: OpenAIService;
promptHandlers: {};
completionHandlers: {};
isInitialized: boolean;
/**
* Initialize the handler system with performance optimizations
*/
initializeHandlerSystem(): void;
toolRegistry: import("./handlers/index.cjs").ToolRegistry | undefined;
/**
* Initialize the prompt handlers system
*/
initializePromptHandlers(): void;
/**
* Initialize the completion handlers system
*/
initializeCompletionHandlers(): void;
/**
* Main request handler - entry point for all MCP requests
*/
handleRequest(request: any): Promise<any>;
/**
* Handle initialize requests
*/
handleInitialize(request: any): Promise<{
jsonrpc: string;
id: any;
result: {
protocolVersion: string;
capabilities: {
tools: any;
resources: any;
prompts: any;
completions: any;
};
serverInfo: {
name: any;
version: any;
};
};
}>;
/**
* Handle tools list requests with pagination support
*/
handleToolsList(request: any): Promise<{
jsonrpc: string;
id: any;
result: {
tools: any;
nextCursor: string | null;
};
}>;
/**
* Handle tools call requests with optimized registry usage
*/
handleToolsCall(request: any, ...args: any[]): Promise<{
jsonrpc: string;
id: any;
result: {
content: {
type: string;
text: string;
}[];
isError?: undefined;
};
} | {
jsonrpc: string;
id: any;
result: {
content: {
type: string;
text: string;
}[];
isError: boolean;
};
}>;
/**
* Handle resources list requests with pagination support
*/
handleResourcesList(request: any): Promise<{
jsonrpc: string;
id: any;
result: {
resources: any;
nextCursor: string | null;
};
}>;
/**
* Handle resources read requests
*/
handleResourcesRead(request: any): Promise<{
jsonrpc: string;
id: any;
result: {
contents: {
uri: any;
name: any;
mimeType: any;
text: string;
}[];
};
}>;
/**
* Handle prompts list requests
*/
handlePromptsList(request: any): Promise<{
jsonrpc: string;
id: any;
result: any;
}>;
/**
* Handle prompts get requests
*/
handlePromptsGet(request: any): Promise<{
jsonrpc: string;
id: any;
result: any;
}>;
/**
* Handle completion requests
*/
handleCompletion(request: any): Promise<{
jsonrpc: string;
id: any;
result: any;
}>;
/**
* Update registry context without recreating the entire registry
* This is a performance optimization to avoid the registry recreation issue
*/
updateRegistryContext(newContext: any): void;
/**
* Centralized error handling with transport adapter support and JSON-RPC 2.0 compliance
*/
handleError(error: any, requestId: any): any;
/**
* Update API key and reinitialize services
*/
updateApiKey(apiKey: any): void;
/**
* Get registry statistics for debugging
*/
getRegistryStats(): {
totalHandlers: number;
handlersByCategory: {};
registeredTools: any[];
};
/**
* Check if handler is initialized
*/
getIsInitialized(): boolean;
/**
* Debug logging
*/
log(message: any, ...args: any[]): void;
}
export class MCPError extends Error {
constructor(code: any, message: any, data: any);
code: any;
data: any;
}
export namespace ErrorCodes {
let PARSE_ERROR: number;
let INVALID_REQUEST: number;
let METHOD_NOT_FOUND: number;
let INVALID_PARAMS: number;
let INTERNAL_ERROR: number;
}
export namespace LegacyErrorCodes {
let NOT_FOUND: number;
let VALIDATION_ERROR: number;
let RATE_LIMIT: number;
}
import { OpenAIService } from "../services/openai-service.cjs";
//# sourceMappingURL=base-mcp-handler.d.cts.map