Skip to content

Configuration

farzad edited this page Aug 19, 2026 · 1 revision

Configuration

All settings live in config.py::Settings (a pydantic-settings BaseSettings), read from environment variables prefixed MCP_CAN_, or from a .env file at the repo root.

Env var Default Notes
MCP_CAN_CAN_INTERFACE virtual Passed through to python-can; set to socketcan on Linux for real hardware/vcan0
MCP_CAN_CAN_CHANNEL bus0 Bus channel name
MCP_CAN_DBC_PATH vehicle.dbc Path to the DBC file to load
MCP_CAN_MCP_PORT 6278 MCP server port
MCP_CAN_MCP_TRANSPORT sse sse | streamable-http | stdio. streamable-http requires a newer mcp SDK version; the server logs a clear error and exits (rather than an SDK traceback) if the installed version doesn't support it.
MCP_CAN_MAX_DURATION_S 30.0 Caps every tool's duration_s/timeout_s — a client can't tie up a listener/request indefinitely. The frame history buffer retains at least this much (or 60s, whichever is larger).
MCP_CAN_LOG_LEVEL INFO Standard Python logging level name
MCP_CAN_CORS_ALLOW_ORIGINS ["*"] JSON array of allowed browser origins for the SSE endpoint, e.g. ["https://your-host.example"]. See below.

CORS and credentials

allow_credentials on the CORS middleware is tied to cors_allow_origins: it's only enabled once that's narrowed away from the default ["*"]. This isn't arbitrary — browsers reject the wildcard-origin + credentials combination outright, so leaving allow_credentials=True on unconditionally (as an earlier version of this project did) had no actual benefit and just signaled a sloppy default. Override before any real deployment; the wildcard default exists purely for the zero-friction demo experience (e.g. MCP Inspector connecting from a browser with no configuration).

Setting via .env

MCP_CAN_CAN_INTERFACE=virtual
MCP_CAN_CAN_CHANNEL=bus0
MCP_CAN_MCP_PORT=6278
MCP_CAN_LOG_LEVEL=DEBUG
MCP_CAN_CORS_ALLOW_ORIGINS=["https://your-host.example"]

Per-invocation overrides

server/demo also accept --port/--transport CLI flags, which set the corresponding env var before starting (see cli.py) — equivalent to exporting it yourself, just scoped to that invocation.

Clone this wiki locally