@pipeworx/mcp-gsa-perdiem 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 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,55 @@
1
+ # mcp-gsa-perdiem
2
+
3
+ GSA Per Diem MCP — wraps the GSA Per Diem API v2 (api.gsa.gov)
4
+
5
+ Part of [Pipeworx](https://pipeworx.io) — an MCP gateway connecting AI agents to 764+ live data sources.
6
+
7
+ ## Tools
8
+
9
+ | Tool | Description |
10
+ |------|-------------|
11
+
12
+ ## Quick Start
13
+
14
+ Add to your MCP client (Claude Desktop, Cursor, Windsurf, etc.):
15
+
16
+ ```json
17
+ {
18
+ "mcpServers": {
19
+ "gsa-perdiem": {
20
+ "url": "https://gateway.pipeworx.io/gsa-perdiem/mcp"
21
+ }
22
+ }
23
+ }
24
+ ```
25
+
26
+ Or connect to the full Pipeworx gateway for access to all 764+ data sources:
27
+
28
+ ```json
29
+ {
30
+ "mcpServers": {
31
+ "pipeworx": {
32
+ "url": "https://gateway.pipeworx.io/mcp"
33
+ }
34
+ }
35
+ }
36
+ ```
37
+
38
+ ## Using with ask_pipeworx
39
+
40
+ Instead of calling tools directly, you can ask questions in plain English:
41
+
42
+ ```
43
+ ask_pipeworx({ question: "your question about Gsa Perdiem data" })
44
+ ```
45
+
46
+ The gateway picks the right tool and fills the arguments automatically.
47
+
48
+ ## More
49
+
50
+ - [All tools and guides](https://github.com/pipeworx-io/examples)
51
+ - [pipeworx.io](https://pipeworx.io)
52
+
53
+ ## License
54
+
55
+ MIT
package/package.json ADDED
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "@pipeworx/mcp-gsa-perdiem",
3
+ "version": "0.1.0",
4
+ "description": "GSA Per Diem MCP — wraps the GSA Per Diem API v2 (api.gsa.gov)",
5
+ "type": "module",
6
+ "main": "src/index.ts",
7
+ "types": "src/index.ts",
8
+ "keywords": ["mcp", "mcp-server", "model-context-protocol", "pipeworx", "gsa-perdiem"],
9
+ "license": "MIT",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "https://github.com/pipeworx-io/mcp-gsa-perdiem"
13
+ },
14
+ "scripts": {
15
+ "typecheck": "tsc --noEmit"
16
+ },
17
+ "devDependencies": {
18
+ "typescript": "^5.7.0"
19
+ }
20
+ }
package/server.json ADDED
@@ -0,0 +1,18 @@
1
+ {
2
+ "$schema": "https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json",
3
+ "name": "io.github.pipeworx-io/gsa-perdiem",
4
+ "title": "Gsa Perdiem",
5
+ "description": "GSA Per Diem MCP — wraps the GSA Per Diem API v2 (api.gsa.gov)",
6
+ "version": "0.1.0",
7
+ "websiteUrl": "https://pipeworx.io/packs/gsa-perdiem",
8
+ "repository": {
9
+ "url": "https://github.com/pipeworx-io/mcp-gsa-perdiem",
10
+ "source": "github"
11
+ },
12
+ "remotes": [
13
+ {
14
+ "type": "streamable-http",
15
+ "url": "https://gateway.pipeworx.io/gsa-perdiem/mcp"
16
+ }
17
+ ]
18
+ }
package/src/index.ts ADDED
@@ -0,0 +1,190 @@
1
+ interface McpToolDefinition {
2
+ name: string;
3
+ description: string;
4
+ inputSchema: {
5
+ type: 'object';
6
+ properties: Record<string, unknown>;
7
+ required?: string[];
8
+ };
9
+ }
10
+
11
+ interface McpToolExport {
12
+ tools: McpToolDefinition[];
13
+ callTool: (name: string, args: Record<string, unknown>) => Promise<unknown>;
14
+ meter?: { credits: number };
15
+ cost?: Record<string, unknown>;
16
+ provider?: string;
17
+ }
18
+
19
+ /**
20
+ * GSA Per Diem MCP — wraps the GSA Per Diem API v2 (api.gsa.gov)
21
+ *
22
+ * US federal per diem rates: government travel lodging and meal allowances.
23
+ * Returns GSA per diem by city/state or by zip code — the daily lodging
24
+ * ceiling (which varies by month/season) and the flat M&IE (meals &
25
+ * incidental expenses) daily rate.
26
+ *
27
+ * Dual key model: pass your own api.data.gov / GSA API key via _apiKey for
28
+ * higher rate limits, or omit it to use the shared Pipeworx key. The key is
29
+ * sent in the X-Api-Key header (api.data.gov convention).
30
+ *
31
+ * Tools:
32
+ * - rates_by_city: federal per diem rates for a city + state (+ optional year)
33
+ * - rates_by_zip: federal per diem rates for a zip code (+ optional year)
34
+ */
35
+
36
+
37
+ const BASE_URL = 'https://api.gsa.gov/travel/perdiem/v2';
38
+
39
+ const tools: McpToolExport['tools'] = [
40
+ {
41
+ name: 'rates_by_city',
42
+ description:
43
+ 'Get US federal per diem rates (government travel lodging and meal allowances) for a city by name and state. Returns the monthly lodging ceiling (per-diem lodging varies by month/season) and the flat M&IE (meals & incidental expenses) daily rate. Example: rates_by_city({ city: "Denver", state: "CO" }).',
44
+ inputSchema: {
45
+ type: 'object' as const,
46
+ properties: {
47
+ city: {
48
+ type: 'string',
49
+ description: 'City name, e.g. "Denver", "San Francisco".',
50
+ },
51
+ state: {
52
+ type: 'string',
53
+ description: 'Two-letter state abbreviation, e.g. "CO", "CA".',
54
+ },
55
+ year: {
56
+ type: 'number',
57
+ description: 'Fiscal/rate year, e.g. 2026. Defaults to the current year.',
58
+ },
59
+ _apiKey: {
60
+ type: 'string',
61
+ description:
62
+ 'Optional — your own api.data.gov / GSA API key for higher limits; omit to use the shared Pipeworx key.',
63
+ },
64
+ },
65
+ required: ['city', 'state'],
66
+ },
67
+ },
68
+ {
69
+ name: 'rates_by_zip',
70
+ description:
71
+ 'Get US federal per diem rates (government travel lodging and meal allowances) for a location by zip code. Returns the monthly lodging ceiling (per-diem lodging varies by month/season) and the flat M&IE (meals & incidental expenses) daily rate. Example: rates_by_zip({ zip: "80202" }).',
72
+ inputSchema: {
73
+ type: 'object' as const,
74
+ properties: {
75
+ zip: {
76
+ type: 'string',
77
+ description: '5-digit US zip code, e.g. "80202".',
78
+ },
79
+ year: {
80
+ type: 'number',
81
+ description: 'Fiscal/rate year, e.g. 2026. Defaults to the current year.',
82
+ },
83
+ _apiKey: {
84
+ type: 'string',
85
+ description:
86
+ 'Optional — your own api.data.gov / GSA API key for higher limits; omit to use the shared Pipeworx key.',
87
+ },
88
+ },
89
+ required: ['zip'],
90
+ },
91
+ },
92
+ ];
93
+
94
+ // GSA Per Diem v2 response shape (partial — only the fields we compact).
95
+ interface PerDiemMonthEntry {
96
+ short?: string;
97
+ value?: number | string;
98
+ }
99
+ interface PerDiemRate {
100
+ city?: string;
101
+ county?: string;
102
+ meals?: number | string;
103
+ months?: { month?: PerDiemMonthEntry[] };
104
+ }
105
+ interface PerDiemResponse {
106
+ rates?: Array<{ rate?: PerDiemRate[] }>;
107
+ }
108
+
109
+ function compactRates(rates: PerDiemResponse['rates']) {
110
+ return (rates?.[0]?.rate || []).map((r) => ({
111
+ destination: r.city || r.county,
112
+ meals_mie: r.meals,
113
+ monthly_lodging: (r.months?.month || []).map((m) => ({
114
+ month: m.short,
115
+ lodging: m.value,
116
+ })),
117
+ }));
118
+ }
119
+
120
+ async function gsaGet(apiKey: string, path: string): Promise<unknown> {
121
+ const res = await fetch(`${BASE_URL}${path}`, {
122
+ headers: {
123
+ 'X-Api-Key': apiKey,
124
+ Accept: 'application/json',
125
+ },
126
+ });
127
+ if (!res.ok) {
128
+ const text = await res.text();
129
+ return { error: res.status, message: text };
130
+ }
131
+ return res.json();
132
+ }
133
+
134
+ async function ratesByCity(
135
+ city: string,
136
+ state: string,
137
+ year: number,
138
+ apiKey: string,
139
+ ) {
140
+ const path = `/rates/city/${encodeURIComponent(city)}/state/${encodeURIComponent(
141
+ state,
142
+ )}/year/${year}`;
143
+ const data = (await gsaGet(apiKey, path)) as PerDiemResponse & { error?: unknown };
144
+ if ((data as { error?: unknown }).error !== undefined) return data;
145
+
146
+ const rates = data.rates;
147
+ return {
148
+ city,
149
+ state,
150
+ year,
151
+ found: !!rates?.length,
152
+ rates: compactRates(rates),
153
+ };
154
+ }
155
+
156
+ async function ratesByZip(zip: string, year: number, apiKey: string) {
157
+ const path = `/rates/zip/${encodeURIComponent(zip)}/year/${year}`;
158
+ const data = (await gsaGet(apiKey, path)) as PerDiemResponse & { error?: unknown };
159
+ if ((data as { error?: unknown }).error !== undefined) return data;
160
+
161
+ const rates = data.rates;
162
+ return {
163
+ zip,
164
+ year,
165
+ found: !!rates?.length,
166
+ rates: compactRates(rates),
167
+ };
168
+ }
169
+
170
+ async function callTool(name: string, args: Record<string, unknown>): Promise<unknown> {
171
+ const apiKey = args._apiKey as string;
172
+ delete args._apiKey;
173
+
174
+ if (!apiKey) {
175
+ return { error: 'api_key_required', message: 'No GSA/api.data.gov key available.' };
176
+ }
177
+
178
+ const year = (args.year as number | undefined) ?? new Date().getFullYear();
179
+
180
+ switch (name) {
181
+ case 'rates_by_city':
182
+ return ratesByCity(args.city as string, args.state as string, year, apiKey);
183
+ case 'rates_by_zip':
184
+ return ratesByZip(args.zip as string, year, apiKey);
185
+ default:
186
+ throw new Error(`Unknown tool: ${name}`);
187
+ }
188
+ }
189
+
190
+ export default { tools, callTool, meter: { credits: 1 } } satisfies McpToolExport;
package/tsconfig.json ADDED
@@ -0,0 +1,14 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "module": "ESNext",
5
+ "moduleResolution": "bundler",
6
+ "strict": true,
7
+ "esModuleInterop": true,
8
+ "skipLibCheck": true,
9
+ "outDir": "dist",
10
+ "rootDir": "src",
11
+ "declaration": true
12
+ },
13
+ "include": ["src"]
14
+ }