Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 84 additions & 0 deletions docs/LLM Tool Server.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# LLM Tool Server

The `obd_ai` package includes a lightweight, runnable server entrypoint for exposing the safe read-only diagnostic tools to external agents.

This transport is function-calling-friendly JSON over HTTP and reuses the same constrained tool surface used by the in-process Python API.

## Exposed tools

- `connect_vehicle`
- `get_vehicle_status`
- `list_supported_commands`
- `read_sensor`
- `read_sensors`
- `get_dtc_codes`
- `get_freeze_frame`
- `get_emissions_monitor_status`
- `basic_health_scan`

These tools remain read-only. The server does **not** expose raw OBD command construction or write operations.

## Start the server

```bash
python3 -m obd_ai.server serve-http --host 127.0.0.1 --port 8000
```

Or, after installing the project in editable or packaged form:

```bash
obd-ai-server serve-http --host 127.0.0.1 --port 8000
```

## Inspect the tool catalog

```bash
python3 -m obd_ai.server list-tools
```

## Make a one-shot tool call from the CLI

```bash
python3 -m obd_ai.server call connect_vehicle --input-json '{"portstr":"/dev/ttyUSB0"}'
python3 -m obd_ai.server call basic_health_scan
```

## HTTP endpoints

### `GET /health`

Returns a small readiness payload:

```json
{
"ok": true,
"service": "obd_ai_server"
}
```

### `GET /tools`

Returns the exposed tool definitions and input schemas.

### `POST /call`

Request body:

```json
{
"tool": "read_sensor",
"input": {
"command_key": "engine_rpm"
}
}
```

### `POST /tools/<tool_name>`

Equivalent convenience route for directly calling a specific tool.

## Notes

- Session lifecycle is managed by the underlying tool surface.
- Call `connect_vehicle` before issuing read operations.
- Error payloads are returned in structured JSON and preserve existing `obd_ai` error codes when possible.
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ nav:
- 'Command Lookup': 'Command Lookup.md'
- 'Command Tables' : 'Command Tables.md'
- 'Responses': 'Responses.md'
- 'LLM Tool Server': 'LLM Tool Server.md'
- 'Async Connections': 'Async Connections.md'
- 'Custom Commands': 'Custom Commands.md'
- 'Debug': 'Debug.md'
Expand Down
Loading