Skip to content

MCP Tools Reference

farzad edited this page Oct 7, 2026 · 2 revisions

MCP Tools Reference

All tools are registered in server/mcp_server.py::create_app() and return typed Pydantic models (server/schemas.py), so clients get a real outputSchema and structured results.

  • duration_s / timeout_s are capped by PEYKAN_MAX_DURATION_S (default 30 s).
  • Parameters that are IDs (CAN IDs, PGNs, OBD services/PIDs, UDS services and DIDs) accept integers or hex strings like "0x7E0"; PGNs also accept catalog acronyms like "EEC1".
  • Request/response tools report a status instead of raising: success, timeout, error, negative_response (UDS), or blocked (refused by the transmit policy). Check it before using the rest of the result.

Reading the bus

These read the server's continuously running frame history (server/live_state.py), so they return immediately and never miss frames between calls.

Tool Returns
read_can_frames(duration_s=1.0) Every raw frame from the last duration_s seconds
filter_frames(arbitration_id=None, signal_name=None, duration_s=1.0) Frames matching an ID and/or containing a decoded signal
monitor_signal(signal_name, duration_s=2.0) Timestamped samples of one decoded signal
get_vehicle_snapshot() The last value of every signal (DBC and J1939), with units, source message and age_s. The best first call for "what is X right now?"
decode_can_frame(arbitration_id, data) Decode any 11-bit frame with the loaded DBC

OBD-II and the DBC diagnostic protocol

Tool Does
send_obd_request(service, pid=None, timeout_s=2.0) OBD-II (SAE J1979) request on 0x7DF; waits for the frame that answers it and decodes known PIDs. service=3 returns stored DTCs. See Diagnostics and OBD-II
send_diagnostic_request(service_id, parameter_id=0, data_field=0, timeout_s=2.0) The DBC's own UDS-style protocol; every simulated ECU answers

UDS over ISO-TP

Multi-frame transport via can-isotp, UDS client via udsoncan. Default addressing is the engine ECU (request 0x7E0, response 0x7E8); pass request_id / response_id for others. Details: UDS over ISO-TP.

Tool Does
read_vin(timeout_s=2.0) VIN via OBD Mode 09 PID 02, with check-digit validation
uds_read_data(dids, request_id="0x7E0", response_id="0x7E8", timeout_s=2.0) ReadDataByIdentifier (0x22). dids is one DID or a list, e.g. ["0xF190", "0xF40C"]
uds_read_dtcs(status_mask="0xFF", ...) ReadDTCInformation (0x19, by status mask): each DTC with its status bits
uds_clear_dtcs(...) ClearDiagnosticInformation (0x14). Changes ECU state

SAE J1939

Details: SAE J1939.

Tool Does
decode_j1939_frame(arbitration_id, data) Split a 29-bit ID into priority / PGN / addresses and decode known SPNs
list_j1939_pgns() The PGN/SPN catalog
request_j1939_pgn(pgn, timeout_s=2.0) Send a Request PGN (0xEA00) and collect decoded responses
read_j1939_dtcs(duration_s=3.0) Active DTCs from the latest DM1 of every ECU (single-frame or multi-packet), each tagged with its source address

Recorded logs

Files must be under PEYKAN_LOG_DIR (default: the server's working directory); "sample" is the bundled drive. Details: Recorded CAN Logs.

Tool Does
list_can_logs() Log files available, plus the sample
analyze_can_log(path) Summary: duration, IDs and rates, signal ranges, OBD and J1939 DTCs, timing gaps
get_log_signal(path, signal_name, max_points=100, message=None) One signal over the log, downsampled. message picks a source when a name occurs in several (e.g. "J1939:EEC1")
replay_can_log(path, speed=1.0, loop=False) Replay onto the bus with original timing; live tools and the dashboard then see it. Counts as a write
stop_log_replay() Stop the replay and report progress

Simulator and safety

Tool Does
activate_fault_scenario(preset=None, timeout_s=2.0) Activate one of the seven fault scenarios, or clear with preset=None. Counts as a write
get_transmit_log(limit=20) The transmit policy and the most recent frames sent or blocked. See Real Hardware and Safety

Prompts

Ready-made multi-step tasks, so smaller models don't have to plan the tool sequence (in ollmcp, type /diagnose_vehicle).

Prompt Does
diagnose_vehicle Snapshot plus OBD, UDS and J1939 trouble codes; reports status, each issue with evidence, and next steps
explain_dtc(code) Explains a code and checks whether it's active now
trip_summary(duration_s=10) Min/avg/max RPM, throttle and speed over the window
fault_drill(preset="overheat") Injects a fault, diagnoses it from the evidence alone, compares, then clears it
analyze_log(path="sample") Investigates a recording and reports a timeline and root cause

Resource

file://vehicle.dbc (dbc_info): the full DBC: nodes, messages (ID, length, cycle time, senders) and every signal's layout, scaling, range, unit and value names.

HTTP routes

Route Purpose
GET / Redirects to /dashboard
GET /dashboard, GET /dashboard/stream The dashboard and its live update stream
GET /healthz 200 when the DBC loaded, 503 otherwise
GET /.well-known/oauth-* Stubs so clients probing for OAuth don't stall (the server has no auth)

Clone this wiki locally