@tryhamster/gerbil 1.0.0-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +23 -0
- package/README.md +253 -0
- package/bin/cli.js +2 -0
- package/dist/auto-update-BbNHbSU1.mjs +3 -0
- package/dist/browser/index.d.mts +262 -0
- package/dist/browser/index.d.mts.map +1 -0
- package/dist/browser/index.mjs +755 -0
- package/dist/browser/index.mjs.map +1 -0
- package/dist/chrome-backend-C5Un08O4.mjs +771 -0
- package/dist/chrome-backend-C5Un08O4.mjs.map +1 -0
- package/dist/chrome-backend-CtwPENIW.mjs +3 -0
- package/dist/chunk-Ct1HF2bE.mjs +7 -0
- package/dist/cli.d.mts +1 -0
- package/dist/cli.mjs +7078 -0
- package/dist/cli.mjs.map +1 -0
- package/dist/frameworks/express.d.mts +22 -0
- package/dist/frameworks/express.d.mts.map +1 -0
- package/dist/frameworks/express.mjs +123 -0
- package/dist/frameworks/express.mjs.map +1 -0
- package/dist/frameworks/fastify.d.mts +11 -0
- package/dist/frameworks/fastify.d.mts.map +1 -0
- package/dist/frameworks/fastify.mjs +73 -0
- package/dist/frameworks/fastify.mjs.map +1 -0
- package/dist/frameworks/hono.d.mts +14 -0
- package/dist/frameworks/hono.d.mts.map +1 -0
- package/dist/frameworks/hono.mjs +82 -0
- package/dist/frameworks/hono.mjs.map +1 -0
- package/dist/frameworks/next.d.mts +31 -0
- package/dist/frameworks/next.d.mts.map +1 -0
- package/dist/frameworks/next.mjs +116 -0
- package/dist/frameworks/next.mjs.map +1 -0
- package/dist/frameworks/react.d.mts +56 -0
- package/dist/frameworks/react.d.mts.map +1 -0
- package/dist/frameworks/react.mjs +172 -0
- package/dist/frameworks/react.mjs.map +1 -0
- package/dist/frameworks/trpc.d.mts +12 -0
- package/dist/frameworks/trpc.d.mts.map +1 -0
- package/dist/frameworks/trpc.mjs +80 -0
- package/dist/frameworks/trpc.mjs.map +1 -0
- package/dist/gerbil-BfnsFWRE.mjs +644 -0
- package/dist/gerbil-BfnsFWRE.mjs.map +1 -0
- package/dist/gerbil-BjW-z7Fq.mjs +5 -0
- package/dist/gerbil-DZ1k3ChC.d.mts +138 -0
- package/dist/gerbil-DZ1k3ChC.d.mts.map +1 -0
- package/dist/index.d.mts +223 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +13 -0
- package/dist/index.mjs.map +1 -0
- package/dist/integrations/ai-sdk.d.mts +78 -0
- package/dist/integrations/ai-sdk.d.mts.map +1 -0
- package/dist/integrations/ai-sdk.mjs +199 -0
- package/dist/integrations/ai-sdk.mjs.map +1 -0
- package/dist/integrations/langchain.d.mts +41 -0
- package/dist/integrations/langchain.d.mts.map +1 -0
- package/dist/integrations/langchain.mjs +93 -0
- package/dist/integrations/langchain.mjs.map +1 -0
- package/dist/integrations/llamaindex.d.mts +45 -0
- package/dist/integrations/llamaindex.d.mts.map +1 -0
- package/dist/integrations/llamaindex.mjs +86 -0
- package/dist/integrations/llamaindex.mjs.map +1 -0
- package/dist/integrations/mcp-client.d.mts +206 -0
- package/dist/integrations/mcp-client.d.mts.map +1 -0
- package/dist/integrations/mcp-client.mjs +507 -0
- package/dist/integrations/mcp-client.mjs.map +1 -0
- package/dist/integrations/mcp.d.mts +177 -0
- package/dist/integrations/mcp.d.mts.map +1 -0
- package/dist/integrations/mcp.mjs +8 -0
- package/dist/mcp-R8kRLIKb.mjs +348 -0
- package/dist/mcp-R8kRLIKb.mjs.map +1 -0
- package/dist/models-DKULvhOr.mjs +136 -0
- package/dist/models-DKULvhOr.mjs.map +1 -0
- package/dist/models-De2-_GmQ.d.mts +22 -0
- package/dist/models-De2-_GmQ.d.mts.map +1 -0
- package/dist/one-liner-BUQR0nqq.mjs +98 -0
- package/dist/one-liner-BUQR0nqq.mjs.map +1 -0
- package/dist/skills/index.d.mts +390 -0
- package/dist/skills/index.d.mts.map +1 -0
- package/dist/skills/index.mjs +7 -0
- package/dist/skills-D3CEpgDc.mjs +630 -0
- package/dist/skills-D3CEpgDc.mjs.map +1 -0
- package/dist/tools-BsiEE6f2.mjs +567 -0
- package/dist/tools-BsiEE6f2.mjs.map +1 -0
- package/dist/types-BS1N92Jt.d.mts +183 -0
- package/dist/types-BS1N92Jt.d.mts.map +1 -0
- package/dist/utils-7vXqtq2Q.mjs +63 -0
- package/dist/utils-7vXqtq2Q.mjs.map +1 -0
- package/docs/ai-sdk.md +80 -0
- package/docs/architecture/README.md +84 -0
- package/docs/architecture/caching.md +227 -0
- package/docs/architecture/inference.md +176 -0
- package/docs/architecture/overview.md +179 -0
- package/docs/architecture/streaming.md +261 -0
- package/docs/architecture/webgpu.md +213 -0
- package/docs/browser.md +328 -0
- package/docs/cli.md +155 -0
- package/docs/frameworks.md +90 -0
- package/docs/mcp-client.md +224 -0
- package/docs/mcp.md +109 -0
- package/docs/memory.md +229 -0
- package/docs/repl.md +473 -0
- package/docs/skills.md +261 -0
- package/docs/tools.md +304 -0
- package/package.json +207 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-client.mjs","names":["result: any","tools: Array<{ server: string; tool: MCPTool }>","shape: Record<string, z.ZodType<any>>","zodType: z.ZodType<any>","defaultHub: MCPHub | null","byServer: Record<string, string[]>"],"sources":["../../src/integrations/mcp-client.ts"],"sourcesContent":["/**\n * Gerbil MCP Client\n *\n * Connect to external MCP servers and use their tools.\n * Uses the official @modelcontextprotocol/sdk for protocol compliance.\n *\n * @example\n * ```typescript\n * import { MCPClient, MCPHub } from \"gerbil/mcp-client\";\n *\n * // Connect to a single server\n * const client = new MCPClient({\n * name: \"filesystem\",\n * command: \"uvx\",\n * args: [\"mcp-server-filesystem\", \"/tmp\"]\n * });\n * await client.connect();\n * const tools = await client.listTools();\n * const result = await client.callTool(\"read_file\", { path: \"/tmp/test.txt\" });\n *\n * // Or use the hub for multiple servers\n * const hub = new MCPHub();\n * await hub.addServer(\"filesystem\", { command: \"uvx\", args: [\"mcp-server-filesystem\", \"/tmp\"] });\n * await hub.addServer(\"browser\", { command: \"npx\", args: [\"-y\", \"@anthropic/mcp-server-puppeteer\"] });\n *\n * // All tools from all servers are available\n * const allTools = hub.getAllTools();\n * ```\n */\n\nimport { z } from \"zod\";\nimport { defineTool } from \"../core/tools.js\";\n\n// ============================================\n// Types\n// ============================================\n\nexport type MCPServerConfig = {\n /** Command to run the MCP server */\n command: string;\n\n /** Arguments for the command */\n args?: string[];\n\n /** Environment variables */\n env?: Record<string, string>;\n\n /** Working directory */\n cwd?: string;\n\n /** Timeout for requests (ms, default: 30000) */\n timeout?: number;\n};\n\nexport type MCPTool = {\n name: string;\n description?: string;\n inputSchema?: {\n type: string;\n properties?: Record<string, any>;\n required?: string[];\n };\n};\n\nexport type MCPResource = {\n uri: string;\n name: string;\n description?: string;\n mimeType?: string;\n};\n\n// ============================================\n// MCP Client (uses official SDK)\n// ============================================\n\n/**\n * Client for a single MCP server.\n *\n * Uses @modelcontextprotocol/sdk when available, falls back to\n * a minimal stdio implementation otherwise.\n */\nexport class MCPClient {\n private readonly config: MCPServerConfig;\n private client: any = null;\n private transport: any = null;\n private connected = false;\n private _tools: MCPTool[] = [];\n private _resources: MCPResource[] = [];\n private readonly serverName: string;\n private useFallback = false;\n\n // Fallback implementation state\n private fallbackProcess: any = null;\n private fallbackRequestId = 0;\n private readonly fallbackPending = new Map<\n number,\n { resolve: (v: any) => void; reject: (e: Error) => void }\n >();\n private fallbackBuffer = \"\";\n\n constructor(config: MCPServerConfig & { name?: string }) {\n this.config = {\n timeout: 30_000,\n ...config,\n };\n this.serverName = config.name || \"mcp\";\n }\n\n /**\n * Connect to the MCP server\n */\n async connect(): Promise<void> {\n if (this.connected) {\n return;\n }\n\n try {\n // Try to use official SDK\n const sdk = await this.loadSDK();\n if (sdk) {\n await this.connectWithSDK(sdk);\n } else {\n // Fallback to minimal implementation\n await this.connectFallback();\n }\n\n this.connected = true;\n await this.refreshCapabilities();\n } catch (e) {\n this.connected = false;\n throw e;\n }\n }\n\n /**\n * Try to load the official MCP SDK\n * Uses dynamic import to avoid bundling issues when SDK is not installed\n */\n private async loadSDK(): Promise<any | null> {\n try {\n // Use Function constructor to create truly dynamic imports\n // This prevents TypeScript/bundlers from trying to resolve the module\n const importDynamic = new Function(\"modulePath\", \"return import(modulePath)\");\n const clientModule = await importDynamic(\"@modelcontextprotocol/sdk/client\");\n const stdioModule = await importDynamic(\"@modelcontextprotocol/sdk/client/stdio\");\n return {\n Client: clientModule.Client,\n StdioClientTransport: stdioModule.StdioClientTransport,\n };\n } catch {\n // SDK not installed - use fallback\n return null;\n }\n }\n\n /**\n * Connect using the official SDK\n */\n private async connectWithSDK(sdk: any): Promise<void> {\n const { Client, StdioClientTransport } = sdk;\n\n this.transport = new StdioClientTransport({\n command: this.config.command,\n args: this.config.args || [],\n env: this.config.env,\n });\n\n this.client = new Client({ name: \"gerbil\", version: \"1.0.0\" }, { capabilities: {} });\n\n await this.client.connect(this.transport);\n }\n\n /**\n * Fallback: Connect without SDK using raw stdio\n */\n private async connectFallback(): Promise<void> {\n this.useFallback = true;\n\n const { spawn } = await import(\"child_process\");\n\n this.fallbackProcess = spawn(this.config.command, this.config.args || [], {\n cwd: this.config.cwd,\n env: { ...process.env, ...this.config.env },\n stdio: [\"pipe\", \"pipe\", \"pipe\"],\n });\n\n this.fallbackProcess.stdout?.on(\"data\", (data: Buffer) => {\n this.fallbackBuffer += data.toString();\n this.processFallbackBuffer();\n });\n\n this.fallbackProcess.on(\"error\", (err: Error) => {\n this.connected = false;\n throw new Error(`MCP server error: ${err.message}`);\n });\n\n this.fallbackProcess.on(\"exit\", (code: number) => {\n this.connected = false;\n for (const [_, req] of this.fallbackPending) {\n req.reject(new Error(`MCP server exited with code ${code}`));\n }\n this.fallbackPending.clear();\n });\n\n // Initialize\n await this.fallbackRequest(\"initialize\", {\n protocolVersion: \"2024-11-05\",\n capabilities: {},\n clientInfo: { name: \"gerbil\", version: \"0.1.0\" },\n });\n\n // Send initialized notification\n this.fallbackNotify(\"notifications/initialized\", {});\n }\n\n private processFallbackBuffer(): void {\n const lines = this.fallbackBuffer.split(\"\\n\");\n this.fallbackBuffer = lines.pop() || \"\";\n\n for (const line of lines) {\n if (!line.trim()) {\n continue;\n }\n try {\n const response = JSON.parse(line);\n if (response.id !== undefined) {\n const pending = this.fallbackPending.get(response.id);\n if (pending) {\n this.fallbackPending.delete(response.id);\n if (response.error) {\n pending.reject(new Error(response.error.message));\n } else {\n pending.resolve(response.result);\n }\n }\n }\n } catch {}\n }\n }\n\n private fallbackRequest(method: string, params?: any): Promise<any> {\n return new Promise((resolve, reject) => {\n if (!this.fallbackProcess?.stdin) {\n reject(new Error(\"Not connected\"));\n return;\n }\n\n const id = ++this.fallbackRequestId;\n const request = { jsonrpc: \"2.0\", id, method, params };\n\n const timeout = setTimeout(() => {\n this.fallbackPending.delete(id);\n reject(new Error(`Request timeout: ${method}`));\n }, this.config.timeout);\n\n this.fallbackPending.set(id, {\n resolve: (v) => {\n clearTimeout(timeout);\n resolve(v);\n },\n reject: (e) => {\n clearTimeout(timeout);\n reject(e);\n },\n });\n\n this.fallbackProcess.stdin.write(`${JSON.stringify(request)}\\n`);\n });\n }\n\n private fallbackNotify(method: string, params?: any): void {\n if (!this.fallbackProcess?.stdin) {\n return;\n }\n this.fallbackProcess.stdin.write(`${JSON.stringify({ jsonrpc: \"2.0\", method, params })}\\n`);\n }\n\n /**\n * Disconnect from the MCP server\n */\n async disconnect(): Promise<void> {\n if (!this.connected) {\n return;\n }\n\n if (this.useFallback && this.fallbackProcess) {\n this.fallbackProcess.kill(\"SIGTERM\");\n this.fallbackProcess = null;\n } else if (this.client) {\n await this.client.close();\n this.client = null;\n this.transport = null;\n }\n\n this.connected = false;\n this._tools = [];\n this._resources = [];\n }\n\n /**\n * Refresh tools and resources from the server\n */\n async refreshCapabilities(): Promise<void> {\n try {\n if (this.useFallback) {\n const result = await this.fallbackRequest(\"tools/list\", {});\n this._tools = result.tools || [];\n } else if (this.client) {\n const result = await this.client.listTools();\n this._tools = result.tools || [];\n }\n } catch {\n this._tools = [];\n }\n\n try {\n if (this.useFallback) {\n const result = await this.fallbackRequest(\"resources/list\", {});\n this._resources = result.resources || [];\n } else if (this.client) {\n const result = await this.client.listResources();\n this._resources = result.resources || [];\n }\n } catch {\n this._resources = [];\n }\n }\n\n /**\n * List available tools\n */\n listTools(): MCPTool[] {\n return this._tools;\n }\n\n /**\n * List available resources\n */\n listResources(): MCPResource[] {\n return this._resources;\n }\n\n /**\n * Call a tool\n */\n async callTool(name: string, args: Record<string, any> = {}): Promise<any> {\n let result: any;\n\n if (this.useFallback) {\n result = await this.fallbackRequest(\"tools/call\", {\n name,\n arguments: args,\n });\n } else if (this.client) {\n result = await this.client.callTool({ name, arguments: args });\n } else {\n throw new Error(\"Not connected\");\n }\n\n // MCP returns content array\n if (result.content && Array.isArray(result.content)) {\n return result.content.map((c: any) => c.text || JSON.stringify(c)).join(\"\\n\");\n }\n\n return result;\n }\n\n /**\n * Read a resource\n */\n async readResource(uri: string): Promise<string> {\n let result: any;\n\n if (this.useFallback) {\n result = await this.fallbackRequest(\"resources/read\", { uri });\n } else if (this.client) {\n result = await this.client.readResource({ uri });\n } else {\n throw new Error(\"Not connected\");\n }\n\n if (result.contents && Array.isArray(result.contents)) {\n return result.contents.map((c: any) => c.text || c.blob || \"\").join(\"\\n\");\n }\n\n return typeof result === \"string\" ? result : JSON.stringify(result);\n }\n\n /**\n * Check if connected\n */\n isConnected(): boolean {\n return this.connected;\n }\n\n /**\n * Get server name\n */\n getName(): string {\n return this.serverName;\n }\n}\n\n// ============================================\n// MCP Hub (manage multiple servers)\n// ============================================\n\n/**\n * Hub for managing multiple MCP server connections\n */\nexport class MCPHub {\n private readonly clients = new Map<string, MCPClient>();\n private readonly toolPrefix = \"mcp\";\n\n /**\n * Add and connect to an MCP server\n */\n async addServer(name: string, config: MCPServerConfig): Promise<MCPClient> {\n // Disconnect existing if same name\n if (this.clients.has(name)) {\n await this.removeServer(name);\n }\n\n const client = new MCPClient({ ...config, name });\n await client.connect();\n this.clients.set(name, client);\n\n // Register tools from this server\n this.registerServerTools(name, client);\n\n return client;\n }\n\n /**\n * Remove and disconnect an MCP server\n */\n async removeServer(name: string): Promise<void> {\n const client = this.clients.get(name);\n if (client) {\n await client.disconnect();\n this.clients.delete(name);\n }\n }\n\n /**\n * Get a specific client\n */\n getClient(name: string): MCPClient | undefined {\n return this.clients.get(name);\n }\n\n /**\n * List connected servers\n */\n listServers(): string[] {\n return Array.from(this.clients.keys());\n }\n\n /**\n * Get all tools from all servers\n */\n getAllTools(): Array<{ server: string; tool: MCPTool }> {\n const tools: Array<{ server: string; tool: MCPTool }> = [];\n\n for (const [serverName, client] of this.clients) {\n for (const tool of client.listTools()) {\n tools.push({ server: serverName, tool });\n }\n }\n\n return tools;\n }\n\n /**\n * Call a tool from any connected server\n * Tool name format: \"server_name:tool_name\" or just \"tool_name\" (searches all)\n */\n async callTool(toolName: string, args: Record<string, any> = {}): Promise<any> {\n // Check if prefixed with server name\n if (toolName.includes(\":\")) {\n const [serverName, actualToolName] = toolName.split(\":\", 2);\n const client = this.clients.get(serverName);\n if (!client) {\n throw new Error(`MCP server \"${serverName}\" not connected`);\n }\n return client.callTool(actualToolName, args);\n }\n\n // Search all servers for the tool\n for (const [_, client] of this.clients) {\n const tools = client.listTools();\n if (tools.some((t) => t.name === toolName)) {\n return client.callTool(toolName, args);\n }\n }\n\n throw new Error(`Tool \"${toolName}\" not found in any connected MCP server`);\n }\n\n /**\n * Disconnect all servers\n */\n async disconnectAll(): Promise<void> {\n for (const [name] of this.clients) {\n await this.removeServer(name);\n }\n }\n\n /**\n * Register tools from an MCP server into Gerbil's tool registry\n */\n private registerServerTools(serverName: string, client: MCPClient): void {\n const tools = client.listTools();\n\n for (const tool of tools) {\n // Create a Gerbil tool that wraps the MCP tool\n const gerbilToolName = `${this.toolPrefix}_${serverName}_${tool.name}`;\n\n // Build Zod schema from MCP input schema\n const zodSchema = this.mcpSchemaToZod(tool.inputSchema);\n\n defineTool({\n name: gerbilToolName,\n description: `[MCP:${serverName}] ${tool.description || tool.name}`,\n parameters: zodSchema,\n execute: async (params) => {\n const result = await client.callTool(tool.name, params);\n return typeof result === \"string\" ? result : JSON.stringify(result);\n },\n });\n }\n }\n\n /**\n * Convert MCP JSON Schema to Zod schema (simplified)\n */\n private mcpSchemaToZod(schema?: MCPTool[\"inputSchema\"]): z.ZodType<any> {\n if (!schema || schema.type !== \"object\") {\n return z.object({}).passthrough();\n }\n\n const shape: Record<string, z.ZodType<any>> = {};\n const properties = schema.properties || {};\n const required = new Set(schema.required || []);\n\n for (const [key, prop] of Object.entries(properties)) {\n let zodType: z.ZodType<any>;\n\n switch ((prop as any).type) {\n case \"string\":\n zodType = z.string();\n if ((prop as any).description) {\n zodType = zodType.describe((prop as any).description);\n }\n break;\n case \"number\":\n case \"integer\":\n zodType = z.number();\n break;\n case \"boolean\":\n zodType = z.boolean();\n break;\n case \"array\":\n zodType = z.array(z.any());\n break;\n default:\n zodType = z.any();\n }\n\n if (!required.has(key)) {\n zodType = zodType.optional();\n }\n\n shape[key] = zodType;\n }\n\n return z.object(shape).passthrough();\n }\n}\n\n// ============================================\n// Convenience functions\n// ============================================\n\nlet defaultHub: MCPHub | null = null;\n\n/**\n * Get the default MCP hub (singleton)\n */\nexport function getMCPHub(): MCPHub {\n if (!defaultHub) {\n defaultHub = new MCPHub();\n }\n return defaultHub;\n}\n\n/**\n * Connect to an MCP server\n */\nexport async function connectMCP(name: string, config: MCPServerConfig): Promise<MCPClient> {\n return getMCPHub().addServer(name, config);\n}\n\n/**\n * Disconnect from an MCP server\n */\nexport async function disconnectMCP(name: string): Promise<void> {\n return getMCPHub().removeServer(name);\n}\n\n/**\n * Call an MCP tool\n */\nexport async function callMCPTool(toolName: string, args?: Record<string, any>): Promise<any> {\n return getMCPHub().callTool(toolName, args);\n}\n\n// ============================================\n// Built-in MCP tools for chat\n// ============================================\n\n/**\n * Tool for the LLM to call MCP tools\n */\ndefineTool({\n name: \"mcp_call\",\n description:\n \"Call a tool from a connected MCP server. Use this when you need to interact with external tools like file systems, browsers, databases, etc.\",\n parameters: z.object({\n server: z.string().describe(\"The MCP server name (e.g., 'filesystem', 'browser')\"),\n tool: z.string().describe(\"The tool name to call\"),\n args: z.record(z.any()).optional().describe(\"Arguments to pass to the tool\"),\n }),\n execute: async ({ server, tool, args }) => {\n const hub = getMCPHub();\n const client = hub.getClient(server);\n\n if (!client) {\n const servers = hub.listServers();\n if (servers.length === 0) {\n return \"No MCP servers are connected. Use the MCP settings to connect to servers first.\";\n }\n return `Server \"${server}\" not found. Available servers: ${servers.join(\", \")}`;\n }\n\n try {\n const result = await client.callTool(tool, args || {});\n return typeof result === \"string\" ? result : JSON.stringify(result, null, 2);\n } catch (e) {\n return `Error calling ${server}:${tool}: ${e}`;\n }\n },\n});\n\n/**\n * Tool to list available MCP tools\n */\ndefineTool({\n name: \"mcp_list\",\n description: \"List all tools available from connected MCP servers\",\n parameters: z.object({\n server: z.string().optional().describe(\"Filter by server name (optional)\"),\n }),\n execute: async ({ server }) => {\n const hub = getMCPHub();\n\n if (server) {\n const client = hub.getClient(server);\n if (!client) {\n return `Server \"${server}\" not connected`;\n }\n const tools = client.listTools();\n return tools.map((t) => `- ${t.name}: ${t.description || \"(no description)\"}`).join(\"\\n\");\n }\n\n const allTools = hub.getAllTools();\n if (allTools.length === 0) {\n return \"No MCP servers connected. Connect to MCP servers to use external tools.\";\n }\n\n const byServer: Record<string, string[]> = {};\n for (const { server: s, tool } of allTools) {\n if (!byServer[s]) {\n byServer[s] = [];\n }\n byServer[s].push(` - ${tool.name}: ${tool.description || \"(no description)\"}`);\n }\n\n return Object.entries(byServer)\n .map(([s, tools]) => `[${s}]\\n${tools.join(\"\\n\")}`)\n .join(\"\\n\\n\");\n },\n});\n\nexport default {\n MCPClient,\n MCPHub,\n getMCPHub,\n connectMCP,\n disconnectMCP,\n callMCPTool,\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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EAAE;WACrE,GAAG;AACV,UAAO,iBAAiB,OAAO,GAAG,KAAK,IAAI;;;CAGhD,CAAC;;;;AAKF,WAAW;CACT,MAAM;CACN,aAAa;CACb,YAAY,EAAE,OAAO,EACnB,QAAQ,EAAE,QAAQ,CAAC,UAAU,CAAC,SAAS,mCAAmC,EAC3E,CAAC;CACF,SAAS,OAAO,EAAE,aAAa;EAC7B,MAAM,MAAM,WAAW;AAEvB,MAAI,QAAQ;GACV,MAAM,SAAS,IAAI,UAAU,OAAO;AACpC,OAAI,CAAC,OACH,QAAO,WAAW,OAAO;AAG3B,UADc,OAAO,WAAW,CACnB,KAAK,MAAM,KAAK,EAAE,KAAK,IAAI,EAAE,eAAe,qBAAqB,CAAC,KAAK,KAAK;;EAG3F,MAAM,WAAW,IAAI,aAAa;AAClC,MAAI,SAAS,WAAW,EACtB,QAAO;EAGT,MAAMC,WAAqC,EAAE;AAC7C,OAAK,MAAM,EAAE,QAAQ,GAAG,UAAU,UAAU;AAC1C,OAAI,CAAC,SAAS,GACZ,UAAS,KAAK,EAAE;AAElB,YAAS,GAAG,KAAK,OAAO,KAAK,KAAK,IAAI,KAAK,eAAe,qBAAqB;;AAGjF,SAAO,OAAO,QAAQ,SAAS,CAC5B,KAAK,CAAC,GAAG,WAAW,IAAI,EAAE,KAAK,MAAM,KAAK,KAAK,GAAG,CAClD,KAAK,OAAO;;CAElB,CAAC;AAEF,yBAAe;CACb;CACA;CACA;CACA;CACA;CACA;CACD"}
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import { s as GerbilConfig } from "../types-BS1N92Jt.mjs";
|
|
2
|
+
import { t as Gerbil } from "../gerbil-DZ1k3ChC.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/integrations/mcp.d.ts
|
|
5
|
+
|
|
6
|
+
interface MCPServerOptions extends GerbilConfig {
|
|
7
|
+
/** Port for HTTP transport (default: stdio) */
|
|
8
|
+
port?: number;
|
|
9
|
+
/** Tools to expose */
|
|
10
|
+
tools?: string[];
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Create MCP server
|
|
14
|
+
*/
|
|
15
|
+
declare function createMCPServer(options?: MCPServerOptions): Promise<{
|
|
16
|
+
info: {
|
|
17
|
+
name: string;
|
|
18
|
+
version: string;
|
|
19
|
+
description: string;
|
|
20
|
+
};
|
|
21
|
+
listTools: () => ({
|
|
22
|
+
name: string;
|
|
23
|
+
description: string;
|
|
24
|
+
inputSchema: {
|
|
25
|
+
type: string;
|
|
26
|
+
properties: {
|
|
27
|
+
prompt: {
|
|
28
|
+
type: string;
|
|
29
|
+
description: string;
|
|
30
|
+
};
|
|
31
|
+
maxTokens: {
|
|
32
|
+
type: string;
|
|
33
|
+
description: string;
|
|
34
|
+
};
|
|
35
|
+
temperature: {
|
|
36
|
+
type: string;
|
|
37
|
+
description: string;
|
|
38
|
+
};
|
|
39
|
+
system: {
|
|
40
|
+
type: string;
|
|
41
|
+
description: string;
|
|
42
|
+
};
|
|
43
|
+
thinking: {
|
|
44
|
+
type: string;
|
|
45
|
+
description: string;
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
required: string[];
|
|
49
|
+
};
|
|
50
|
+
} | {
|
|
51
|
+
name: string;
|
|
52
|
+
description: string;
|
|
53
|
+
inputSchema: {
|
|
54
|
+
type: string;
|
|
55
|
+
properties: {
|
|
56
|
+
content: {
|
|
57
|
+
type: string;
|
|
58
|
+
description: string;
|
|
59
|
+
};
|
|
60
|
+
length: {
|
|
61
|
+
type: string;
|
|
62
|
+
enum: string[];
|
|
63
|
+
};
|
|
64
|
+
format: {
|
|
65
|
+
type: string;
|
|
66
|
+
enum: string[];
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
required: string[];
|
|
70
|
+
};
|
|
71
|
+
} | {
|
|
72
|
+
name: string;
|
|
73
|
+
description: string;
|
|
74
|
+
inputSchema: {
|
|
75
|
+
type: string;
|
|
76
|
+
properties: {
|
|
77
|
+
content: {
|
|
78
|
+
type: string;
|
|
79
|
+
description: string;
|
|
80
|
+
};
|
|
81
|
+
level: {
|
|
82
|
+
type: string;
|
|
83
|
+
enum: string[];
|
|
84
|
+
};
|
|
85
|
+
language: {
|
|
86
|
+
type: string;
|
|
87
|
+
description: string;
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
required: string[];
|
|
91
|
+
};
|
|
92
|
+
} | {
|
|
93
|
+
name: string;
|
|
94
|
+
description: string;
|
|
95
|
+
inputSchema: {
|
|
96
|
+
type: string;
|
|
97
|
+
properties: {
|
|
98
|
+
code: {
|
|
99
|
+
type: string;
|
|
100
|
+
description: string;
|
|
101
|
+
};
|
|
102
|
+
focus: {
|
|
103
|
+
type: string;
|
|
104
|
+
items: {
|
|
105
|
+
type: string;
|
|
106
|
+
enum: string[];
|
|
107
|
+
};
|
|
108
|
+
};
|
|
109
|
+
};
|
|
110
|
+
required: string[];
|
|
111
|
+
};
|
|
112
|
+
} | {
|
|
113
|
+
name: string;
|
|
114
|
+
description: string;
|
|
115
|
+
inputSchema: {
|
|
116
|
+
type: string;
|
|
117
|
+
properties: {
|
|
118
|
+
diff: {
|
|
119
|
+
type: string;
|
|
120
|
+
description: string;
|
|
121
|
+
};
|
|
122
|
+
type: {
|
|
123
|
+
type: string;
|
|
124
|
+
enum: string[];
|
|
125
|
+
};
|
|
126
|
+
};
|
|
127
|
+
required: string[];
|
|
128
|
+
};
|
|
129
|
+
} | {
|
|
130
|
+
name: string;
|
|
131
|
+
description: string;
|
|
132
|
+
inputSchema: {
|
|
133
|
+
type: string;
|
|
134
|
+
properties: {
|
|
135
|
+
text: {
|
|
136
|
+
type: string;
|
|
137
|
+
description: string;
|
|
138
|
+
};
|
|
139
|
+
to: {
|
|
140
|
+
type: string;
|
|
141
|
+
description: string;
|
|
142
|
+
};
|
|
143
|
+
from: {
|
|
144
|
+
type: string;
|
|
145
|
+
description: string;
|
|
146
|
+
};
|
|
147
|
+
};
|
|
148
|
+
required: string[];
|
|
149
|
+
};
|
|
150
|
+
} | {
|
|
151
|
+
name: string;
|
|
152
|
+
description: string;
|
|
153
|
+
inputSchema: {
|
|
154
|
+
type: string;
|
|
155
|
+
properties: {
|
|
156
|
+
text: {
|
|
157
|
+
type: string;
|
|
158
|
+
description: string;
|
|
159
|
+
};
|
|
160
|
+
};
|
|
161
|
+
required: string[];
|
|
162
|
+
};
|
|
163
|
+
})[];
|
|
164
|
+
callTool: (name: string, args: any) => Promise<any>;
|
|
165
|
+
gerbil: Gerbil;
|
|
166
|
+
}>;
|
|
167
|
+
/**
|
|
168
|
+
* Start MCP server with stdio transport
|
|
169
|
+
*/
|
|
170
|
+
declare function startMCPServer(options?: MCPServerOptions): Promise<void>;
|
|
171
|
+
declare const _default: {
|
|
172
|
+
createMCPServer: typeof createMCPServer;
|
|
173
|
+
startMCPServer: typeof startMCPServer;
|
|
174
|
+
};
|
|
175
|
+
//#endregion
|
|
176
|
+
export { MCPServerOptions, createMCPServer, _default as default, startMCPServer };
|
|
177
|
+
//# sourceMappingURL=mcp.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp.d.mts","names":[],"sources":["../../src/integrations/mcp.ts"],"sourcesContent":[],"mappings":";;;;;UA2BiB,gBAAA,SAAyB;;;;;;;;;iBA2GpB,eAAA,WAAyB,mBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;yCAwGxB;;;;;;iBAgBtB,cAAA,WAAwB,mBAAqB;cA6DlE;0BAAA;yBAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import "../models-DKULvhOr.mjs";
|
|
2
|
+
import "../utils-7vXqtq2Q.mjs";
|
|
3
|
+
import "../gerbil-BfnsFWRE.mjs";
|
|
4
|
+
import "../one-liner-BUQR0nqq.mjs";
|
|
5
|
+
import "../skills-D3CEpgDc.mjs";
|
|
6
|
+
import { n as mcp_default, r as startMCPServer, t as createMCPServer } from "../mcp-R8kRLIKb.mjs";
|
|
7
|
+
|
|
8
|
+
export { createMCPServer, mcp_default as default, startMCPServer };
|
|
@@ -0,0 +1,348 @@
|
|
|
1
|
+
import { t as Gerbil } from "./gerbil-BfnsFWRE.mjs";
|
|
2
|
+
import { a as review, c as commit, i as summarize, s as explain, t as translate } from "./skills-D3CEpgDc.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/integrations/mcp.ts
|
|
5
|
+
/**
|
|
6
|
+
* Gerbil MCP Server
|
|
7
|
+
*
|
|
8
|
+
* Model Context Protocol server for Claude Desktop, Cursor, etc.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```bash
|
|
12
|
+
* gerbil serve --mcp
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* @example Claude Desktop config
|
|
16
|
+
* ```json
|
|
17
|
+
* {
|
|
18
|
+
* "mcpServers": {
|
|
19
|
+
* "gerbil": {
|
|
20
|
+
* "command": "npx",
|
|
21
|
+
* "args": ["-y", "gerbil", "serve", "--mcp"]
|
|
22
|
+
* }
|
|
23
|
+
* }
|
|
24
|
+
* }
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
const TOOL_DEFINITIONS = {
|
|
28
|
+
generate: {
|
|
29
|
+
name: "gerbil_generate",
|
|
30
|
+
description: "Generate text using a local LLM",
|
|
31
|
+
inputSchema: {
|
|
32
|
+
type: "object",
|
|
33
|
+
properties: {
|
|
34
|
+
prompt: {
|
|
35
|
+
type: "string",
|
|
36
|
+
description: "The prompt to generate from"
|
|
37
|
+
},
|
|
38
|
+
maxTokens: {
|
|
39
|
+
type: "number",
|
|
40
|
+
description: "Maximum tokens to generate"
|
|
41
|
+
},
|
|
42
|
+
temperature: {
|
|
43
|
+
type: "number",
|
|
44
|
+
description: "Sampling temperature (0-2)"
|
|
45
|
+
},
|
|
46
|
+
system: {
|
|
47
|
+
type: "string",
|
|
48
|
+
description: "System prompt"
|
|
49
|
+
},
|
|
50
|
+
thinking: {
|
|
51
|
+
type: "boolean",
|
|
52
|
+
description: "Enable thinking mode"
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
required: ["prompt"]
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
summarize: {
|
|
59
|
+
name: "gerbil_summarize",
|
|
60
|
+
description: "Summarize content",
|
|
61
|
+
inputSchema: {
|
|
62
|
+
type: "object",
|
|
63
|
+
properties: {
|
|
64
|
+
content: {
|
|
65
|
+
type: "string",
|
|
66
|
+
description: "Content to summarize"
|
|
67
|
+
},
|
|
68
|
+
length: {
|
|
69
|
+
type: "string",
|
|
70
|
+
enum: [
|
|
71
|
+
"short",
|
|
72
|
+
"medium",
|
|
73
|
+
"long"
|
|
74
|
+
]
|
|
75
|
+
},
|
|
76
|
+
format: {
|
|
77
|
+
type: "string",
|
|
78
|
+
enum: ["paragraph", "bullets"]
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
required: ["content"]
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
explain: {
|
|
85
|
+
name: "gerbil_explain",
|
|
86
|
+
description: "Explain code or concepts",
|
|
87
|
+
inputSchema: {
|
|
88
|
+
type: "object",
|
|
89
|
+
properties: {
|
|
90
|
+
content: {
|
|
91
|
+
type: "string",
|
|
92
|
+
description: "Code or concept to explain"
|
|
93
|
+
},
|
|
94
|
+
level: {
|
|
95
|
+
type: "string",
|
|
96
|
+
enum: [
|
|
97
|
+
"beginner",
|
|
98
|
+
"intermediate",
|
|
99
|
+
"expert"
|
|
100
|
+
]
|
|
101
|
+
},
|
|
102
|
+
language: {
|
|
103
|
+
type: "string",
|
|
104
|
+
description: "Programming language"
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
required: ["content"]
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
review: {
|
|
111
|
+
name: "gerbil_review",
|
|
112
|
+
description: "Review code for issues",
|
|
113
|
+
inputSchema: {
|
|
114
|
+
type: "object",
|
|
115
|
+
properties: {
|
|
116
|
+
code: {
|
|
117
|
+
type: "string",
|
|
118
|
+
description: "Code to review"
|
|
119
|
+
},
|
|
120
|
+
focus: {
|
|
121
|
+
type: "array",
|
|
122
|
+
items: {
|
|
123
|
+
type: "string",
|
|
124
|
+
enum: [
|
|
125
|
+
"security",
|
|
126
|
+
"performance",
|
|
127
|
+
"style",
|
|
128
|
+
"bugs"
|
|
129
|
+
]
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
},
|
|
133
|
+
required: ["code"]
|
|
134
|
+
}
|
|
135
|
+
},
|
|
136
|
+
commit: {
|
|
137
|
+
name: "gerbil_commit",
|
|
138
|
+
description: "Generate a commit message from a diff",
|
|
139
|
+
inputSchema: {
|
|
140
|
+
type: "object",
|
|
141
|
+
properties: {
|
|
142
|
+
diff: {
|
|
143
|
+
type: "string",
|
|
144
|
+
description: "Git diff"
|
|
145
|
+
},
|
|
146
|
+
type: {
|
|
147
|
+
type: "string",
|
|
148
|
+
enum: [
|
|
149
|
+
"conventional",
|
|
150
|
+
"simple",
|
|
151
|
+
"detailed"
|
|
152
|
+
]
|
|
153
|
+
}
|
|
154
|
+
},
|
|
155
|
+
required: ["diff"]
|
|
156
|
+
}
|
|
157
|
+
},
|
|
158
|
+
translate: {
|
|
159
|
+
name: "gerbil_translate",
|
|
160
|
+
description: "Translate text",
|
|
161
|
+
inputSchema: {
|
|
162
|
+
type: "object",
|
|
163
|
+
properties: {
|
|
164
|
+
text: {
|
|
165
|
+
type: "string",
|
|
166
|
+
description: "Text to translate"
|
|
167
|
+
},
|
|
168
|
+
to: {
|
|
169
|
+
type: "string",
|
|
170
|
+
description: "Target language"
|
|
171
|
+
},
|
|
172
|
+
from: {
|
|
173
|
+
type: "string",
|
|
174
|
+
description: "Source language (optional)"
|
|
175
|
+
}
|
|
176
|
+
},
|
|
177
|
+
required: ["text", "to"]
|
|
178
|
+
}
|
|
179
|
+
},
|
|
180
|
+
embed: {
|
|
181
|
+
name: "gerbil_embed",
|
|
182
|
+
description: "Generate embeddings for text",
|
|
183
|
+
inputSchema: {
|
|
184
|
+
type: "object",
|
|
185
|
+
properties: { text: {
|
|
186
|
+
type: "string",
|
|
187
|
+
description: "Text to embed"
|
|
188
|
+
} },
|
|
189
|
+
required: ["text"]
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
/**
|
|
194
|
+
* Create MCP server
|
|
195
|
+
*/
|
|
196
|
+
async function createMCPServer(options = {}) {
|
|
197
|
+
const g = new Gerbil(options);
|
|
198
|
+
await g.loadModel(options.model || "qwen3-0.6b");
|
|
199
|
+
const enabledTools = options.tools || Object.keys(TOOL_DEFINITIONS);
|
|
200
|
+
const handlers = {
|
|
201
|
+
gerbil_generate: async (args) => {
|
|
202
|
+
const result = await g.generate(args.prompt, {
|
|
203
|
+
maxTokens: args.maxTokens,
|
|
204
|
+
temperature: args.temperature,
|
|
205
|
+
system: args.system,
|
|
206
|
+
thinking: args.thinking
|
|
207
|
+
});
|
|
208
|
+
return { content: [{
|
|
209
|
+
type: "text",
|
|
210
|
+
text: result.thinking ? `Thinking: ${result.thinking}\n\nAnswer: ${result.text}` : result.text
|
|
211
|
+
}] };
|
|
212
|
+
},
|
|
213
|
+
gerbil_summarize: async (args) => {
|
|
214
|
+
return { content: [{
|
|
215
|
+
type: "text",
|
|
216
|
+
text: await summarize({
|
|
217
|
+
content: args.content,
|
|
218
|
+
length: args.length,
|
|
219
|
+
format: args.format
|
|
220
|
+
})
|
|
221
|
+
}] };
|
|
222
|
+
},
|
|
223
|
+
gerbil_explain: async (args) => {
|
|
224
|
+
return { content: [{
|
|
225
|
+
type: "text",
|
|
226
|
+
text: await explain({
|
|
227
|
+
content: args.content,
|
|
228
|
+
level: args.level,
|
|
229
|
+
language: args.language
|
|
230
|
+
})
|
|
231
|
+
}] };
|
|
232
|
+
},
|
|
233
|
+
gerbil_review: async (args) => {
|
|
234
|
+
return { content: [{
|
|
235
|
+
type: "text",
|
|
236
|
+
text: await review({
|
|
237
|
+
code: args.code,
|
|
238
|
+
focus: args.focus
|
|
239
|
+
})
|
|
240
|
+
}] };
|
|
241
|
+
},
|
|
242
|
+
gerbil_commit: async (args) => {
|
|
243
|
+
return { content: [{
|
|
244
|
+
type: "text",
|
|
245
|
+
text: await commit({
|
|
246
|
+
diff: args.diff,
|
|
247
|
+
type: args.type
|
|
248
|
+
})
|
|
249
|
+
}] };
|
|
250
|
+
},
|
|
251
|
+
gerbil_translate: async (args) => {
|
|
252
|
+
return { content: [{
|
|
253
|
+
type: "text",
|
|
254
|
+
text: await translate({
|
|
255
|
+
text: args.text,
|
|
256
|
+
to: args.to,
|
|
257
|
+
from: args.from
|
|
258
|
+
})
|
|
259
|
+
}] };
|
|
260
|
+
},
|
|
261
|
+
gerbil_embed: async (args) => {
|
|
262
|
+
const result = await g.embed(args.text);
|
|
263
|
+
return { content: [{
|
|
264
|
+
type: "text",
|
|
265
|
+
text: JSON.stringify({
|
|
266
|
+
vector: result.vector.slice(0, 10),
|
|
267
|
+
dimensions: result.vector.length
|
|
268
|
+
})
|
|
269
|
+
}] };
|
|
270
|
+
}
|
|
271
|
+
};
|
|
272
|
+
return {
|
|
273
|
+
info: {
|
|
274
|
+
name: "gerbil",
|
|
275
|
+
version: "1.0.0",
|
|
276
|
+
description: "Local LLM inference via Gerbil"
|
|
277
|
+
},
|
|
278
|
+
listTools: () => enabledTools.filter((t) => TOOL_DEFINITIONS[t]).map((t) => TOOL_DEFINITIONS[t]),
|
|
279
|
+
callTool: async (name, args) => {
|
|
280
|
+
const handler = handlers[name];
|
|
281
|
+
if (!handler) throw new Error(`Unknown tool: ${name}`);
|
|
282
|
+
return handler(args);
|
|
283
|
+
},
|
|
284
|
+
gerbil: g
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* Start MCP server with stdio transport
|
|
289
|
+
*/
|
|
290
|
+
async function startMCPServer(options = {}) {
|
|
291
|
+
const server = await createMCPServer(options);
|
|
292
|
+
const rl = (await import("readline")).createInterface({
|
|
293
|
+
input: process.stdin,
|
|
294
|
+
output: process.stdout,
|
|
295
|
+
terminal: false
|
|
296
|
+
});
|
|
297
|
+
console.error("🐹 Gerbil MCP Server");
|
|
298
|
+
console.error(` Model: ${options.model || "qwen3-0.6b"}`);
|
|
299
|
+
console.error(` Tools: ${server.listTools().map((t) => t.name).join(", ")}`);
|
|
300
|
+
console.error(" Ready for connections...");
|
|
301
|
+
rl.on("line", async (line) => {
|
|
302
|
+
try {
|
|
303
|
+
const request = JSON.parse(line);
|
|
304
|
+
let response;
|
|
305
|
+
switch (request.method) {
|
|
306
|
+
case "initialize":
|
|
307
|
+
response = {
|
|
308
|
+
protocolVersion: "2024-11-05",
|
|
309
|
+
serverInfo: server.info,
|
|
310
|
+
capabilities: { tools: {} }
|
|
311
|
+
};
|
|
312
|
+
break;
|
|
313
|
+
case "tools/list":
|
|
314
|
+
response = { tools: server.listTools() };
|
|
315
|
+
break;
|
|
316
|
+
case "tools/call":
|
|
317
|
+
response = await server.callTool(request.params.name, request.params.arguments);
|
|
318
|
+
break;
|
|
319
|
+
default: response = { error: {
|
|
320
|
+
code: -32601,
|
|
321
|
+
message: "Method not found"
|
|
322
|
+
} };
|
|
323
|
+
}
|
|
324
|
+
console.log(JSON.stringify({
|
|
325
|
+
jsonrpc: "2.0",
|
|
326
|
+
id: request.id,
|
|
327
|
+
result: response
|
|
328
|
+
}));
|
|
329
|
+
} catch (error) {
|
|
330
|
+
console.log(JSON.stringify({
|
|
331
|
+
jsonrpc: "2.0",
|
|
332
|
+
id: null,
|
|
333
|
+
error: {
|
|
334
|
+
code: -32700,
|
|
335
|
+
message: String(error)
|
|
336
|
+
}
|
|
337
|
+
}));
|
|
338
|
+
}
|
|
339
|
+
});
|
|
340
|
+
}
|
|
341
|
+
var mcp_default = {
|
|
342
|
+
createMCPServer,
|
|
343
|
+
startMCPServer
|
|
344
|
+
};
|
|
345
|
+
|
|
346
|
+
//#endregion
|
|
347
|
+
export { mcp_default as n, startMCPServer as r, createMCPServer as t };
|
|
348
|
+
//# sourceMappingURL=mcp-R8kRLIKb.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-R8kRLIKb.mjs","names":["handlers: Record<string, (args: any) => Promise<any>>","skills.summarize","skills.explain","skills.review","skills.commit","skills.translate","response: any"],"sources":["../src/integrations/mcp.ts"],"sourcesContent":["/**\n * Gerbil MCP Server\n *\n * Model Context Protocol server for Claude Desktop, Cursor, etc.\n *\n * @example\n * ```bash\n * gerbil serve --mcp\n * ```\n *\n * @example Claude Desktop config\n * ```json\n * {\n * \"mcpServers\": {\n * \"gerbil\": {\n * \"command\": \"npx\",\n * \"args\": [\"-y\", \"gerbil\", \"serve\", \"--mcp\"]\n * }\n * }\n * }\n * ```\n */\n\nimport { Gerbil } from \"../core/gerbil.js\";\nimport type { GerbilConfig } from \"../core/types.js\";\nimport * as skills from \"../skills/index.js\";\n\nexport interface MCPServerOptions extends GerbilConfig {\n /** Port for HTTP transport (default: stdio) */\n port?: number;\n\n /** Tools to expose */\n tools?: string[];\n}\n\n// Tool definitions\nconst TOOL_DEFINITIONS = {\n generate: {\n name: \"gerbil_generate\",\n description: \"Generate text using a local LLM\",\n inputSchema: {\n type: \"object\",\n properties: {\n prompt: { type: \"string\", description: \"The prompt to generate from\" },\n maxTokens: { type: \"number\", description: \"Maximum tokens to generate\" },\n temperature: { type: \"number\", description: \"Sampling temperature (0-2)\" },\n system: { type: \"string\", description: \"System prompt\" },\n thinking: { type: \"boolean\", description: \"Enable thinking mode\" },\n },\n required: [\"prompt\"],\n },\n },\n summarize: {\n name: \"gerbil_summarize\",\n description: \"Summarize content\",\n inputSchema: {\n type: \"object\",\n properties: {\n content: { type: \"string\", description: \"Content to summarize\" },\n length: { type: \"string\", enum: [\"short\", \"medium\", \"long\"] },\n format: { type: \"string\", enum: [\"paragraph\", \"bullets\"] },\n },\n required: [\"content\"],\n },\n },\n explain: {\n name: \"gerbil_explain\",\n description: \"Explain code or concepts\",\n inputSchema: {\n type: \"object\",\n properties: {\n content: { type: \"string\", description: \"Code or concept to explain\" },\n level: { type: \"string\", enum: [\"beginner\", \"intermediate\", \"expert\"] },\n language: { type: \"string\", description: \"Programming language\" },\n },\n required: [\"content\"],\n },\n },\n review: {\n name: \"gerbil_review\",\n description: \"Review code for issues\",\n inputSchema: {\n type: \"object\",\n properties: {\n code: { type: \"string\", description: \"Code to review\" },\n focus: {\n type: \"array\",\n items: { type: \"string\", enum: [\"security\", \"performance\", \"style\", \"bugs\"] },\n },\n },\n required: [\"code\"],\n },\n },\n commit: {\n name: \"gerbil_commit\",\n description: \"Generate a commit message from a diff\",\n inputSchema: {\n type: \"object\",\n properties: {\n diff: { type: \"string\", description: \"Git diff\" },\n type: { type: \"string\", enum: [\"conventional\", \"simple\", \"detailed\"] },\n },\n required: [\"diff\"],\n },\n },\n translate: {\n name: \"gerbil_translate\",\n description: \"Translate text\",\n inputSchema: {\n type: \"object\",\n properties: {\n text: { type: \"string\", description: \"Text to translate\" },\n to: { type: \"string\", description: \"Target language\" },\n from: { type: \"string\", description: \"Source language (optional)\" },\n },\n required: [\"text\", \"to\"],\n },\n },\n embed: {\n name: \"gerbil_embed\",\n description: \"Generate embeddings for text\",\n inputSchema: {\n type: \"object\",\n properties: {\n text: { type: \"string\", description: \"Text to embed\" },\n },\n required: [\"text\"],\n },\n },\n};\n\n/**\n * Create MCP server\n */\nexport async function createMCPServer(options: MCPServerOptions = {}) {\n const g = new Gerbil(options);\n\n // Load model\n await g.loadModel(options.model || \"qwen3-0.6b\");\n\n // Determine which tools to expose\n const enabledTools = options.tools || Object.keys(TOOL_DEFINITIONS);\n\n // Tool handlers\n const handlers: Record<string, (args: any) => Promise<any>> = {\n gerbil_generate: async (args) => {\n const result = await g.generate(args.prompt, {\n maxTokens: args.maxTokens,\n temperature: args.temperature,\n system: args.system,\n thinking: args.thinking,\n });\n return {\n content: [\n {\n type: \"text\",\n text: result.thinking\n ? `Thinking: ${result.thinking}\\n\\nAnswer: ${result.text}`\n : result.text,\n },\n ],\n };\n },\n\n gerbil_summarize: async (args) => {\n const summary = await skills.summarize({\n content: args.content,\n length: args.length,\n format: args.format,\n });\n return { content: [{ type: \"text\", text: summary }] };\n },\n\n gerbil_explain: async (args) => {\n const explanation = await skills.explain({\n content: args.content,\n level: args.level,\n language: args.language,\n });\n return { content: [{ type: \"text\", text: explanation }] };\n },\n\n gerbil_review: async (args) => {\n const reviewResult = await skills.review({\n code: args.code,\n focus: args.focus,\n });\n return { content: [{ type: \"text\", text: reviewResult }] };\n },\n\n gerbil_commit: async (args) => {\n const message = await skills.commit({\n diff: args.diff,\n type: args.type,\n });\n return { content: [{ type: \"text\", text: message }] };\n },\n\n gerbil_translate: async (args) => {\n const translated = await skills.translate({\n text: args.text,\n to: args.to,\n from: args.from,\n });\n return { content: [{ type: \"text\", text: translated }] };\n },\n\n gerbil_embed: async (args) => {\n const result = await g.embed(args.text);\n return {\n content: [\n {\n type: \"text\",\n text: JSON.stringify({\n vector: result.vector.slice(0, 10),\n dimensions: result.vector.length,\n }),\n },\n ],\n };\n },\n };\n\n return {\n // Server info\n info: {\n name: \"gerbil\",\n version: \"1.0.0\",\n description: \"Local LLM inference via Gerbil\",\n },\n\n // List available tools\n listTools: () =>\n enabledTools\n .filter((t) => TOOL_DEFINITIONS[t as keyof typeof TOOL_DEFINITIONS])\n .map((t) => TOOL_DEFINITIONS[t as keyof typeof TOOL_DEFINITIONS]),\n\n // Call a tool\n callTool: async (name: string, args: any) => {\n const handler = handlers[name];\n if (!handler) {\n throw new Error(`Unknown tool: ${name}`);\n }\n return handler(args);\n },\n\n // Get Gerbil instance\n gerbil: g,\n };\n}\n\n/**\n * Start MCP server with stdio transport\n */\nexport async function startMCPServer(options: MCPServerOptions = {}) {\n const server = await createMCPServer(options);\n\n // Simple stdio protocol handler\n const readline = await import(\"readline\");\n const rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false,\n });\n\n console.error(\"🐹 Gerbil MCP Server\");\n console.error(` Model: ${options.model || \"qwen3-0.6b\"}`);\n console.error(\n ` Tools: ${server\n .listTools()\n .map((t) => t.name)\n .join(\", \")}`,\n );\n console.error(\" Ready for connections...\");\n\n rl.on(\"line\", async (line) => {\n try {\n const request = JSON.parse(line);\n\n let response: any;\n\n switch (request.method) {\n case \"initialize\":\n response = {\n protocolVersion: \"2024-11-05\",\n serverInfo: server.info,\n capabilities: {\n tools: {},\n },\n };\n break;\n\n case \"tools/list\":\n response = { tools: server.listTools() };\n break;\n\n case \"tools/call\":\n response = await server.callTool(request.params.name, request.params.arguments);\n break;\n\n default:\n response = { error: { code: -32_601, message: \"Method not found\" } };\n }\n\n console.log(JSON.stringify({ jsonrpc: \"2.0\", id: request.id, result: response }));\n } catch (error) {\n console.log(\n JSON.stringify({\n jsonrpc: \"2.0\",\n id: null,\n error: { code: -32_700, message: String(error) },\n }),\n );\n }\n });\n}\n\nexport default { createMCPServer, startMCPServer };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAoCA,MAAM,mBAAmB;CACvB,UAAU;EACR,MAAM;EACN,aAAa;EACb,aAAa;GACX,MAAM;GACN,YAAY;IACV,QAAQ;KAAE,MAAM;KAAU,aAAa;KAA+B;IACtE,WAAW;KAAE,MAAM;KAAU,aAAa;KAA8B;IACxE,aAAa;KAAE,MAAM;KAAU,aAAa;KAA8B;IAC1E,QAAQ;KAAE,MAAM;KAAU,aAAa;KAAiB;IACxD,UAAU;KAAE,MAAM;KAAW,aAAa;KAAwB;IACnE;GACD,UAAU,CAAC,SAAS;GACrB;EACF;CACD,WAAW;EACT,MAAM;EACN,aAAa;EACb,aAAa;GACX,MAAM;GACN,YAAY;IACV,SAAS;KAAE,MAAM;KAAU,aAAa;KAAwB;IAChE,QAAQ;KAAE,MAAM;KAAU,MAAM;MAAC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