Skip to content

Configuration

farzad edited this page Oct 7, 2026 · 2 revisions

Configuration

Settings live in config.py::Settings (pydantic-settings) and are read from PEYKAN_* environment variables or a .env file in the working directory.

Bus

Variable Default Notes
PEYKAN_CAN_INTERFACE virtual Any python-can interface: socketcan, pcan, kvaser, vector, slcan, ...
PEYKAN_CAN_CHANNEL bus0 e.g. can0, PCAN_USBBUS1, COM3
PEYKAN_CAN_BITRATE unset Passed to python-can for real adapters (SocketCAN sets it on the link instead)
PEYKAN_DBC_PATH bundled vehicle.dbc Your vehicle's DBC
PEYKAN_J1939_ENABLED true Run the J1939 side of the simulator

Server

Variable Default Notes
PEYKAN_MCP_HOST 127.0.0.1 Interface to listen on. 0.0.0.0 accepts connections from other machines; the tools have no authentication, so only do that on a trusted network or in a container
PEYKAN_MCP_PORT 6278
PEYKAN_MCP_TRANSPORT sse sse (endpoint /sse), streamable-http (/mcp) or stdio
PEYKAN_MAX_DURATION_S 30.0 Caps every tool's duration_s / timeout_s; the frame history keeps at least this much (or 60 s)
PEYKAN_CORS_ALLOW_ORIGINS ["*"] JSON array of browser origins. Credentialed CORS is only enabled once this is narrowed from * (browsers reject * with credentials)
PEYKAN_LOG_LEVEL INFO Logs go to stderr

On 127.0.0.1 the server also rejects requests whose Host header isn't local (DNS-rebinding protection: a web page can't reach the tools by pointing its own hostname at your machine). Origins listed in PEYKAN_CORS_ALLOW_ORIGINS are still accepted.

Transmit safety

See Real Hardware and Safety for what these allow.

Variable Default Notes
PEYKAN_ALLOW_TRANSMIT on for virtual, off otherwise Allow requests that only read
PEYKAN_ALLOW_WRITE_SERVICES on for virtual, off otherwise Also allow state-changing services; never without ALLOW_TRANSMIT
PEYKAN_TRANSMIT_ALLOWLIST none JSON array of IDs, e.g. ["0x7DF","0x7E0"]
PEYKAN_TRANSMIT_LOG_PATH unset Append every frame sent or blocked as JSON lines
PEYKAN_SIMULATOR_ON_HARDWARE false Let the simulator run on a real interface (isolated bench setups only)

Logs

Variable Default Notes
PEYKAN_LOG_DIR . The only directory MCP clients may read log files from (plus the bundled sample)

Examples

.env for a PCAN adapter, read-only:

PEYKAN_CAN_INTERFACE=pcan
PEYKAN_CAN_CHANNEL=PCAN_USBBUS1
PEYKAN_CAN_BITRATE=500000
PEYKAN_ALLOW_TRANSMIT=true
PEYKAN_TRANSMIT_LOG_PATH=transmit.jsonl
PEYKAN_DBC_PATH=C:/dbc/my_car.dbc

Per invocation, server and demo accept --host, --port and --transport.

Old variable names

Before 0.2.0 the prefix was MCP_CAN_. Those variables are still read when the matching PEYKAN_ one isn't set, with a one-time warning. .env files are not migrated: rename the keys.

Clone this wiki locally