1. Updates docs to prefer `uv run server.py` instead of `arcade mcp` or `python -m arcade_mcp_server` 2. Found a bug with running stdio servers while updating the docs, so i snuck that in this PR
6.9 KiB
MCP Inspector
The MCP Inspector is a powerful debugging and testing tool for MCP servers. It provides a web-based interface to interact with your Arcade MCP server, test tools, and monitor protocol messages.
Installation
Install the MCP Inspector globally:
npm install -g @modelcontextprotocol/inspector
Or use npx to run without installing:
npx @modelcontextprotocol/inspector
Basic Usage
Connecting to HTTP Servers
For MCP servers running over HTTP:
# Start your MCP server
uv run server.py
# In another terminal, start the inspector
mcp-inspector http://localhost:8000/mcp
Connecting to stdio Servers
For stdio-based servers:
# Start the inspector with your server command
mcp-inspector "uv run server.py stdio"
# With additional project directory
mcp-inspector --cwd /path/to/project "uv run server.py stdio"
Inspector Features
Tool Explorer
The Tool Explorer shows all available tools with:
- Tool names and descriptions
- Parameter schemas
- Return type information
- Example invocations
Interactive Testing
Test tools directly from the interface:
- Select a tool from the explorer
- Fill in parameter values
- Click "Execute" to run the tool
- View results and execution time
Protocol Monitor
Monitor all MCP protocol messages:
- Request/response pairs
- Message timing
- Protocol errors
- Raw JSON data
Resource Browser
If your server provides resources:
- Browse available resources
- View resource contents
- Test resource operations
Prompt Templates
Test prompt templates if supported:
- View available prompts
- Fill template parameters
- Preview rendered prompts
Advanced Usage
Custom Environment
Pass environment variables to your server:
# Using env command
env ARCADE_API_KEY=your-key mcp-inspector "uv run server.py stdio"
# Using inspector's env option
mcp-inspector --env ARCADE_API_KEY=your-key "uv run server.py stdio"
Working Directory
Set the working directory for your server:
mcp-inspector --cwd /path/to/project "uv run server.py stdio"
Debug Mode
Enable verbose logging:
# Debug the inspector
mcp-inspector --debug "uv run server.py stdio"
# Server debug logging is configured in your server.py
# app = MCPApp(name="my_server", version="1.0.0", log_level="DEBUG")
Testing Workflows
Tool Development
-
Configure your server with hot reload:
# In your server.py if __name__ == "__main__": transport = sys.argv[1] if len(sys.argv) > 1 else "http" app.run(transport=transport, host="127.0.0.1", port=8000, reload=True)Then run:
uv run server.py -
Connect the inspector:
mcp-inspector http://localhost:8000/mcp -
Develop and test:
- Modify your tool code
- Server auto-reloads
- Test immediately in inspector
Performance Testing
Use the inspector to measure tool performance:
- Enable timing in the Protocol Monitor
- Execute tools multiple times
- Analyze response times
- Identify bottlenecks
Error Debugging
Debug tool errors effectively:
- Enable debug mode on your server
- Execute the failing tool
- Check Protocol Monitor for error details
- View server logs in terminal
Integration Testing
Test Suites
Create test suites using the inspector:
// test-tools.js
const tests = [
{
tool: "greet",
params: { name: "World" },
expected: "Hello, World!"
},
{
tool: "calculate",
params: { expression: "2 + 2" },
expected: 4
}
];
// Run tests via inspector API
Automated Testing
Combine with testing frameworks:
# test_mcp_tools.py
import subprocess
import json
import pytest
def test_tool_via_inspector():
# Start server
server = subprocess.Popen(
["python", "-m", "arcade_mcp_server"],
stdout=subprocess.PIPE
)
# Use inspector's API to test tools
# ...
Best Practices
Development Setup
-
Use Split Terminal:
- Terminal 1: MCP server with reload
- Terminal 2: Inspector
- Terminal 3: Code editor
-
Enable All Debugging:
# In server.py app = MCPApp(name="my_server", version="1.0.0", log_level="DEBUG") # Run with reload app.run(transport="http", host="127.0.0.1", port=8000, reload=True)Then run with environment file:
uv run server.py -
Save Test Cases:
- Export successful tool calls
- Build regression test suite
- Document edge cases
Production Testing
-
Test Against Production Config:
mcp-inspector "uv run server.py stdio" -
Verify Security:
- Test with limited permissions
- Verify API key handling
- Check error messages don't leak secrets
-
Load Testing:
- Execute tools rapidly
- Monitor memory usage
- Check for resource leaks
Troubleshooting
Connection Issues
"Failed to connect"
- Verify server is running
- Check correct URL/command
- Ensure ports aren't blocked
- Try with
--debugflag
"Protocol error"
- Ensure server implements MCP correctly
- Check for version compatibility
- Review server logs
- Verify transport type
Tool Issues
"Tool not found"
- Verify tool is decorated with
@tool - Check tool discovery in server
- Ensure no import errors
- Restart server and inspector
"Parameter validation failed"
- Check parameter types match schema
- Verify required parameters
- Test with simpler values
- Review tool documentation
Examples
Quick Test Session
# 1. Start a simple MCP server
cat > test_tools.py << 'EOF'
from arcade_mcp_server import tool
from typing import Annotated
@tool
def echo(message: Annotated[str, "Message to echo"]) -> str:
"""Echo the message back."""
return message
@tool
def add(
a: Annotated[int, "First number"],
b: Annotated[int, "Second number"]
) -> Annotated[int, "Sum"]:
"""Add two numbers."""
return a + b
EOF
# 2. Start inspector
mcp-inspector "uv run server.py stdio"
# 3. Test tools in the web interface
HTTP Server Testing
# 1. Create an MCPApp server
cat > app.py << 'EOF'
from arcade_mcp_server import MCPApp
from typing import Annotated
app = MCPApp(name="test-server", version="1.0.0")
@app.tool
def get_time() -> Annotated[str, "Current time"]:
"""Get the current time."""
from datetime import datetime
return datetime.now().isoformat()
if __name__ == "__main__":
app.run(port=9000, reload=True)
EOF
# 2. Run the server
python app.py
# 3. Connect inspector
mcp-inspector http://localhost:9000/mcp
Debugging Session
# 1. Enable all debugging
export DEBUG=*
export MCP_DEBUG=true
# 2. Start server with verbose logging
# (configure log_level="DEBUG" in your server.py)
uv run server.py stdio 2>server.log
# 3. Start inspector with debugging
mcp-inspector --debug "uv run server.py stdio"