@pipeworx/mcp-nhtsa 0.1.0
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 +31 -0
- package/package.json +18 -0
- package/src/index.ts +164 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Pipeworx
|
|
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
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# @pipeworx/mcp-nhtsa
|
|
2
|
+
|
|
3
|
+
MCP server for vehicle data via the [NHTSA vPIC API](https://vpic.nhtsa.dot.gov/api/). Free, no authentication required.
|
|
4
|
+
|
|
5
|
+
## Tools
|
|
6
|
+
|
|
7
|
+
| Tool | Description |
|
|
8
|
+
|------|-------------|
|
|
9
|
+
| `decode_vin` | Decode a 17-character VIN to get make, model, year, body style, engine, and more |
|
|
10
|
+
| `get_makes` | Retrieve all vehicle makes (brands) registered with NHTSA |
|
|
11
|
+
| `get_models` | Get all vehicle models for a specific make and model year |
|
|
12
|
+
|
|
13
|
+
## Quickstart via Pipeworx Gateway
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
curl -X POST https://gateway.pipeworx.io/mcp \
|
|
17
|
+
-H "Content-Type: application/json" \
|
|
18
|
+
-d '{
|
|
19
|
+
"jsonrpc": "2.0",
|
|
20
|
+
"method": "tools/call",
|
|
21
|
+
"params": {
|
|
22
|
+
"name": "nhtsa__decode_vin",
|
|
23
|
+
"arguments": { "vin": "1HGBH41JXMN109186" }
|
|
24
|
+
},
|
|
25
|
+
"id": 1
|
|
26
|
+
}'
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## License
|
|
30
|
+
|
|
31
|
+
MIT
|
package/package.json
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@pipeworx/mcp-nhtsa",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "MCP server for vehicle data (VIN decoding, makes, models) via NHTSA vPIC API",
|
|
5
|
+
"main": "src/index.ts",
|
|
6
|
+
"types": "src/index.ts",
|
|
7
|
+
"files": ["src"],
|
|
8
|
+
"scripts": {
|
|
9
|
+
"build": "tsc",
|
|
10
|
+
"check": "tsc --noEmit"
|
|
11
|
+
},
|
|
12
|
+
"keywords": ["mcp", "mcp-server", "model-context-protocol", "pipeworx", "nhtsa", "vehicles", "vin", "automotive"],
|
|
13
|
+
"author": "Pipeworx",
|
|
14
|
+
"license": "MIT",
|
|
15
|
+
"devDependencies": {
|
|
16
|
+
"typescript": "^5.0.0"
|
|
17
|
+
}
|
|
18
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* NHTSA MCP — wraps the NHTSA vPIC (Vehicle Product Information Catalog) API (free, no auth)
|
|
3
|
+
*
|
|
4
|
+
* Tools:
|
|
5
|
+
* - decode_vin: decode a Vehicle Identification Number into make, model, year, and attributes
|
|
6
|
+
* - get_makes: retrieve all vehicle makes registered with NHTSA
|
|
7
|
+
* - get_models: retrieve all models for a given make and model year
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
interface McpToolDefinition {
|
|
11
|
+
name: string;
|
|
12
|
+
description: string;
|
|
13
|
+
inputSchema: {
|
|
14
|
+
type: 'object';
|
|
15
|
+
properties: Record<string, unknown>;
|
|
16
|
+
required?: string[];
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
interface McpToolExport {
|
|
21
|
+
tools: McpToolDefinition[];
|
|
22
|
+
callTool: (name: string, args: Record<string, unknown>) => Promise<unknown>;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const BASE_URL = 'https://vpic.nhtsa.dot.gov/api';
|
|
26
|
+
|
|
27
|
+
const tools: McpToolExport['tools'] = [
|
|
28
|
+
{
|
|
29
|
+
name: 'decode_vin',
|
|
30
|
+
description:
|
|
31
|
+
'Decode a 17-character Vehicle Identification Number (VIN) to get make, model, year, body style, engine, and other attributes.',
|
|
32
|
+
inputSchema: {
|
|
33
|
+
type: 'object' as const,
|
|
34
|
+
properties: {
|
|
35
|
+
vin: {
|
|
36
|
+
type: 'string',
|
|
37
|
+
description: '17-character VIN (e.g., "1HGBH41JXMN109186")',
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
required: ['vin'],
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
name: 'get_makes',
|
|
45
|
+
description: 'Retrieve all vehicle makes (brands) registered with NHTSA.',
|
|
46
|
+
inputSchema: {
|
|
47
|
+
type: 'object' as const,
|
|
48
|
+
properties: {},
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
name: 'get_models',
|
|
53
|
+
description: 'Get all vehicle models available for a specific make and model year.',
|
|
54
|
+
inputSchema: {
|
|
55
|
+
type: 'object' as const,
|
|
56
|
+
properties: {
|
|
57
|
+
make: { type: 'string', description: 'Vehicle make name (e.g., "Toyota", "Ford", "BMW")' },
|
|
58
|
+
year: { type: 'number', description: 'Model year (e.g., 2022)' },
|
|
59
|
+
},
|
|
60
|
+
required: ['make', 'year'],
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
];
|
|
64
|
+
|
|
65
|
+
async function callTool(name: string, args: Record<string, unknown>): Promise<unknown> {
|
|
66
|
+
switch (name) {
|
|
67
|
+
case 'decode_vin':
|
|
68
|
+
return decodeVin(args.vin as string);
|
|
69
|
+
case 'get_makes':
|
|
70
|
+
return getMakes();
|
|
71
|
+
case 'get_models':
|
|
72
|
+
return getModels(args.make as string, args.year as number);
|
|
73
|
+
default:
|
|
74
|
+
throw new Error(`Unknown tool: ${name}`);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
interface NhtsaResult {
|
|
79
|
+
Variable?: string;
|
|
80
|
+
Value?: string | null;
|
|
81
|
+
ValueId?: string | null;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
async function decodeVin(vin: string) {
|
|
85
|
+
const res = await fetch(`${BASE_URL}/vehicles/DecodeVin/${encodeURIComponent(vin)}?format=json`);
|
|
86
|
+
if (!res.ok) throw new Error(`NHTSA error: ${res.status} ${res.statusText}`);
|
|
87
|
+
|
|
88
|
+
const data = (await res.json()) as { Results?: NhtsaResult[]; Message?: string };
|
|
89
|
+
|
|
90
|
+
if (!data.Results || data.Results.length === 0) {
|
|
91
|
+
throw new Error('No results returned for VIN');
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// Collect all non-null, non-empty decoded fields
|
|
95
|
+
const attributes: Record<string, string> = {};
|
|
96
|
+
for (const r of data.Results) {
|
|
97
|
+
if (r.Variable && r.Value && r.Value.trim() !== '' && r.Value !== 'Not Applicable') {
|
|
98
|
+
attributes[r.Variable] = r.Value;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// Pull out top-level fields for easy access
|
|
103
|
+
return {
|
|
104
|
+
vin: vin.toUpperCase(),
|
|
105
|
+
make: attributes['Make'] ?? null,
|
|
106
|
+
model: attributes['Model'] ?? null,
|
|
107
|
+
model_year: attributes['Model Year'] ?? null,
|
|
108
|
+
trim: attributes['Trim'] ?? null,
|
|
109
|
+
vehicle_type: attributes['Vehicle Type'] ?? null,
|
|
110
|
+
body_class: attributes['Body Class'] ?? null,
|
|
111
|
+
doors: attributes['Doors'] ?? null,
|
|
112
|
+
drive_type: attributes['Drive Type'] ?? null,
|
|
113
|
+
fuel_type_primary: attributes['Fuel Type - Primary'] ?? null,
|
|
114
|
+
engine_cylinders: attributes['Engine Number of Cylinders'] ?? null,
|
|
115
|
+
engine_displacement_l: attributes['Displacement (L)'] ?? null,
|
|
116
|
+
transmission: attributes['Transmission Style'] ?? null,
|
|
117
|
+
plant_country: attributes['Plant Country'] ?? null,
|
|
118
|
+
manufacturer: attributes['Manufacturer Name'] ?? null,
|
|
119
|
+
all_attributes: attributes,
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
async function getMakes() {
|
|
124
|
+
const res = await fetch(`${BASE_URL}/vehicles/GetAllMakes?format=json`);
|
|
125
|
+
if (!res.ok) throw new Error(`NHTSA error: ${res.status} ${res.statusText}`);
|
|
126
|
+
|
|
127
|
+
const data = (await res.json()) as {
|
|
128
|
+
Results?: { Make_ID?: number; Make_Name?: string }[];
|
|
129
|
+
Count?: number;
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
return {
|
|
133
|
+
count: data.Count ?? (data.Results?.length ?? 0),
|
|
134
|
+
makes: (data.Results ?? []).map((m) => ({
|
|
135
|
+
id: m.Make_ID ?? null,
|
|
136
|
+
name: m.Make_Name ?? null,
|
|
137
|
+
})),
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
async function getModels(make: string, year: number) {
|
|
142
|
+
const url = `${BASE_URL}/vehicles/GetModelsForMakeYear/make/${encodeURIComponent(make)}/modelyear/${year}?format=json`;
|
|
143
|
+
const res = await fetch(url);
|
|
144
|
+
if (!res.ok) throw new Error(`NHTSA error: ${res.status} ${res.statusText}`);
|
|
145
|
+
|
|
146
|
+
const data = (await res.json()) as {
|
|
147
|
+
Results?: { Make_ID?: number; Make_Name?: string; Model_ID?: number; Model_Name?: string }[];
|
|
148
|
+
Count?: number;
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
return {
|
|
152
|
+
make,
|
|
153
|
+
year,
|
|
154
|
+
count: data.Count ?? (data.Results?.length ?? 0),
|
|
155
|
+
models: (data.Results ?? []).map((m) => ({
|
|
156
|
+
make_id: m.Make_ID ?? null,
|
|
157
|
+
make_name: m.Make_Name ?? null,
|
|
158
|
+
model_id: m.Model_ID ?? null,
|
|
159
|
+
model_name: m.Model_Name ?? null,
|
|
160
|
+
})),
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export default { tools, callTool } satisfies McpToolExport;
|