UNPKG

@noanswer/context-compose

Version:

Orchestrate complex AI interactions with Context Compose. A powerful CLI and server for building, validating, and managing context for large language models using the Model Context Protocol (MCP).

58 lines 1.58 kB
import { FastMCP } from 'fastmcp'; import { findPackageJson } from '../../src/core/utils/index.js'; import { registerAllTools } from './tools/index.js'; /** * Main MCP server class that integrates with Context Compose */ class ContextComposeServer { server; initialized; constructor() { // Get version from package.json using shared utility const packageJson = findPackageJson(); // Create FastMCP server with proper options this.server = new FastMCP({ name: 'Context Compose Server', version: packageJson.version, }); this.initialized = false; // Bind methods this.init = this.init.bind(this); this.start = this.start.bind(this); this.stop = this.stop.bind(this); } /** * Initialize the MCP server with necessary tools and routes */ async init() { if (this.initialized) return; // Register all Context Compose tools registerAllTools(this.server); this.initialized = true; return this; } /** * Start the MCP server */ async start() { if (!this.initialized) { await this.init(); } // Start the FastMCP server await this.server.start({ transportType: 'stdio', }); return this; } /** * Stop the MCP server */ async stop() { if (this.server) { await this.server.stop(); } } } export default ContextComposeServer; //# sourceMappingURL=index.js.map