{"_id":"@imlewc/metabase-server","name":"@imlewc/metabase-server","dist-tags":{"latest":"0.1.0"},"versions":{"0.1.0":{"name":"@imlewc/metabase-server","version":"0.1.0","description":"MCP server for interacting with Metabase - provides AI assistants with tools to query, create, and manage dashboards, cards, and databases","type":"module","bin":{"metabase-server":"build/index.js"},"scripts":{"build":"tsc && node -e \"require('fs').chmodSync('build/index.js', '755')\" && mkdir -p dist && cp build/*.js dist/","prepare":"npm run build","watch":"tsc --watch","inspector":"npx @modelcontextprotocol/inspector build/index.js"},"dependencies":{"@modelcontextprotocol/sdk":"^1.25.2","abort-controller":"^3.0.0","axios":"^1.8.2"},"devDependencies":{"@types/axios":"^0.14.4","@types/node":"^20.17.22","typescript":"^5.3.3"},"_id":"@imlewc/metabase-server@0.1.0","gitHead":"8fe56a6e7156c3c1aa7f0a7e7cb5dbd60541cb88","_nodeVersion":"22.22.0","_npmVersion":"10.9.4","dist":{"integrity":"sha512-q3bW+e5Y7ByQQBbO/x8J/IZIm9RZerGluzCNdwsDnJzA7WY5b8or6N8RvcnO8PUHdo1BaX6SNjH65VctecmPYA==","shasum":"66c0b1e9c0dea90a6ca41ea837af2f902e310e2c","tarball":"https://registry.npmjs.org/@imlewc/metabase-server/-/metabase-server-0.1.0.tgz","fileCount":5,"unpackedSize":92458,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIEgf1qarG8KMSCmtnF4wXvUqXOJ9b7uQPmdmv5QR2RsXAiEAoli+XrDJgRu4FxeElMJdt4cXjR9ji7QvTdfEVhcR94k="}]},"_npmUser":{"name":"imlewc","email":"imlewc@126.com"},"directories":{},"maintainers":[{"name":"imlewc","email":"imlewc@126.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/metabase-server_0.1.0_1772174579866_0.3948934226583849"},"_hasShrinkwrap":false}},"time":{"created":"2026-02-27T06:42:59.772Z","0.1.0":"2026-02-27T06:43:00.007Z","modified":"2026-02-27T06:43:00.208Z"},"maintainers":[{"name":"imlewc","email":"imlewc@126.com"}],"description":"MCP server for interacting with Metabase - provides AI assistants with tools to query, create, and manage dashboards, cards, and databases","readme":"[![MseeP.ai Security Assessment Badge](https://mseep.net/pr/imlewc-metabase-server-badge.png)](https://mseep.ai/app/imlewc-metabase-server)\n\n# metabase-server MCP Server\n\n[![smithery badge](https://smithery.ai/badge/@imlewc/metabase-server)](https://smithery.ai/server/@imlewc/metabase-server)\n\nA Model Context Protocol server for Metabase integration.\n\nThis is a TypeScript-based MCP server that implements integration with Metabase API. It allows AI assistants to interact with Metabase, providing access to:\n\n- Dashboards, questions/cards, and databases as resources\n- Tools for listing and executing Metabase queries\n- Ability to view and interact with Metabase data\n\n## Features\n\n### Resources\n- List and access Metabase resources via `metabase://` URIs\n- Access dashboards, cards/questions, and databases\n- JSON content type for structured data access\n\n### Tools\n- `list_dashboards` - List all dashboards in Metabase\n- `list_cards` - List all questions/cards in Metabase\n- `list_databases` - List all databases in Metabase\n- `execute_card` - Execute a Metabase question/card and get results\n- `get_dashboard_cards` - Get all cards in a dashboard\n- `execute_query` - Execute a SQL query against a Metabase database\n\n## Configuration\n\nBefore running the server, you need to set environment variables for authentication. The server supports two methods:\n\n1.  **API Key (Preferred):**\n    *   `METABASE_URL`: The URL of your Metabase instance (e.g., `https://your-metabase-instance.com`).\n    *   `METABASE_API_KEY`: Your Metabase API key.\n\n2.  **Username/Password (Fallback):**\n    *   `METABASE_URL`: The URL of your Metabase instance.\n    *   `METABASE_USERNAME`: Your Metabase username.\n    *   `METABASE_PASSWORD`: Your Metabase password.\n\nThe server will first check for `METABASE_API_KEY`. If it's set, API key authentication will be used. If `METABASE_API_KEY` is not set, the server will fall back to using `METABASE_USERNAME` and `METABASE_PASSWORD`. You must provide credentials for at least one of these methods.\n\n**Example setup:**\n\nUsing API Key:\n```bash\n# Required environment variables\nexport METABASE_URL=https://your-metabase-instance.com\nexport METABASE_API_KEY=your_metabase_api_key\n```\n\nOr, using Username/Password:\n```bash\n# Required environment variables\nexport METABASE_URL=https://your-metabase-instance.com\nexport METABASE_USERNAME=your_username\nexport METABASE_PASSWORD=your_password\n```\nYou can set these environment variables in your shell profile or use a `.env` file with a package like `dotenv`.\n\n## Development\n\nInstall dependencies:\n```bash\nnpm install\n```\n\nBuild the server:\n```bash\nnpm run build\n```\n\nFor development with auto-rebuild:\n```bash\nnpm run watch\n```\n\n## Installation\n```bash\n# Oneliner, suitable for CI environment\ngit clone https://github.com/imlewc/metabase-server.git && cd metabase-server && npm i && npm run build && npm link\n```\n\nTo use with Claude Desktop, add the server config:\n\nOn MacOS: `~/Library/Application Support/Claude/claude_desktop_config.json`\nOn Windows: `%APPDATA%/Claude/claude_desktop_config.json`\n\n```json\n{\n  \"mcpServers\": {\n    \"metabase-server\": {\n      \"command\": \"metabase-server\",\n      \"env\": {\n        \"METABASE_URL\": \"https://your-metabase-instance.com\",\n        // Use API Key (preferred)\n        \"METABASE_API_KEY\": \"your_metabase_api_key\"\n        // Or Username/Password (if API Key is not set)\n        // \"METABASE_USERNAME\": \"your_username\",\n        // \"METABASE_PASSWORD\": \"your_password\"\n      }\n    }\n  }\n}\n```\n\nNote: You can also set these environment variables in your system instead of in the config file if you prefer.\n\n### Installing via Smithery\n\nTo install metabase-server for Claude Desktop automatically via [Smithery](https://smithery.ai/server/@imlewc/metabase-server):\n\n```bash\nnpx -y @smithery/cli install @imlewc/metabase-server --client claude\n```\n\n### Debugging\n\nSince MCP servers communicate over stdio, debugging can be challenging. We recommend using the [MCP Inspector](https://github.com/modelcontextprotocol/inspector), which is available as a package script:\n\n```bash\nnpm run inspector\n```\n\nThe Inspector will provide a URL to access debugging tools in your browser.\n\n## Testing\n\nAfter configuring the environment variables as described in the \"Configuration\" section, you can manually test the server's authentication. The MCP Inspector (`npm run inspector`) is a useful tool for sending requests to the server.\n\n### 1. Testing with API Key Authentication\n\n1.  Set the `METABASE_URL` and `METABASE_API_KEY` environment variables with your Metabase instance URL and a valid API key.\n2.  Ensure `METABASE_USERNAME` and `METABASE_PASSWORD` are unset or leave them, as the API key should take precedence.\n3.  Start the server: `npm run build && node build/index.js` (or use your chosen method for running the server, like via Claude Desktop config).\n4.  Check the server logs. You should see a message indicating that it's using API key authentication (e.g., \"Using Metabase API Key for authentication.\").\n5.  Using an MCP client or the MCP Inspector, try calling a tool, for example, `tools/call` with `{\"name\": \"list_dashboards\"}`.\n6.  Verify that the tool call is successful and you receive the expected data.\n\n### 2. Testing with Username/Password Authentication (Fallback)\n\n1.  Ensure the `METABASE_API_KEY` environment variable is unset.\n2.  Set `METABASE_URL`, `METABASE_USERNAME`, and `METABASE_PASSWORD` with valid credentials for your Metabase instance.\n3.  Start the server.\n4.  Check the server logs. You should see a message indicating that it's using username/password authentication (e.g., \"Using Metabase username/password for authentication.\" followed by \"Authenticating with Metabase using username/password...\").\n5.  Using an MCP client or the MCP Inspector, try calling the `list_dashboards` tool.\n6.  Verify that the tool call is successful.\n\n### 3. Testing Authentication Failures\n\n*   **Invalid API Key:**\n    1.  Set `METABASE_URL` and an invalid `METABASE_API_KEY`. Ensure `METABASE_USERNAME` and `METABASE_PASSWORD` variables are unset.\n    2.  Start the server.\n    3.  Attempt to call a tool (e.g., `list_dashboards`). The tool call should fail, and the server logs might indicate an authentication error from Metabase (e.g., \"Metabase API error: Invalid X-API-Key\").\n*   **Invalid Username/Password:**\n    1.  Ensure `METABASE_API_KEY` is unset. Set `METABASE_URL` and invalid `METABASE_USERNAME`/`METABASE_PASSWORD`.\n    2.  Start the server.\n    3.  Attempt to call a tool. The tool call should fail due to failed session authentication. The server logs might show \"Authentication failed\" or \"Failed to authenticate with Metabase\".\n*   **Missing Credentials:**\n    1.  Unset `METABASE_API_KEY`, `METABASE_USERNAME`, and `METABASE_PASSWORD`. Set only `METABASE_URL`.\n    2.  Attempt to start the server.\n    3.  The server should fail to start and log an error message stating that authentication credentials (either API key or username/password) are required (e.g., \"Either (METABASE_URL and METABASE_API_KEY) or (METABASE_URL, METABASE_USERNAME, and METABASE_PASSWORD) environment variables are required\").\n","readmeFilename":"README.md","_rev":"1-f518f8e389db2dfb193a3480dbc99c4f"}