@sanderkooger/mcp-server-ragdocs
Version:
An MCP server for semantic documentation search and retrieval using vector databases to augment LLM capabilities.
40 lines (39 loc) • 1.27 kB
JavaScript
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
import { ApiClient } from './api-client.js';
import { HandlerRegistry } from './handler-registry.js';
class RagDocsServer {
server;
apiClient;
handlerRegistry;
constructor() {
this.server = new Server({
name: 'mcp-ragdocs',
version: '0.1.1'
}, {
capabilities: {
tools: {}
}
});
this.apiClient = new ApiClient();
this.handlerRegistry = new HandlerRegistry(this.server, this.apiClient);
// Error handling
this.server.onerror = (error) => console.error('[MCP Error]', error);
process.on('SIGINT', async () => {
await this.cleanup();
process.exit(0);
});
}
async cleanup() {
await this.apiClient.cleanup();
await this.server.close();
}
async run() {
const transport = new StdioServerTransport();
await this.server.connect(transport);
console.error('RAG Docs MCP server running on stdio');
}
}
const server = new RagDocsServer();
server.run().catch(console.error);