{"_id":"@4ourlab/mcp-client-claude","name":"@4ourlab/mcp-client-claude","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@4ourlab/mcp-client-claude","version":"1.0.0","description":"MCP (Model Context Protocol) implementation for Claude 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","claude","ai","anthropic","typescript","nodejs"],"author":{"name":"Billston"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/4ourlab/mcp-client-claude.git"},"homepage":"https://github.com/4ourlab/mcp-client-claude","bugs":{"url":"https://github.com/4ourlab/mcp-client-claude/issues"},"dependencies":{"@modelcontextprotocol/sdk":"^1.17.0","@anthropic-ai/sdk":"^0.57.0"},"devDependencies":{"@types/node":"^22.16.5","typescript":"^5.8.3"},"_id":"@4ourlab/mcp-client-claude@1.0.0","_nodeVersion":"22.15.0","_npmVersion":"11.4.2","dist":{"integrity":"sha512-qqI6Zlbd07rK2Z4YzGkFxhAzKITJg90rQeDB5ph6VYs2F+BVsf1om/fF1UgLEFLJbPryd0vWo4uwXin+kR+m7A==","shasum":"b44dae23f4335eba139d9dfd6effa30dce29befc","tarball":"https://registry.npmjs.org/@4ourlab/mcp-client-claude/-/mcp-client-claude-1.0.0.tgz","fileCount":18,"unpackedSize":23413,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQC5mCqhJe5j1SdRQZxlxEjaNkprEFAEoRjZzM+VeFtH1wIhAIJ0d/wnJLFhcI6Obd6LsfiHeFot6YyWVpmKz12tM5Jg"}]},"_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-claude_1.0.0_1754677247334_0.5768123822445907"},"_hasShrinkwrap":false}},"time":{"created":"2025-08-08T18:20:47.099Z","1.0.0":"2025-08-08T18:20:47.500Z","modified":"2025-08-08T18:20:48.008Z"},"maintainers":[{"name":"billston","email":"billston.apaza@gmail.com"}],"description":"MCP (Model Context Protocol) implementation for Claude models","homepage":"https://github.com/4ourlab/mcp-client-claude","keywords":["mcp","model-context-protocol","claude","ai","anthropic","typescript","nodejs"],"repository":{"type":"git","url":"git+https://github.com/4ourlab/mcp-client-claude.git"},"author":{"name":"Billston"},"bugs":{"url":"https://github.com/4ourlab/mcp-client-claude/issues"},"license":"MIT","readme":"# @4ourlab/mcp-client-claude\n\nA MCP (Model Context Protocol) implementation for Claude models that allows connecting and using multiple MCP servers through Anthropic's Claude 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 Anthropic Claude API\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 Claude models:\n- `claude-3-5-sonnet-20241022`\n- `claude-sonnet-4-20250514`\n\n## Installation\n\n```bash\nnpm install @4ourlab/mcp-client-claude\n```\n\n## Basic Usage\n\n```javascript\nimport { MCPClient } from '@4ourlab/mcp-client-claude';\n\nconst mcpClient = new MCPClient(\n    \"your-anthropic-api-key\",\n    \"claude-3-5-sonnet-20241022\", // 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-claude';\n\nasync function main() {\n    const mcpClient = new MCPClient(\n        \"your-api-key\",\n        \"claude-3-5-sonnet-20241022\",\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-claude';\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        \"claude-3-5-sonnet-20241022\",\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- `@anthropic-ai/sdk`: Official Anthropic Claude API client\n- `@modelcontextprotocol/sdk`: Official MCP SDK\n\n## Development\n\n### Building the project\n\n```bash\nnpm run build\n```\n\n### Development mode\n\n```bash\nnpm run dev\n```\n\n## License\n\nMIT ","readmeFilename":"README.md","_rev":"1-379b0d3385fadd42a7107c05096af340"}