@motorbay/mcp 0.0.0-stage → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +156 -2
- package/dist/capabilities.js +18 -0
- package/dist/client.js +44 -0
- package/dist/errors.js +56 -0
- package/dist/index.js +14 -0
- package/dist/server.js +23 -0
- package/dist/tools.js +125 -0
- package/dist/version.js +1 -0
- package/package.json +44 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Motorbay
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,157 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @motorbay/mcp
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[npm: @motorbay/mcp](https://www.npmjs.com/package/@motorbay/mcp)
|
|
4
|
+
|
|
5
|
+
A Model Context Protocol (MCP) server for the [Motorbay API](https://app.motorbay.app). It lets an AI assistant look up Danish vehicles by registration number, VIN or id, and read their inspection, technical details, engine, environmental data, fuel types, equipment and usages.
|
|
6
|
+
|
|
7
|
+
The data comes from Motorstyrelsen's public weekly extract of the Danish Motor Register (DMR) and is updated weekly. Motorbay is not affiliated with Motorstyrelsen, and the data is provided as-is. It holds no owner or keeper information.
|
|
8
|
+
|
|
9
|
+
## What you need
|
|
10
|
+
|
|
11
|
+
- Node.js 20 or newer.
|
|
12
|
+
- A Motorbay API key. Create one in the [Motorbay console](https://app.motorbay.app). Production keys start with `mbk_live_`.
|
|
13
|
+
|
|
14
|
+
The server reads the key from the `MOTORBAY_API_KEY` environment variable and sends it in the `X-Api-Key` header. It runs over stdio, so your MCP client starts it for you.
|
|
15
|
+
|
|
16
|
+
## Setup
|
|
17
|
+
|
|
18
|
+
### Claude Desktop
|
|
19
|
+
|
|
20
|
+
Edit `claude_desktop_config.json` (Settings, Developer, Edit Config):
|
|
21
|
+
|
|
22
|
+
```json
|
|
23
|
+
{
|
|
24
|
+
"mcpServers": {
|
|
25
|
+
"motorbay": {
|
|
26
|
+
"command": "npx",
|
|
27
|
+
"args": ["-y", "@motorbay/mcp"],
|
|
28
|
+
"env": { "MOTORBAY_API_KEY": "mbk_live_..." }
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Restart Claude Desktop.
|
|
35
|
+
|
|
36
|
+
### Claude Code
|
|
37
|
+
|
|
38
|
+
```sh
|
|
39
|
+
claude mcp add motorbay --env MOTORBAY_API_KEY=mbk_live_... -- npx -y @motorbay/mcp
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Or add it to `.mcp.json` in your project, reading the key from your shell:
|
|
43
|
+
|
|
44
|
+
```json
|
|
45
|
+
{
|
|
46
|
+
"mcpServers": {
|
|
47
|
+
"motorbay": {
|
|
48
|
+
"command": "npx",
|
|
49
|
+
"args": ["-y", "@motorbay/mcp"],
|
|
50
|
+
"env": { "MOTORBAY_API_KEY": "${MOTORBAY_API_KEY}" }
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### Cursor
|
|
57
|
+
|
|
58
|
+
Add to `~/.cursor/mcp.json` (all projects) or `.cursor/mcp.json` (one project):
|
|
59
|
+
|
|
60
|
+
```json
|
|
61
|
+
{
|
|
62
|
+
"mcpServers": {
|
|
63
|
+
"motorbay": {
|
|
64
|
+
"command": "npx",
|
|
65
|
+
"args": ["-y", "@motorbay/mcp"],
|
|
66
|
+
"env": { "MOTORBAY_API_KEY": "mbk_live_..." }
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### VS Code (GitHub Copilot agent mode)
|
|
73
|
+
|
|
74
|
+
Add to `.vscode/mcp.json`. VS Code asks for the key once and stores it securely:
|
|
75
|
+
|
|
76
|
+
```json
|
|
77
|
+
{
|
|
78
|
+
"inputs": [
|
|
79
|
+
{ "type": "promptString", "id": "motorbay-key", "description": "Motorbay API key", "password": true }
|
|
80
|
+
],
|
|
81
|
+
"servers": {
|
|
82
|
+
"motorbay": {
|
|
83
|
+
"type": "stdio",
|
|
84
|
+
"command": "npx",
|
|
85
|
+
"args": ["-y", "@motorbay/mcp"],
|
|
86
|
+
"env": { "MOTORBAY_API_KEY": "${input:motorbay-key}" }
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Do not commit a real key to a repository.
|
|
93
|
+
|
|
94
|
+
## Tools
|
|
95
|
+
|
|
96
|
+
| Tool | What it does |
|
|
97
|
+
| --- | --- |
|
|
98
|
+
| `get_vehicle_by_plate` | Vehicle by registration number, e.g. `AB12345` |
|
|
99
|
+
| `get_vehicle_by_vin` | Vehicle by VIN |
|
|
100
|
+
| `get_vehicle` | Vehicle by Motorbay id |
|
|
101
|
+
| `get_vehicle_inspection` | Latest inspection: type, date, result, odometer reading |
|
|
102
|
+
| `get_vehicle_technical_details` | Weights, seats, doors, body type, model year and more |
|
|
103
|
+
| `get_vehicle_engine` | Power, displacement, cylinders, noise |
|
|
104
|
+
| `get_vehicle_environmental_information` | CO2, NOx, particle emission, particle filter |
|
|
105
|
+
| `list_vehicle_fuel_types` | Fuel types, fuel economy, CO2 |
|
|
106
|
+
| `list_vehicle_equipment` | Registered equipment |
|
|
107
|
+
| `list_vehicle_secondary_usages` | Secondary usages, e.g. rental |
|
|
108
|
+
| `search_vehicles` | Search by plate history, make, kind, usage, color, model year |
|
|
109
|
+
| `check_vehicle` | Used-car check: status, blocks, damage, leasing, latest inspection, flags |
|
|
110
|
+
|
|
111
|
+
All tools are read-only. Results are compact JSON as the API returns it. When the register has no engine, inspection or environmental record, the tool returns `{"found": false, ...}` instead of an error.
|
|
112
|
+
|
|
113
|
+
The server reads the API's OpenAPI document at start-up and offers only the tools whose endpoints that API serves.
|
|
114
|
+
|
|
115
|
+
## Errors
|
|
116
|
+
|
|
117
|
+
Errors come back as tool errors with a message the assistant can act on:
|
|
118
|
+
|
|
119
|
+
| API answer | Message |
|
|
120
|
+
| --- | --- |
|
|
121
|
+
| 401 `ApiKeyMissing` | The key is not set: set `MOTORBAY_API_KEY` |
|
|
122
|
+
| 401 `ApiKeyInvalid` | The key is unknown, revoked or expired |
|
|
123
|
+
| 402 `PaymentRequired` | No active plan, with a link to pricing |
|
|
124
|
+
| 429 `QuotaExceeded` | Monthly quota used, upgrade or wait for the 1st |
|
|
125
|
+
| 429 `RateLimitExceeded` | 60 requests per minute, with the `Retry-After` seconds |
|
|
126
|
+
| 404 `VehicleNotFound` | No vehicle in the current weekly extract |
|
|
127
|
+
| 400 `ValidationFailed` | Which input rule failed |
|
|
128
|
+
|
|
129
|
+
Each message ends with the request ID. Send it with any support request.
|
|
130
|
+
|
|
131
|
+
## Usage and quota
|
|
132
|
+
|
|
133
|
+
Every tool call is one API request and counts toward your plan. The data changes at most once a week, so asking again for the same vehicle within a week gives the same answer.
|
|
134
|
+
|
|
135
|
+
## Configuration
|
|
136
|
+
|
|
137
|
+
| Variable | Default | Meaning |
|
|
138
|
+
| --- | --- | --- |
|
|
139
|
+
| `MOTORBAY_API_KEY` | none | Your API key. Required |
|
|
140
|
+
| `MOTORBAY_API_URL` | `https://api.motorbay.app` | Base URL, for testing |
|
|
141
|
+
|
|
142
|
+
## Development
|
|
143
|
+
|
|
144
|
+
```sh
|
|
145
|
+
npm install
|
|
146
|
+
npm test # vitest, against a local mock server
|
|
147
|
+
npm run build # compiles to dist/
|
|
148
|
+
npm run refresh-openapi # refetch the live OpenAPI document and retest
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
The mock server answers with bodies that the tests validate against the schemas in the API's OpenAPI document (`test/fixtures/openapi.json`), and a test checks that every tool's path and parameters exist in that document.
|
|
152
|
+
|
|
153
|
+
To add a tool for a new endpoint, add one entry to `TOOLS` in `src/tools.ts`.
|
|
154
|
+
|
|
155
|
+
## License
|
|
156
|
+
|
|
157
|
+
MIT
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reads the API's OpenAPI document to find which paths exist, so a tool is
|
|
3
|
+
* offered only when the API it talks to serves its path (an older or
|
|
4
|
+
* self-hosted API may not). Returns null if the document can't be read;
|
|
5
|
+
* callers then show every tool.
|
|
6
|
+
*/
|
|
7
|
+
export async function fetchAvailablePaths(baseUrl, fetchImpl = fetch) {
|
|
8
|
+
try {
|
|
9
|
+
const res = await fetchImpl(`${baseUrl.replace(/\/+$/, "")}/openapi/v1.json`, { signal: AbortSignal.timeout(5000) });
|
|
10
|
+
if (!res.ok)
|
|
11
|
+
return null;
|
|
12
|
+
const doc = (await res.json());
|
|
13
|
+
return doc.paths ? new Set(Object.keys(doc.paths)) : null;
|
|
14
|
+
}
|
|
15
|
+
catch {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { describeApiError, MotorbayApiError } from "./errors.js";
|
|
2
|
+
export const DEFAULT_BASE_URL = "https://api.motorbay.app";
|
|
3
|
+
export class MotorbayClient {
|
|
4
|
+
opts;
|
|
5
|
+
baseUrl;
|
|
6
|
+
fetchImpl;
|
|
7
|
+
constructor(opts) {
|
|
8
|
+
this.opts = opts;
|
|
9
|
+
this.baseUrl = (opts.baseUrl ?? DEFAULT_BASE_URL).replace(/\/+$/, "");
|
|
10
|
+
this.fetchImpl = opts.fetch ?? fetch;
|
|
11
|
+
}
|
|
12
|
+
async get(path, query = {}) {
|
|
13
|
+
const qs = new URLSearchParams();
|
|
14
|
+
for (const [k, v] of Object.entries(query))
|
|
15
|
+
if (v !== undefined && v !== "")
|
|
16
|
+
qs.set(k, String(v));
|
|
17
|
+
const url = `${this.baseUrl}${path}${qs.size ? `?${qs}` : ""}`;
|
|
18
|
+
const headers = { accept: "application/json", "user-agent": this.opts.userAgent ?? "motorbay-mcp" };
|
|
19
|
+
if (this.opts.apiKey)
|
|
20
|
+
headers["x-api-key"] = this.opts.apiKey;
|
|
21
|
+
let res;
|
|
22
|
+
try {
|
|
23
|
+
res = await this.fetchImpl(url, { headers });
|
|
24
|
+
}
|
|
25
|
+
catch (e) {
|
|
26
|
+
throw new MotorbayApiError(0, undefined, `Could not reach the Motorbay API at ${this.baseUrl}: ${e.message}`);
|
|
27
|
+
}
|
|
28
|
+
if (res.status === 204)
|
|
29
|
+
return { status: 204, body: undefined };
|
|
30
|
+
const text = await res.text();
|
|
31
|
+
let body = text;
|
|
32
|
+
try {
|
|
33
|
+
body = text ? JSON.parse(text) : undefined;
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
/* keep text */
|
|
37
|
+
}
|
|
38
|
+
if (!res.ok) {
|
|
39
|
+
const code = body && typeof body === "object" ? body.code : undefined;
|
|
40
|
+
throw new MotorbayApiError(res.status, code, describeApiError(res.status, body, res.headers.get("retry-after")));
|
|
41
|
+
}
|
|
42
|
+
return { status: res.status, body };
|
|
43
|
+
}
|
|
44
|
+
}
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
export const CONSOLE_URL = "https://app.motorbay.app";
|
|
2
|
+
export const PRICING_URL = `${CONSOLE_URL}/pricing`;
|
|
3
|
+
export class MotorbayApiError extends Error {
|
|
4
|
+
status;
|
|
5
|
+
code;
|
|
6
|
+
constructor(status, code, message) {
|
|
7
|
+
super(message);
|
|
8
|
+
this.status = status;
|
|
9
|
+
this.code = code;
|
|
10
|
+
this.name = "MotorbayApiError";
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
function asProblem(body) {
|
|
14
|
+
return body && typeof body === "object" ? body : {};
|
|
15
|
+
}
|
|
16
|
+
/** Turns an API error into a message an AI agent can act on. Branches on status and code only. */
|
|
17
|
+
export function describeApiError(status, body, retryAfter) {
|
|
18
|
+
const p = asProblem(body);
|
|
19
|
+
const code = p.code;
|
|
20
|
+
const wait = retryAfter ? ` Retry in ${retryAfter} seconds.` : "";
|
|
21
|
+
let msg;
|
|
22
|
+
if (status === 401 && code === "ApiKeyMissing") {
|
|
23
|
+
msg = "Motorbay API key missing. Set MOTORBAY_API_KEY in the MCP server config.";
|
|
24
|
+
}
|
|
25
|
+
else if (status === 401) {
|
|
26
|
+
msg = `Motorbay API key not valid (unknown, revoked, expired or from another environment). Check MOTORBAY_API_KEY, or create a new key at ${CONSOLE_URL}.`;
|
|
27
|
+
}
|
|
28
|
+
else if (status === 402) {
|
|
29
|
+
msg = `The Motorbay account for this key has no active plan or trial. Choose a plan at ${PRICING_URL}.`;
|
|
30
|
+
}
|
|
31
|
+
else if (status === 429 && code === "QuotaExceeded") {
|
|
32
|
+
msg = `The monthly quota for this Motorbay plan is used up. Upgrade the plan at ${PRICING_URL}, or wait for the reset at 00:00 UTC on the 1st. Do not retry now.`;
|
|
33
|
+
}
|
|
34
|
+
else if (status === 429) {
|
|
35
|
+
msg = `Motorbay rate limit reached (60 requests per minute per key).${wait || " Retry in up to 60 seconds."}`;
|
|
36
|
+
}
|
|
37
|
+
else if (status === 404 && code === "VehicleNotFound") {
|
|
38
|
+
msg = "No vehicle found. The data is Motorstyrelsen's public extract, updated weekly, so a very new registration may not be there yet. Do not retry now.";
|
|
39
|
+
}
|
|
40
|
+
else if (status === 404) {
|
|
41
|
+
msg = `Not found${code ? ` (${code})` : ""}. ${p.detail ?? "Check the id."}`;
|
|
42
|
+
}
|
|
43
|
+
else if (status === 400) {
|
|
44
|
+
const rules = p.errors
|
|
45
|
+
? Object.entries(p.errors).map(([k, v]) => `${k}: ${v.join(" ")}`).join("; ")
|
|
46
|
+
: p.detail ?? "a parameter is malformed";
|
|
47
|
+
msg = `Invalid request: ${rules}. Fix the input; the same request fails again.`;
|
|
48
|
+
}
|
|
49
|
+
else if (status >= 500) {
|
|
50
|
+
msg = `Motorbay API error ${status}${code ? ` (${code})` : ""}.${wait || " Retry after a short pause."}`;
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
msg = `Motorbay API error ${status}${code ? ` (${code})` : ""}: ${p.detail ?? p.title ?? "unexpected response"}.`;
|
|
54
|
+
}
|
|
55
|
+
return p.requestId ? `${msg} Request ID: ${p.requestId}` : msg;
|
|
56
|
+
}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
3
|
+
import { MotorbayClient, DEFAULT_BASE_URL } from "./client.js";
|
|
4
|
+
import { fetchAvailablePaths } from "./capabilities.js";
|
|
5
|
+
import { buildServer } from "./server.js";
|
|
6
|
+
import { VERSION } from "./version.js";
|
|
7
|
+
const apiKey = process.env.MOTORBAY_API_KEY?.trim() || undefined;
|
|
8
|
+
const baseUrl = process.env.MOTORBAY_API_URL?.trim() || DEFAULT_BASE_URL;
|
|
9
|
+
if (!apiKey)
|
|
10
|
+
console.error("motorbay-mcp: MOTORBAY_API_KEY is not set. Tool calls will fail until it is. Create a key at https://app.motorbay.app");
|
|
11
|
+
const client = new MotorbayClient({ apiKey, baseUrl, userAgent: `motorbay-mcp/${VERSION}` });
|
|
12
|
+
const paths = await fetchAvailablePaths(baseUrl);
|
|
13
|
+
const server = buildServer(client, paths);
|
|
14
|
+
await server.connect(new StdioServerTransport());
|
package/dist/server.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
import { availableTools, buildRequest } from "./tools.js";
|
|
3
|
+
import { VERSION } from "./version.js";
|
|
4
|
+
const text = (t, isError = false) => ({ content: [{ type: "text", text: t }], ...(isError ? { isError } : {}) });
|
|
5
|
+
/** `paths` is the set of paths from the API's OpenAPI document, or null if it couldn't be read. */
|
|
6
|
+
export function buildServer(client, paths) {
|
|
7
|
+
const server = new McpServer({ name: "motorbay", version: VERSION });
|
|
8
|
+
for (const tool of availableTools(paths)) {
|
|
9
|
+
server.registerTool(tool.name, { title: tool.title, description: tool.description, inputSchema: tool.input, annotations: { readOnlyHint: true, openWorldHint: true } }, async (args) => {
|
|
10
|
+
const req = buildRequest(tool.path, args);
|
|
11
|
+
try {
|
|
12
|
+
const res = await client.get(req.path, req.query);
|
|
13
|
+
if (res.status === 204)
|
|
14
|
+
return text(JSON.stringify({ found: false, message: tool.noContent ?? "No record." }));
|
|
15
|
+
return text(JSON.stringify(res.body));
|
|
16
|
+
}
|
|
17
|
+
catch (e) {
|
|
18
|
+
return text(e.message, true);
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
return server;
|
|
23
|
+
}
|
package/dist/tools.js
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
const id = (what) => z.string().regex(/^\d{1,19}$/, "A Motorbay id is a string of digits").describe(what);
|
|
3
|
+
const vehicleId = id("The vehicle's Motorbay id (the `id` field from a vehicle lookup), e.g. \"1000123456\".");
|
|
4
|
+
const page = z.number().int().min(1).optional().describe("Page number, from 1. Default 1.");
|
|
5
|
+
const pageSize = z.number().int().min(1).max(50).optional().describe("Items per page, 1 to 50. Default 10.");
|
|
6
|
+
const SOURCE = "Data is from Motorstyrelsen's public weekly extract of the Danish Motor Register, updated weekly. It holds no owner information.";
|
|
7
|
+
export const TOOLS = [
|
|
8
|
+
{
|
|
9
|
+
name: "get_vehicle_by_plate",
|
|
10
|
+
title: "Vehicle by plate",
|
|
11
|
+
path: "/v1/vehicles/plate/{plate}",
|
|
12
|
+
description: `Look up a Danish vehicle by registration number (plate), e.g. "AB12345". Case, spaces and hyphens are ignored. Returns make, model, variant, VIN, kind, color, first registration date, registration status and the vehicle's id, which the other vehicle tools take. Plates are reused: this returns the vehicle currently registered with the plate; use search_vehicles with registrationNumber for every vehicle that has carried it. ${SOURCE}`,
|
|
13
|
+
input: { plate: z.string().min(1).max(20).describe("Danish registration number, e.g. \"AB12345\" or \"ab 12 345\".") },
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
name: "get_vehicle_by_vin",
|
|
17
|
+
title: "Vehicle by VIN",
|
|
18
|
+
path: "/v1/vehicles/vin/{vin}",
|
|
19
|
+
description: `Look up a vehicle in the Danish register by VIN (chassis/frame number). Returns the same fields as get_vehicle_by_plate, including the id used by the other vehicle tools. ${SOURCE}`,
|
|
20
|
+
input: { vin: z.string().min(1).max(40).describe("Vehicle identification number, e.g. \"WVWZZZAUZKW123456\".") },
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
name: "get_vehicle",
|
|
24
|
+
title: "Vehicle by id",
|
|
25
|
+
path: "/v1/vehicles/{id}",
|
|
26
|
+
description: `Get a vehicle by its Motorbay id (from a previous lookup or search). Returns make, model, variant, VIN, plate, kind, color, dates and registration status. ${SOURCE}`,
|
|
27
|
+
input: { id: id("The vehicle's Motorbay id, e.g. \"1000123456\".") },
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
name: "get_vehicle_inspection",
|
|
31
|
+
title: "Latest inspection",
|
|
32
|
+
path: "/v1/vehicles/{vehicleId}/inspection",
|
|
33
|
+
description: "Get the vehicle's latest inspection report (syn): type, date, result (approved, rejected and so on) and odometer reading in km at the inspection. Useful for checking mileage and whether the vehicle passed.",
|
|
34
|
+
input: { vehicleId },
|
|
35
|
+
noContent: "The register has no inspection record for this vehicle.",
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
name: "get_vehicle_technical_details",
|
|
39
|
+
title: "Technical details",
|
|
40
|
+
path: "/v1/vehicles/{vehicleId}/technical-details",
|
|
41
|
+
description: "Get the vehicle's technical details: weights (kg), seats, doors, axles, body type, model year, maximum speed, towing capacity, type approval numbers, and flags such as hasTrafficDamage and isSuitableForTaxi.",
|
|
42
|
+
input: { vehicleId },
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
name: "get_vehicle_engine",
|
|
46
|
+
title: "Engine",
|
|
47
|
+
path: "/v1/vehicles/{vehicleId}/engine",
|
|
48
|
+
description: "Get the vehicle's engine information: maximum power (kW), displacement (cm3), cylinders, engine marking, noise levels and recorded odometer reading.",
|
|
49
|
+
input: { vehicleId },
|
|
50
|
+
noContent: "The register has no engine record for this vehicle.",
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
name: "get_vehicle_environmental_information",
|
|
54
|
+
title: "Environmental information",
|
|
55
|
+
path: "/v1/vehicles/{vehicleId}/environmental-information",
|
|
56
|
+
description: "Get the vehicle's environmental data: CO2 emission and CO2 group, NOx, CO, particle emission, particle filter and smoke density.",
|
|
57
|
+
input: { vehicleId },
|
|
58
|
+
noContent: "The register has no environmental record for this vehicle.",
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
name: "list_vehicle_fuel_types",
|
|
62
|
+
title: "Fuel types",
|
|
63
|
+
path: "/v1/vehicles/{vehicleId}/fuel-types",
|
|
64
|
+
description: "List the vehicle's fuel types (petrol, diesel, electricity and so on), which one is primary, fuel economy in km per liter, CO2 emission and electric consumption. Paginated.",
|
|
65
|
+
input: { vehicleId, page, pageSize },
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
name: "list_vehicle_equipment",
|
|
69
|
+
title: "Equipment",
|
|
70
|
+
path: "/v1/vehicles/{vehicleId}/equipment",
|
|
71
|
+
description: "List equipment registered on the vehicle (for example airbags, tow bar, sunroof) with a count for each. Names are in Danish as Motorstyrelsen writes them. Paginated.",
|
|
72
|
+
input: { vehicleId, page, pageSize },
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
name: "list_vehicle_secondary_usages",
|
|
76
|
+
title: "Secondary usages",
|
|
77
|
+
path: "/v1/vehicles/{vehicleId}/secondary-usages",
|
|
78
|
+
description: "List the vehicle's secondary usages besides its primary usage, for example rental (Udlejning). Names are in Danish. Paginated.",
|
|
79
|
+
input: { vehicleId, page, pageSize },
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
name: "search_vehicles",
|
|
83
|
+
title: "Search vehicles",
|
|
84
|
+
path: "/v1/vehicles",
|
|
85
|
+
description: "Search Danish vehicles by filters. Use registrationNumber to list every vehicle that has carried a plate (plate history). makeId, kindId, usageId and colorId are Motorbay ids, which appear on any vehicle result (e.g. makeId). Returns { data, metadata: { page, pageSize, totalCount, totalPages } }. page × pageSize may be at most 10,000.",
|
|
86
|
+
input: {
|
|
87
|
+
registrationNumber: z.string().max(20).optional().describe("Every vehicle that has carried this plate."),
|
|
88
|
+
makeId: id("Make id, e.g. the makeId of a vehicle.").optional(),
|
|
89
|
+
kindId: id("Vehicle kind id.").optional(),
|
|
90
|
+
usageId: id("Usage id.").optional(),
|
|
91
|
+
colorId: id("Color id.").optional(),
|
|
92
|
+
fromModelYear: z.number().int().optional().describe("Earliest model year, inclusive."),
|
|
93
|
+
toModelYear: z.number().int().optional().describe("Latest model year, inclusive."),
|
|
94
|
+
sortBy: z
|
|
95
|
+
.enum(["firstRegisteredOn", "-firstRegisteredOn", "vin", "-vin", "registrationNumber", "-registrationNumber", "id", "-id"])
|
|
96
|
+
.optional()
|
|
97
|
+
.describe("Sort order. A leading \"-\" sorts descending. Default -firstRegisteredOn."),
|
|
98
|
+
page,
|
|
99
|
+
pageSize,
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
name: "check_vehicle",
|
|
104
|
+
title: "Used-car check",
|
|
105
|
+
path: "/v1/vehicles/{vehicleId}/check",
|
|
106
|
+
description: "Run a used-car risk check on a vehicle by its Motorbay id: registration status, blocks, traffic damage, restamped VIN, active leasing, latest inspection, and flags with a severity, the most serious first. It reflects the latest weekly extract, so no flags is not a guarantee.",
|
|
107
|
+
input: { vehicleId },
|
|
108
|
+
},
|
|
109
|
+
];
|
|
110
|
+
/** Fills `{name}` placeholders from args and returns the rest as query parameters. */
|
|
111
|
+
export function buildRequest(path, args) {
|
|
112
|
+
const query = {};
|
|
113
|
+
const used = new Set();
|
|
114
|
+
const filled = path.replace(/\{(\w+)\}/g, (_, name) => {
|
|
115
|
+
used.add(name);
|
|
116
|
+
return encodeURIComponent(String(args[name] ?? ""));
|
|
117
|
+
});
|
|
118
|
+
for (const [k, v] of Object.entries(args))
|
|
119
|
+
if (!used.has(k) && v !== undefined)
|
|
120
|
+
query[k] = v;
|
|
121
|
+
return { path: filled, query };
|
|
122
|
+
}
|
|
123
|
+
export function availableTools(paths) {
|
|
124
|
+
return paths ? TOOLS.filter((t) => paths.has(t.path)) : TOOLS;
|
|
125
|
+
}
|
package/dist/version.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const VERSION = "0.1.1";
|
package/package.json
CHANGED
|
@@ -1,6 +1,46 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@motorbay/mcp",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "MCP server for the Motorbay API: Danish vehicle data from Motorstyrelsen's public weekly extract.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"bin": {
|
|
8
|
+
"motorbay-mcp": "dist/index.js"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"dist",
|
|
12
|
+
"README.md"
|
|
13
|
+
],
|
|
14
|
+
"engines": {
|
|
15
|
+
"node": ">=20"
|
|
16
|
+
},
|
|
17
|
+
"scripts": {
|
|
18
|
+
"build": "tsc -p tsconfig.json",
|
|
19
|
+
"test": "vitest run",
|
|
20
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
21
|
+
"prepublishOnly": "npm run build && npm test",
|
|
22
|
+
"refresh-openapi": "sh scripts/refresh-openapi.sh"
|
|
23
|
+
},
|
|
24
|
+
"keywords": [
|
|
25
|
+
"mcp",
|
|
26
|
+
"model-context-protocol",
|
|
27
|
+
"denmark",
|
|
28
|
+
"vehicles",
|
|
29
|
+
"dmr"
|
|
30
|
+
],
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"@modelcontextprotocol/sdk": "^1.32.1",
|
|
33
|
+
"zod": "^4.6.5"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@types/node": "^26.6.4",
|
|
37
|
+
"ajv": "^8.20.0",
|
|
38
|
+
"ajv-formats": "^3.0.1",
|
|
39
|
+
"typescript": "^7.0.2",
|
|
40
|
+
"vitest": "^5.0.3"
|
|
41
|
+
},
|
|
42
|
+
"publishConfig": {
|
|
43
|
+
"access": "public"
|
|
44
|
+
},
|
|
45
|
+
"homepage": "https://app.motorbay.app"
|
|
46
|
+
}
|