HTTP Mode¶
The server can run in streamable-http mode in addition to stdio.
Behavior¶
- MCP endpoint:
/mcp - Discovery endpoint:
/.well-known/mcp-server - Optional bearer-token auth
- Optional
/metricsendpoint whenKICAD_MCP_ENABLE_METRICS=true - Optional OpenTelemetry OTLP export when
OTEL_EXPORTER_OTLP_ENDPOINTis set or--telemetryis passed - Optional CORS allowlist using explicit
http://,https://, orvscode-webview://origins only - Wildcard CORS (
*) is rejected intentionally - Stateless HTTP by default, with opt-in stateful HTTP for session-aware clients
- Legacy
/sseand/messagesroutes stay disabled unlessKICAD_MCP_LEGACY_SSE=true
The default HTTP port is 3334. For KiCad Studio local bridge setups, 27185 is a good convention if you want a dedicated port.
Stateless mode is the ChatGPT-compatible default. In this mode the initialize
response does not include Mcp-Session-Id, and follow-up requests such as
tools/list must work without a session header. Set KICAD_MCP_STATEFUL_HTTP=true
only for clients that preserve Mcp-Session-Id from the initialize response and
send it on subsequent Streamable HTTP requests.
Environment Variables¶
KICAD_MCP_TRANSPORT=httpKICAD_MCP_HOST=127.0.0.1KICAD_MCP_PORT=3334KICAD_MCP_CORS_ORIGINS=https://app.example.com,http://127.0.0.1:3334KICAD_MCP_AUTH_TOKEN=...KICAD_MCP_STATEFUL_HTTP=trueKICAD_MCP_ENABLE_METRICS=trueKICAD_MCP_LEGACY_SSE=trueOTEL_EXPORTER_OTLP_ENDPOINT=http://127.0.0.1:4318OTEL_EXPORTER_OTLP_PROTOCOL=http/protobufOTEL_SERVICE_NAME=kicad-mcp-pro
Discovery, Metrics, and Token Rotation¶
GET /.well-known/mcp-serverreturns the server card pluscapabilities.toolCategories,capabilities.profiles, andcapabilities.experimentalToolsso clients can negotiate a profile before listing tools.GET /metricsemits in-memory Prometheus text metrics for tool calls and sliding-window p50/p95 latency when metrics are enabled.- OpenTelemetry emits MCP request, tool, KiCad CLI, and PCB parser spans plus tool/session/CLI metrics to the configured OTLP collector. Attributes do not include project paths, board contents, schematic contents, request arguments, CLI output, or collector headers.
POST /.well-known/mcp-server/token-rotaterotates the in-memory bearer token. The request must authenticate with the current token and send JSON like{"new_token": "..."}.
Notes¶
- When bearer auth is enabled, cross-origin
POST /mcprequests are checked againstKICAD_MCP_CORS_ORIGINS. - If you run over
stdio,KICAD_MCP_AUTH_TOKENis ignored and a startup warning is emitted. - Use explicit origins instead of wildcard origins so the allowlist stays valid and auditable.
- Token rotation is intentionally in-memory; update your environment or TOML config separately for persistence.