MCP Inspector
repository·main·Indexed 27 days ago
https://github.com/modelcontextprotocol/inspectorA developer tool for testing and debugging Model Context Protocol (MCP) servers. It features a React-based web UI and a Node.js proxy to interact with servers via stdio, SSE, or streamable-http transports. The tool includes a CLI mode for programmatic interaction, automation, and CI/CD, allowing developers to list tools, resources, and prompts or call specific tools directly from the command line.
What's inside @modelcontextprotocol/inspector
- The MCP Inspector is a developer tool designed for testing and debugging Model Context Protocol (MCP) servers. It provides an interactive environment to verify server capabilities and behavior.
Understand the MCP Inspector Architecture
mainThe MCP Inspector architecture consists of two primary components:
- MCP Inspector Client (MCPI): A React-based web UI that serves as the interactive interface for developers to test and debug servers.
- MCP Proxy (MCPP): A Node.js server that acts as a protocol bridge. It functions as both an MCP client (connecting to your MCP server) and an HTTP server (serving the web UI). This allows the browser-based UI to interact with MCP servers using various transport methods such as
stdio,SSE, orstreamable-http.
Inspect an MCP Server via npx
mainTo inspect a local MCP server implementation, pass the command used to start your server as arguments to
npx @modelcontextprotocol/inspector.Passing Arguments and Environment Variables
- Arguments only: Append arguments directly after the server command.
- Environment variables only: Use the
-eflag for each variable. - Both: Use
-efor environment variables and append arguments at the end. - Separation: Use
--to separate inspector flags from your server's own arguments.
Customizing Ports
You can customize the client and server ports using environment variables:
CLIENT_PORT=8080 SERVER_PORT=9000 npx @modelcontextprotocol/inspector <server-command>Quick Start the MCP Inspector UI
mainTo launch the MCP Inspector UI immediately, use
npx. The UI will be accessible athttp://localhost:6274by default.Requirements:
- Node.js:
^22.7.5
npx @modelcontextprotocol/inspector- Node.js:
Workflow: Bumping version for a release
mainFollow these steps to perform a full version bump and release cycle within the monorepo:
- Update the version: Run
npm run update-version <version>. - Verify consistency: Run
npm run check-versionto ensure no mismatches occurred. - Commit changes: Stage all files and commit with a version bump message.
- Tag the release: Create a git tag for the new version.
- Push: Push both the branch and the tags to the remote repository.
# Update to new version npm run update-version 0.15.0 # Verify everything is correct npm run check-version # Commit the changes git add -A git commit -m "chore: bump version to 0.15.0" # Create a tag git tag 0.15.0 # Push changes and tag git push && git push --tags- Update the version: Run
Update versions across the monorepo with update-version.js
mainUse the
update-version.jsscript to synchronize the version number across allpackage.jsonfiles (root, client, server, and cli) and update thepackage-lock.json. This script also updates workspace dependencies in the rootpackage.jsonand runsnpm installto ensure the lockfile is current.npm run update-version <new-version> # Example: npm run update-version 0.14.3Tool Input Validation Guidelines for MCP Inspector
mainWhen implementing or modifying tool input parameter handling in the Inspector, follow these rules to ensure clean parameter passing and proper separation of concerns between the Inspector client and MCP servers:
- Omit optional fields with empty values: Omit empty strings or null values for optional parameters, unless the field has an explicit default value in the schema that matches the current value.
- Preserve explicit default values: If a field schema contains an explicit default (e.g.,
default: null), and the current value matches that default, include it in the request. This is considered a meaningful value. - Always include required fields: Preserve required field values even when empty. This allows the MCP server to perform its own validation and return appropriate error messages.
- Defer deep validation to the server: The Inspector client should only implement basic field presence checking; rely on the MCP server for full parameter validation according to its schema.
Verify version consistency with check-version-consistency.js
mainUse the
check-version-consistency.jsscript to ensure that all packages in the monorepo share the same version, workspace dependencies in the rootpackage.jsonare correct, and thatpackage-lock.jsonis perfectly in sync with thepackage.jsonfiles.npm run check-versionRun the Inspector in a Docker Container
mainYou can run the inspector using a Docker container. This command maps the necessary ports for the client UI (6274) and the MCP Proxy (6277).
docker run --rm \ -p 127.0.0.1:6274:6274 \ -p 127.0.0.1:6277:6277 \ -e HOST=0.0.0.0 \ -e MCP_AUTO_OPEN_ENABLED=false \ ghcr.io/modelcontextprotocol/inspector:latestConfigure eslint-plugin-react for the Inspector client
mainTo use recommended React linting rules, install
eslint-plugin-reactand update youreslint.config.jsto include the plugin, set the React version insettings, and spread the recommended rules into therulesobject.// eslint.config.js import react from "eslint-plugin-react"; export default tseslint.config({ // Set the react version settings: { react: { version: "18.3" } }, plugins: { // Add the react plugin react, }, rules: { // other rules... // Enable its recommended rules ...react.configs.recommended.rules, ...react.configs["jsx-runtime"].rules, }, });Enable type-aware ESLint rules in the Inspector client
mainFor production application development, it is recommended to enable type-aware lint rules by updating the ESLint configuration. This involves configuring
parserOptionsto point to your TypeScript configuration files and switching to type-checked rule sets.export default tseslint.config({ languageOptions: { // other options... parserOptions: { project: ["./tsconfig.node.json", "./tsconfig.app.json"], tsconfigRootDir: import.meta.dirname, }, }, });Configure Authentication and Security
mainProxy Authentication
By default, the MCP Inspector proxy requires authentication. A random session token is generated and printed to the console.
- Automatic: The inspector opens the browser with the token pre-filled in the URL.
- Manual: In the UI, click Configuration -> Proxy Session Token and enter the token from the console.
- Environment Variable: Set
MCP_PROXY_AUTH_TOKENwhen starting.
Security Warnings
- DANGEROUSLY_OMIT_AUTH: Setting this to
truedisables authentication. This is highly discouraged as it exposes your machine to remote compromise via web browsers. - Local-only Binding: By default, services bind to
localhost. UseHOST=0.0.0.0to bind to all interfaces (only in trusted networks). - DNS Rebinding Protection: The inspector validates the
Originheader. UseALLOWED_ORIGINS(comma-separated) to allow additional origins.