{"_rev":"8-0df92561f9417771cb5f28eaa8aacd1d","time":{"created":"2025-08-02T17:44:55.081Z","modified":"2025-08-02T17:44:55.682Z","1.0.0":"2025-08-02T16:51:10.898Z","1.0.1":"2025-08-02T17:15:55.746Z","1.0.2":"2025-08-02T17:21:13.195Z","1.0.3":"2025-08-02T17:25:28.260Z","1.0.4":"2025-08-02T17:28:04.111Z","1.0.5":"2025-08-02T17:44:55.379Z"},"_id":"@4ourlab/mcp-client-gemini","name":"@4ourlab/mcp-client-gemini","dist-tags":{"latest":"1.0.5"},"versions":{"1.0.5":{"name":"@4ourlab/mcp-client-gemini","version":"1.0.5","description":"MCP (Model Context Protocol) implementation for Gemini models","main":"build/src/index.js","types":"build/src/index.d.ts","exports":{".":{"import":"./build/src/index.js","require":"./build/src/index.js"},"./examples/*":"./build/examples/*"},"scripts":{"build":"tsc && cp -r examples build/ && node -e \"require('fs').chmodSync('build/src/index.js', '755')\"","dev":"tsc --watch"},"keywords":["mcp","model-context-protocol","gemini","ai","google-generative-ai","typescript","nodejs"],"author":{"name":"Billston"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/4ourlab/mcp-client-gemini.git"},"homepage":"https://github.com/4ourlab/mcp-client-gemini","bugs":{"url":"https://github.com/4ourlab/mcp-client-gemini/issues"},"dependencies":{"@google/generative-ai":"^0.21.0","@modelcontextprotocol/sdk":"^1.17.0"},"devDependencies":{"@types/node":"^22.16.5","typescript":"^5.8.3"},"_id":"@4ourlab/mcp-client-gemini@1.0.5","_nodeVersion":"22.15.0","_npmVersion":"11.4.2","dist":{"integrity":"sha512-xFxD+ULIcikPq9Wv79qX1Mv3iEEijU/fcQvYo4JR1kbleHBZ2Uc9PBKsl/EDVMrKogp/Q3K/WQCKenEwKi9IYA==","shasum":"0eced85cadbd6ff3076b26483bf4b020bd23242c","tarball":"https://registry.npmjs.org/@4ourlab/mcp-client-gemini/-/mcp-client-gemini-1.0.5.tgz","fileCount":18,"unpackedSize":30154,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQC8RXb32+9ZX5phKW45+apj6j8/7lDkfWSSrcXOAmiQeQIgUbQyuiFu0eGbp6joCGVf+617MFNvI/FiF0j8FVTs+Qs="}]},"_npmUser":{"name":"billston","email":"billston.apaza@gmail.com"},"directories":{},"maintainers":[{"name":"billston","email":"billston.apaza@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/mcp-client-gemini_1.0.5_1754156695182_0.655372427609026"},"_hasShrinkwrap":false}},"maintainers":[{"name":"billston","email":"billston.apaza@gmail.com"}],"description":"MCP (Model Context Protocol) implementation for Gemini models","homepage":"https://github.com/4ourlab/mcp-client-gemini","keywords":["mcp","model-context-protocol","gemini","ai","google-generative-ai","typescript","nodejs"],"repository":{"type":"git","url":"git+https://github.com/4ourlab/mcp-client-gemini.git"},"author":{"name":"Billston"},"bugs":{"url":"https://github.com/4ourlab/mcp-client-gemini/issues"},"license":"MIT","readme":"# @4ourlab/mcp-client-gemini\n\nA MCP (Model Context Protocol) implementation for Gemini models that allows connecting and using multiple MCP servers through Google Generative AI API.\n\nThis implementation is based on the official [Model Context Protocol documentation](https://modelcontextprotocol.io/).\n\n## Features\n\n- 🔗 Connect to multiple MCP servers\n- 🤖 Integration with Google Generative AI (Gemini)\n- 📝 Support for custom system prompts\n- 🔧 Complete TypeScript interface\n- 🛠️ Included usage examples\n\n## Supported Models\n\nThis client has been tested with the following Gemini models:\n- `gemini-1.5-pro`\n- `gemini-2.5-pro`\n- `gemini-2.5-flash`\n- `gemini-2.5-flash-lite`\n\n## Installation\n\n```bash\nnpm install @4ourlab/mcp-client-gemini\n```\n\n## Basic Usage\n\n```javascript\nimport { MCPClient } from '@4ourlab/mcp-client-gemini';\n\nconst mcpClient = new MCPClient(\n    \"your-gemini-api-key\",\n    \"gemini-1.5-pro\", // or any other supported model\n    \"./path/to/mcpServer.json\",\n    \"Optional system prompt\"\n);\n\ntry {\n    await mcpClient.connectToServers();\n    const response = await mcpClient.processQuery(\"Your query here\");\n    console.log(response);\n} finally {\n    await mcpClient.cleanup();\n}\n```\n\n## MCP Server Configuration\n\nCreate an `mcpServer.json` file with your server configuration:\n\n```json\n{\n    \"mcpServers\": {\n        \"weather\": {\n            \"command\": \"node\",\n            \"args\": [\"/path/to/mcpserver-weather/build/index.js\"]\n        },\n        \"mssql\": {\n            \"command\": \"dotnet\",\n            \"args\": [\"run\", \"--project\", \"/path/to/mcpserver-mssql.csproj\"]\n        }\n    }\n}\n```\n\n## Examples\n\n### Example 1: Interactive Chat\n\n```javascript\nimport { MCPClient } from '@4ourlab/mcp-client-gemini';\n\nasync function main() {\n    const mcpClient = new MCPClient(\n        \"your-api-key\",\n        \"gemini-1.5-pro\",\n        \"./examples/mcpServer.json\",\n        \"\"\n    );\n\n    try {\n        await mcpClient.connectToServers();\n        await mcpClient.chatLoop();\n    } finally {\n        await mcpClient.cleanup();\n        process.exit(0);\n    }\n}\n\nmain().catch(console.error);\n```\n\n### Example 2: Query Processing with JSON Response\n\n```javascript\nimport { MCPClient } from '@4ourlab/mcp-client-gemini';\n\nasync function main() {\n    const systemPrompt = `\n        You are an intelligent assistant with access to tools. Use your knowledge and available tools to solve problems proactively. \n\n        For final responses, use JSON format:\n        {\n            \"header\": {\n                \"success\": true|false,\n                \"usedTools\": true|false,\n                \"message\": \"error description when success=false\"\n            },\n            \"result\": {\n                \"your response content here\"\n            }\n        }`;\n\n    const mcpClient = new MCPClient(\n        \"your-api-key\",\n        \"gemini-2.5-flash\",\n        \"./examples/mcpServer.json\",\n        systemPrompt\n    );\n\n    try {\n        await mcpClient.connectToServers();\n        const response = await mcpClient.processQuery(\"What's the weather in Sacramento?\");\n        console.log(\"\\nResponse:\\n\" + cleanResponse(response));\n    } catch (error) {\n        console.error(\"Error in main:\", error);\n    } finally {\n        await mcpClient.cleanup();\n        process.exit(0);\n    }\n}\n\nfunction cleanResponse(response) {\n    const content = response;\n    const json = content.match(/```json\\n([\\s\\S]*?)\\n```/)?.[1] || content.match(/\\{[\\s\\S]*\\}/)?.[0];\n    return json || response;\n}\n\nmain().catch(console.error);\n```\n\n## API\n\n### MCPClient\n\n#### Constructor\n```javascript\nnew MCPClient(apiKey: string, model: string, serverConfigPath: string, systemPrompt?: string)\n```\n\n#### Methods\n\n- `connectToServers()`: Connect to all configured MCP servers\n- `processQuery(query: string)`: Process a query using available servers\n- `chatLoop()`: Start an interactive chat loop\n- `cleanup()`: Clean up connections and resources\n\n## Dependencies\n\n- `@google/generative-ai`: Official Google Generative AI client\n- `@modelcontextprotocol/sdk`: Official MCP SDK\n\n## License\n\nMIT ","readmeFilename":"README.md"}