A robust and modular Model Context Protocol (MCP) server for Middleware.io. This server enables AI assistants like Claude to interact with Middleware's observability platform for monitoring, dashboards, widgets, metrics, and alerts.
list_dashboards- List all dashboards with filtering and paginationget_dashboard- Get a specific dashboard by keycreate_dashboard- Create a new dashboardupdate_dashboard- Update an existing dashboarddelete_dashboard- Delete a dashboardclone_dashboard- Clone an existing dashboardset_dashboard_favorite- Mark dashboard as favorite/unfavorite
list_widgets- List widgets for a report or display scopecreate_widget- Create or update a widgetdelete_widget- Delete a widgetget_widget_data- Get data for a specific widgetget_multi_widget_data- Get data for multiple widgets at onceupdate_widget_layouts- Update widget layout positions
get_metrics- Get metrics, filters, or groupby tagsget_resources- Get available resources for queriesquery- Execute flexible queries to retrieve logs, metrics, traces, and other data
list_alerts- List alerts for a specific rulecreate_alert- Create a new alertget_alert_stats- Get alert statistics
list_errors- List all errors/incidents with filtering and pagination (includes clickableissue_urlfor each incident)get_error_details- Get detailed information about a specific error/incident by fingerprint
Get up and running in 5 minutes!
- Log in to your Middleware.io account
- Navigate to Settings → API Keys
- Click Generate New API Key
- Copy your API key and project URL
# Navigate to the project directory
cd mcp-middleware
# Install dependencies
go mod download
# Build the server
go build -o mcp-middleware .Or using Make:
make install
make buildCreate a .env file from the example:
cp .env.example .envOr use the Makefile command:
make init-envEdit .env with your credentials. The file should contain:
# Required: Your Middleware API Key
MIDDLEWARE_API_KEY=your_api_key_here
# Required: Your Middleware project URL
MIDDLEWARE_BASE_URL=https://your-project.middleware.io
# Optional: Application mode (default: stdio)
APP_MODE=stdioRequired Variables:
MIDDLEWARE_API_KEY: Your API key from Middleware SettingsMIDDLEWARE_BASE_URL: Your project URL (e.g.,https://your-project.middleware.io)
Optional Variables:
APP_MODE: Server mode -stdio(default),http, orsseAPP_HOST: Server host for http/sse modes (default:localhost)APP_PORT: Server port for http/sse modes (default:8080)EXCLUDED_TOOLS: Comma-separated list of tools to exclude (e.g.,delete_dashboard,delete_widget)
See the Configuration section below for all available options.
Run the server directly:
./mcp-middlewareThe server will start in stdio mode. You should see:
Middleware MCP Server v1.0.0
Connected to: https://your-project.middleware.io
Starting MCP server in stdio mode...
Press Ctrl+C to stop.
- Open
~/.config/Claude/claude_desktop_config.json - Add the server configuration:
{
"mcpServers": {
"middleware": {
"command": "/full/path/to/mcp-middleware/mcp-middleware",
"env": {
"MIDDLEWARE_API_KEY": "your_api_key",
"MIDDLEWARE_BASE_URL": "https://your-project.middleware.io"
}
}
}
}- Open
%APPDATA%\Claude\claude_desktop_config.json - Add the server configuration with Windows path:
{
"mcpServers": {
"middleware": {
"command": "C:\\path\\to\\mcp-middleware\\mcp-middleware.exe",
"env": {
"MIDDLEWARE_API_KEY": "your_api_key",
"MIDDLEWARE_BASE_URL": "https://your-project.middleware.io"
}
}
}
}- Restart Claude Desktop
Before connecting to Claude, you can test your server with the MCP Inspector:
# Requires Node.js and npx
make inspectThis opens an interactive web interface where you can:
- Test all 21 tools
- View server logs in real-time
- Debug inputs and outputs
- Verify everything works
Open Claude Desktop and try these commands:
List Dashboards:
Can you list all my dashboards in Middleware?
Get Resources:
What resources are available in my Middleware account?
Create a Dashboard:
Create a new dashboard called "Production Metrics" with public visibility
Get Widget Data:
Get the data for widget with builder ID 123
List Errors:
List all errors in the system from the last hour
Get Error Details:
Get detailed information about error with fingerprint 7693967476886782339
- Go 1.23 or later (the project uses Go 1.23.0 with toolchain 1.24.10)
- Node.js and npx (for MCP Inspector testing)
- Middleware.io account with API access
- API Key from Middleware API Keys settings
The server supports three transport modes:
- stdio (default): Standard input/output transport for command-line usage
- http: Streamable HTTP transport for web-based clients (uses
NewStreamableHTTPServer) - sse: Server-Sent Events transport for real-time streaming (uses
NewSSEServer)
| Environment Variable | Required | Default | Description |
|---|---|---|---|
MIDDLEWARE_API_KEY |
✅ Yes* | - | Your Middleware API key from settings |
AUTHORIZATION |
✅ Yes* | - | Alternative authorization token (if not using API key) |
MIDDLEWARE_BASE_URL |
✅ Yes | - | Your Middleware project URL (e.g., https://your-project.middleware.io) |
APP_MODE |
No | stdio |
Server mode: stdio, http, or sse |
APP_HOST |
No | localhost |
Server host (for http/sse modes) |
APP_PORT |
No | 8080 |
Server port (for http/sse modes) |
EXCLUDED_TOOLS |
No | - | Comma-separated list of tools to exclude |
* Either MIDDLEWARE_API_KEY or AUTHORIZATION must be provided.
You can exclude specific tools for security or functionality reasons:
EXCLUDED_TOOLS=delete_dashboard,delete_widget,create_alertThis is useful for creating read-only instances or restricting destructive operations.
./mcp-middleware
# Or set explicitly
APP_MODE=stdio ./mcp-middlewareStart the server in HTTP mode for web-based clients:
APP_MODE=http APP_HOST=localhost APP_PORT=8080 ./mcp-middlewareThe server will start on http://localhost:8080. Clients can connect using the streamable HTTP transport.
Start the server in SSE (Server-Sent Events) mode:
APP_MODE=sse APP_HOST=localhost APP_PORT=8080 ./mcp-middlewareThe server will start on http://localhost:8080 with SSE support for real-time streaming.
mcp-middleware/
├── config/ # Configuration Management
│ └── config.go # Environment variable loading and validation
│
├── middleware/ # Middleware.io API Client
│ ├── client.go # HTTP client with authentication
│ ├── types.go # API data structures (Dashboard, Widget, Alert, Incident, etc.)
│ ├── dashboards.go # Dashboard API endpoints
│ ├── widgets.go # Widget API endpoints
│ ├── metrics.go # Metrics API endpoints
│ ├── alerts.go # Alert API endpoints
│ └── issues.go # Error/Incident API endpoints
│
├── server/ # MCP Server Implementation
│ ├── server.go # Server initialization and lifecycle
│ ├── register_tools.go # Tool registration (21 tools)
│ ├── register_resources.go # Resource registration (future)
│ ├── register_prompts.go # Prompt registration (future)
│ └── tools/ # MCP Tool Definitions
│ ├── server_interface.go # Server interface for tool handlers
│ ├── helpers.go # Shared utility functions
│ ├── dashboards_tools.go # Dashboard MCP tools (7 tools)
│ ├── widgets_tools.go # Widget MCP tools (6 tools)
│ ├── metrics_tools.go # Metrics MCP tools (3 tools)
│ ├── alerts_tools.go # Alert MCP tools (3 tools)
│ ├── errors_tools.go # Error/Incident MCP tools (2 tools)
│ └── TOOLS_DOCUMENTATION.md # Comprehensive tool reference
│
├── test/ # Test Suite
│ ├── config/ # Configuration tests
│ │ └── config_test.go
│ ├── middleware/ # API client tests
│ │ └── client_test.go
│ ├── server/ # Server tests
│ │ └── server_test.go
│ ├── integration/ # Integration tests
│ │ └── integration_test.go
│ └── README.md # Test documentation
│
├── main.go # Application entry point
├── go.mod # Go module definition
├── go.sum # Go module checksums
├── .env.example # Example environment configuration
├── .gitignore # Git ignore rules
├── Makefile # Build and development automation
└── README.md # This file
Purpose: Centralized configuration management
- Load environment variables from
.envfile - Validate required configuration
- Provide configuration to other modules
Key Features:
- Support for multiple transport modes (stdio, http, sse)
- Tool exclusion for customization
- Default value handling
Purpose: Abstraction layer for Middleware.io REST API
- HTTP client with authentication
- Type-safe API methods
- Error handling and context support
Components:
client.go: Base HTTP client, authentication, common request handlingtypes.go: Go structs matching Middleware API data modelsdashboards.go: CRUD operations for dashboardswidgets.go: Widget management and data fetchingmetrics.go: Metrics metadata and resource discoveryalerts.go: Alert instance managementissues.go: Error/incident listing and detail retrieval
Purpose: Model Context Protocol server implementation
- Register MCP tools
- Handle tool invocations
- Map tool calls to Middleware API
Structure:
server.go: Core server setup, initialization, and lifecycle managementregister_tools.go: Registration of all MCP tools (21 tools)register_resources.go: Registration of MCP resources (prepared for future)register_prompts.go: Registration of MCP prompts (prepared for future)tools/: Directory containing all MCP tool definitionsserver_interface.go: Interface for tool handlers to access serverhelpers.go: Shared utility functions (e.g., ToMap, ToTextResult)*_tools.go: Tool definitions grouped by functionalityTOOLS_DOCUMENTATION.md: Comprehensive documentation for all tools
MCP Features:
- Tools ✅: Functions that AI models can actively call (21 tools implemented)
- Resources 🔜: Passive data sources for context (structure prepared)
- Prompts 🔜: Pre-built instruction templates (structure prepared)
Tool Organization:
dashboards_tools.go(7 tools): List, get, create, update, delete, clone dashboards, set favoriteswidgets_tools.go(6 tools): List, create, delete widgets, get widget data, batch data, update layoutsmetrics_tools.go(3 tools): Get metrics/filters/groupby tags, list available resources, execute flexible queriesalerts_tools.go(3 tools): List alerts, create alerts, get alert statisticserrors_tools.go(2 tools): List errors/incidents with clickable URLs, get error details by fingerprint
Purpose: Comprehensive test coverage
- Unit tests for each module
- Integration tests for full workflows
- HTTP mocking for isolated testing
Test Organization:
config/: Configuration loading testsmiddleware/: API client tests with httptestserver/: Server initialization testsintegration/: End-to-end workflow tests
- Separation of Concerns: Config, Middleware, Server, and Main are clearly separated
- Type Safety: Strongly typed structs for all API data with JSON schema validation
- Testability: Interfaces for dependency injection, HTTP mocking, context-based cancellation
- Extensibility: Easy to add new tools, tool exclusion for customization, modular architecture
- Robustness: Comprehensive error handling, context propagation, graceful shutdown, input validation
To add a new MCP tool:
- Choose appropriate file based on functionality (dashboard/widget/metrics/alert)
- Define tool using
mcp.NewTool()withmcp.WithDescription()andmcp.WithInputSchema[T]() - Define input struct with proper JSON schema tags
- Implement handler that calls the middleware client (signature:
func HandleTool(s ServerInterface, ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolResult, error)) - Register in
server/register_tools.gousings.mcpServer.AddTool(tools.NewTool(), handler) - Add tests in
test/server/ - Update
server/tools/TOOLS_DOCUMENTATION.md
The project includes 28 comprehensive tests organized in the test/ directory:
# Run all tests (28 tests)
make test
# Run with coverage report
make test-coverage
# Run with race detection
make test-race
# Run specific test suites
make test-config # Config tests (9 tests)
make test-middleware # Middleware client tests (11 tests)
make test-server # Server tests (3 tests)
make test-integration # Integration tests (5 tests)Test Coverage:
- ✅ Config: 9 tests
- ✅ Middleware Client: 11 tests (with HTTP mocking)
- ✅ Server: 3 tests
- ✅ Integration: 5 tests
For detailed testing information, see test/README.md.
Use the MCP Inspector for interactive testing during development:
# Start inspector
make inspect
# In another terminal, make changes and rebuild
make build
# Reconnect in inspector to test changesThis project follows Go best practices:
- Use
anyinstead ofinterface{} - Proper error handling with wrapped errors
- Context propagation for cancellation
- Clear package separation
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
For issues and questions:
- Middleware Support: [email protected]
- Documentation: See README.md for full documentation
Made with ❤️ for the MCP and Middleware communities