Scouter MCP Server
An MCP server that connects AI agents to Scouter APM, enabling natural-language queries against real-time application performance data.
README
Scouter MCP Server
An MCP (Model Context Protocol) server that connects AI agents to Scouter APM, enabling natural-language queries against real-time application performance data.
Ask your AI assistant things like "What's the slowest SQL in the last hour?" or "Why is TPS dropping?" and get answers grounded in live monitoring data.
Features
- 32 tools covering the full Scouter API surface
- Dual protocol — connects via HTTP (REST API) or TCP (binary protocol)
- Automatic hash resolution — SQL queries, service names, and error messages are decoded from Scouter's internal hash IDs to human-readable text
- Executable SQL — transaction profiles include SQL with bind parameters substituted, ready for
EXPLAIN ANALYZE - Zero external dependencies — only
@modelcontextprotocol/sdkandzod
Quick Start
Using npx (no install needed)
npx scouter-mcp-server
Or install from source
cd scouter.mcp
npm install
npm run build
Configure
Set environment variables to point at your Scouter collector:
| Variable | Description | Default |
|---|---|---|
SCOUTER_API_URL |
Scouter webapp REST API base URL | http://localhost:6180 |
SCOUTER_API_ID |
API login ID | |
SCOUTER_API_PASSWORD |
API login password | |
SCOUTER_TCP_HOST |
TCP direct connection host | |
SCOUTER_TCP_PORT |
TCP direct connection port | 6100 |
SCOUTER_ENABLE_WRITE |
Set to true to enable write tools |
(disabled) |
SCOUTER_MASK_PII |
Set to false to disable PII masking in responses (IP, login, userAgent, SQL params) |
true |
HTTP mode (recommended) — set SCOUTER_API_URL. Supports all 32 tools (write tools require SCOUTER_ENABLE_WRITE=true).
TCP mode — set SCOUTER_TCP_HOST. Lightweight, no webapp needed, but some admin tools are unavailable.
Note: By default, only read-only tools (25) are registered. To enable write tools (
set_configure,set_alert_scripting,manage_kv_store,manage_shortener,control_thread,remove_inactive_objects), setSCOUTER_ENABLE_WRITE=true.
3. Add to your MCP client
Claude Desktop (claude_desktop_config.json):
HTTP mode:
{
"mcpServers": {
"scouter": {
"command": "npx",
"args": ["-y", "scouter-mcp-server"],
"env": {
"SCOUTER_API_URL": "http://your-scouter-server:6180",
"SCOUTER_API_ID": "admin",
"SCOUTER_API_PASSWORD": "your-password"
}
}
}
}
TCP mode:
{
"mcpServers": {
"scouter": {
"command": "npx",
"args": ["-y", "scouter-mcp-server"],
"env": {
"SCOUTER_TCP_HOST": "your-scouter-server",
"SCOUTER_TCP_PORT": "6100",
"SCOUTER_API_ID": "admin",
"SCOUTER_API_PASSWORD": "your-password"
}
}
}
}
Claude Code (use -s user to register globally across all projects):
# HTTP mode
claude mcp add scouter -s user \
-e SCOUTER_API_URL=http://your-scouter-server:6180 \
-e SCOUTER_API_ID=admin \
-e SCOUTER_API_PASSWORD=your-password \
-- npx -y scouter-mcp-server
# TCP mode
claude mcp add scouter -s user \
-e SCOUTER_TCP_HOST=your-scouter-server \
-e SCOUTER_TCP_PORT=6100 \
-e SCOUTER_API_ID=admin \
-e SCOUTER_API_PASSWORD=your-password \
-- npx -y scouter-mcp-server
To update the configuration later, edit ~/.claude.json directly or remove and re-add:
claude mcp remove scouter -s user
claude mcp add scouter -s user \
-e SCOUTER_TCP_HOST=new-host \
-e SCOUTER_TCP_PORT=6100 \
-e SCOUTER_API_ID=admin \
-e SCOUTER_API_PASSWORD=your-password \
-- npx -y scouter-mcp-server
Tools
Performance Investigation
| Tool | Description |
|---|---|
get_system_overview |
Real-time snapshot — TPS, response time, CPU, heap, active services, alerts |
diagnose_performance |
Automated multi-step diagnosis with severity-ranked findings |
get_counter_trend |
Historical counter values (TPS, ElapsedTime, CPU, etc.) over time |
search_transactions |
Find slow/error transactions by time range, service, IP, login |
get_transaction_detail |
Full transaction profile with executable SQL and API call traces |
list_active_services |
Currently running requests with thread state |
SQL & Database
| Tool | Description |
|---|---|
get_sql_analysis |
SQL performance ranking — count, elapsed, errors, % of total |
lookup_text |
Resolve hash IDs to SQL/service/error text |
Error & Alert Analysis
| Tool | Description |
|---|---|
get_error_summary |
Errors ranked by frequency with per-service error rates |
get_alert_summary |
Alert statistics within a time range |
get_alert_scripting |
Read alert rule scripts |
set_alert_scripting |
Create/update alert rules (HTTP only) |
Service & Traffic
| Tool | Description |
|---|---|
get_service_summary |
Service-level stats with external API call breakdown |
get_ip_summary |
Request distribution by client IP |
get_user_agent_summary |
Request distribution by browser/user-agent |
get_visitor_stats |
Unique visitor counts (realtime, daily, hourly) |
get_interaction_counters |
Service-to-service call relationships |
Infrastructure
| Tool | Description |
|---|---|
get_thread_dump |
Thread dump with stack traces |
get_host_info |
Host-level top processes and disk usage |
get_agent_info |
Agent runtime info (threads, env, sockets) |
get_server_info |
Collector server metadata and counter model |
Distributed Tracing
| Tool | Description |
|---|---|
get_distributed_trace |
Trace a transaction across services via GXID |
get_realtime_xlogs |
Real-time transaction stream |
get_raw_xlog |
Raw XLog data (5 query modes) |
get_raw_profile |
Raw profile steps with hash IDs |
Configuration & Management
| Tool | Description |
|---|---|
get_configure |
Read server/agent configuration |
set_configure |
Modify configuration (HTTP only) |
control_thread |
Suspend/resume/interrupt threads |
manage_kv_store |
Global, namespaced, and private key-value store |
manage_shortener |
URL shortener service |
remove_inactive_objects |
Clean up dead agents (HTTP only) |
Architecture
┌─────────────────────────────┐
│ AI Agent (Claude, etc.) │
│ "Why is the app slow?" │
└──────────┬──────────────────┘
│ MCP (stdio)
┌──────────▼──────────────────┐
│ Scouter MCP Server │
│ ┌────────────────────────┐ │
│ │ Tool Hub (31 tools) │ │
│ │ Hash Resolution Engine │ │
│ │ SQL Param Binding │ │
│ └────────────────────────┘ │
└──────────┬──────────────────┘
│ HTTP REST or TCP Binary
┌──────────▼──────────────────┐
│ Scouter Collector Server │
│ + Webapp (REST API) │
└──────────┬──────────────────┘
│
┌──────▼──────┐
│ Java Agents │
│ Host Agents │
└─────────────┘
Project Structure
scouter.mcp/
├── index.ts # Entry point — stdio transport + SIGINT handler
├── server/
│ └── index.ts # createServer() factory → { server, cleanup }
├── tools/
│ ├── index.ts # registerAllTools() hub — explicit imports of all tools
│ ├── shared-utils.ts # Hash resolution, SQL param binding
│ └── ... (31 tool files)
├── client/
│ ├── index.ts # Client facade — exports client, jsonStringify, catchWarn
│ ├── interface.ts # ScouterClient interface + types
│ ├── http.ts # HTTP/REST implementation
│ └── tcp.ts # TCP binary protocol implementation
├── protocol/
│ ├── tcp-connection.ts # TCP connection with handshake/auth
│ ├── packs.ts # Scouter binary pack definitions
│ ├── values.ts # Value type serialization
│ ├── data-input.ts # Binary deserialization
│ ├── data-output.ts # Binary serialization
│ └── constants.ts # Protocol constants
├── time-utils.ts # Time parsing utilities
├── __tests__/ # Vitest test suites
├── vitest.config.ts # Test config (v8 coverage)
├── tsconfig.json # NodeNext modules
└── package.json
Development
npm run dev # Watch mode (tsc --watch)
npm test # Run tests
npm run test:coverage # Coverage report
npm run build # Production build
Adding a New Tool
- Create
tools/my-tool.tsexportingregister(server: McpServer)withserver.registerTool() - Add
import { register as registerMyTool } from "./my-tool.js"totools/index.ts - Call
registerMyTool(server)insideregisterAllTools() - Use
shared-utils.tsfor hash resolution and SQL binding
Protocol Details
HTTP Mode
Connects to Scouter's webapp REST API (/scouter/v1/*). Supports all 32 tools including write operations (configuration, alert scripting, thread control).
Authentication: username/password login with bearer token auto-refresh on 401.
TCP Mode
Connects directly to the Scouter collector using the binary protocol (port 6100). Handshake uses NetCafe magic number (0xCAFE2001), login with SHA-256 hashed password.
Supports read-only tools. Write operations (config, alerts, KV store, URL shortener) throw UnsupportedOperationError.
Text hash resolution uses GET_TEXT_100 command with per-date caching.
Requirements
- Node.js >= 18
- Scouter Collector >= 2.x with webapp enabled (for HTTP mode)
License
Apache License 2.0 — same as the Scouter project.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。