import { Server } from '@modelcontextprotocol/sdk/server/index.js';
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
import { ToolRegistry } from './tools/registry.js';
import { ResourceRegistry } from './resources/registry.js';
import { RequestHandlers } from './handlers/index.js';
import { getServerInfo, getServerCapabilities } from './utils/config.js';
export class SimpleMCPServer {
private server: Server;
private toolRegistry: ToolRegistry;
private resourceRegistry: ResourceRegistry;
private requestHandlers: RequestHandlers;
constructor() {
this.server = new Server(getServerInfo(), getServerCapabilities());
this.toolRegistry = new ToolRegistry();
this.resourceRegistry = new ResourceRegistry();
this.requestHandlers = new RequestHandlers(
this.server,
this.toolRegistry,
this.resourceRegistry
);
}
async run() {
const transport = new StdioServerTransport();
await this.server.connect(transport);
console.error('Simple MCP Server running on stdio');
}
// Getter methods for accessing registries (useful for testing or extending)
getToolRegistry(): ToolRegistry {
return this.toolRegistry;
}
getResourceRegistry(): ResourceRegistry {
return this.resourceRegistry;
}
getServer(): Server {
return this.server;
}
}