@pipeworx/mcp-census-business 0.0.0-stage → 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 +148 -2
- package/bin/cli.js +61 -0
- package/lib/index.js +333 -0
- package/package.json +31 -4
- package/server.json +18 -0
- package/tools.json +222 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Mojibake Inc.
|
|
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,149 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @pipeworx/census-business
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
How big is an industry? U.S. Census Bureau business statistics by NAICS industry and geography: employer establishments, employees and payroll (County Business Patterns), nonemployer businesses, Economic Census receipts, employer-firm owner demographics (Annual Business Survey), and monthly retail and quarterly services sales series.
|
|
4
|
+
|
|
5
|
+
Part of [Pipeworx](https://pipeworx.io) — an MCP gateway connecting AI agents to 2034+ live data sources. This is an independent, unofficial integration — not affiliated with, endorsed by, or published by the upstream provider.
|
|
6
|
+
|
|
7
|
+
Tools take a plain industry phrase ("dental offices") as well as a NAICS code, a state or county, and a year, and return values with the NAICS title, geography, year, Census dataset name and `data_as_of`.
|
|
8
|
+
|
|
9
|
+
## Tools
|
|
10
|
+
|
|
11
|
+
- `industry_code_search(query)` — industry words to the NAICS codes the Census business datasets use, from the Census Bureau's own industry list.
|
|
12
|
+
- `industry_size(industry, state?, county?, year?, breakdown?)` — establishments, employees, annual payroll and average pay for an industry in the nation, a state or a county (County Business Patterns), plus nonemployer establishments and receipts (Nonemployer Statistics). `breakdown: "state"` ranks every state; `"county"` ranks the counties of a state. Payroll and receipts are returned in dollars (Census publishes thousands).
|
|
13
|
+
- `establishment_size_split(industry, state?, county?, year?)` — establishments, employees and payroll by employment-size class (1-4, 5-9, ... 1,000+), with each class's share of establishments.
|
|
14
|
+
- `economic_census_industry(industry, state?, county?, year?)` — establishments, firms, sales / revenue, payroll and employees from the Economic Census (2022, 2017). The source for total industry revenue.
|
|
15
|
+
- `business_owner_demographics(industry?, dimension?, state?, year?)` — employer firms, receipts, employees and payroll by owner sex, ethnicity, race or veteran status (Annual Business Survey).
|
|
16
|
+
- `monthly_sales_series(program?, category_code?, data_type_code?, from?, to?, list_codes?)` — Monthly Retail Trade (mrts) and Quarterly Services (qss) series; `list_codes: true` shows the codes a program publishes.
|
|
17
|
+
|
|
18
|
+
For full NAICS descriptions, hierarchy, edition and SIC crosswalks, use the `naics` pack. For county employment and wages by industry from a different publisher (BLS), see `qcew`.
|
|
19
|
+
|
|
20
|
+
## Auth
|
|
21
|
+
|
|
22
|
+
Platform key (`PLATFORM_CENSUS_KEY`, the key the `census` pack also uses). The Census data service now answers 302 to a "missing key" page on every data query, so there is no keyless mode; callers do not pass a key.
|
|
23
|
+
|
|
24
|
+
## Data sources
|
|
25
|
+
|
|
26
|
+
- U.S. Census Bureau, County Business Patterns. Reference year 2023 is the latest; payroll is for the whole year, employment is for the week of March 12.
|
|
27
|
+
- U.S. Census Bureau, Nonemployer Statistics.
|
|
28
|
+
- U.S. Census Bureau, Economic Census (2022 and 2017 core statistics).
|
|
29
|
+
- U.S. Census Bureau, Annual Business Survey.
|
|
30
|
+
- U.S. Census Bureau, Monthly Retail Trade Survey and Quarterly Services Survey.
|
|
31
|
+
|
|
32
|
+
U.S. federal data, public domain; proxied live per request, nothing is copied.
|
|
33
|
+
|
|
34
|
+
## Things worth knowing
|
|
35
|
+
|
|
36
|
+
- **NAICS edition.** County Business Patterns still uses the 2017 NAICS through its 2023 data; the 2022 Economic Census and recent Annual Business Surveys use 2022. An industry renumbered in 2022 (software publishers: 511210 became 513210) has a different code in each. A code missing from a dataset's list is reported as such, with a pointer to `industry_code_search`; use the `naics` pack's `naics_crosswalk` to translate.
|
|
37
|
+
- **Nonemployer years.** The nonemployer tables moved to 2022 NAICS in 2022; `industry_size` pairs the CBP year with the latest nonemployer year on the same NAICS edition (2021) and says so rather than mixing editions.
|
|
38
|
+
- **Suppression.** Small cells are withheld or noise-infused. A missing row is reported as "published no ... row", never as zero; `employees_noise_flag` and `payroll_noise_flag` carry Census's own noise-range letter.
|
|
39
|
+
- **Firm-size tables.** Statistics of U.S. Businesses (firm size by industry) is bulk files only, not in the Census data service; `establishment_size_split` answers the size question by establishment employment class instead.
|
|
40
|
+
- **Verification status.** The data endpoints need a key no fleet machine holds, so this pack was built against the services' published metadata and a stubbed response shape; the first live answers come from the post-deploy probe.
|
|
41
|
+
|
|
42
|
+
## Quick Start
|
|
43
|
+
|
|
44
|
+
Add to your MCP client (Claude Desktop, Cursor, Windsurf, etc.):
|
|
45
|
+
|
|
46
|
+
```json
|
|
47
|
+
{
|
|
48
|
+
"mcpServers": {
|
|
49
|
+
"census-business": {
|
|
50
|
+
"url": "https://gateway.pipeworx.io/census-business/mcp"
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### What this endpoint actually serves
|
|
57
|
+
|
|
58
|
+
`tools/list` at `https://gateway.pipeworx.io/census-business/mcp` returns the tools in the table
|
|
59
|
+
above **plus the shared Pipeworx meta-tools** — `ask_pipeworx`,
|
|
60
|
+
`discover_tools`, `search_within`, `remember`/`recall` and the rest of the
|
|
61
|
+
gateway-wide set. So the tool count you see is larger than this table: a
|
|
62
|
+
single-pack endpoint currently lists roughly 30 shared tools alongside the
|
|
63
|
+
pack's own. The connection's `initialize` response states its exact scope, and
|
|
64
|
+
is the authoritative answer for a given day.
|
|
65
|
+
|
|
66
|
+
This is deliberate, not multiplexing by accident. The meta-tools are what let a
|
|
67
|
+
scoped connection answer a question this pack does not cover — via
|
|
68
|
+
`ask_pipeworx`, which routes across the whole catalog — without you adding a
|
|
69
|
+
second MCP server. There is currently no way to mount a pack endpoint without
|
|
70
|
+
them; if the extra schemas cost you more context than the routing is worth,
|
|
71
|
+
connect to the full gateway once rather than to several pack endpoints.
|
|
72
|
+
|
|
73
|
+
Or connect to the full Pipeworx gateway to get every pack's tools listed
|
|
74
|
+
directly, instead of just this one's:
|
|
75
|
+
|
|
76
|
+
```json
|
|
77
|
+
{
|
|
78
|
+
"mcpServers": {
|
|
79
|
+
"pipeworx": {
|
|
80
|
+
"url": "https://gateway.pipeworx.io/mcp"
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Both URLs reach the same gateway and the same 2034+ data sources. The
|
|
87
|
+
only difference is which pack's tools are listed **directly**; `ask_pipeworx`
|
|
88
|
+
reaches all of them from either one.
|
|
89
|
+
|
|
90
|
+
## No MCP client? Call it over HTTP
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
curl -X POST https://gateway.pipeworx.io/v1/tools/industry_code_search \
|
|
94
|
+
-H 'Content-Type: application/json' \
|
|
95
|
+
-d '{"query":"dental offices"}'
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
No account needed for the first calls. Inspect any tool: `GET https://gateway.pipeworx.io/v1/tools/industry_code_search`. Find one: `POST https://gateway.pipeworx.io/v1/tools/search_packs` with `{"query":"..."}`.
|
|
99
|
+
|
|
100
|
+
## Run it from npm
|
|
101
|
+
|
|
102
|
+
`@pipeworx/mcp-census-business` is a local stdio bridge to the Pipeworx gateway: your MCP client
|
|
103
|
+
starts it with `npx`, and it forwards every call to the same
|
|
104
|
+
`https://gateway.pipeworx.io/census-business/mcp` endpoint shown above. It needs network access;
|
|
105
|
+
there is no offline mode.
|
|
106
|
+
|
|
107
|
+
```json
|
|
108
|
+
{
|
|
109
|
+
"mcpServers": {
|
|
110
|
+
"census-business": {
|
|
111
|
+
"command": "npx",
|
|
112
|
+
"args": ["-y", "@pipeworx/mcp-census-business"]
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
Without a key it calls anonymously, capped at 50 calls a day. A free account
|
|
119
|
+
raises that to 200 a day: get a key at https://pipeworx.io/signup and add
|
|
120
|
+
`"env": { "PIPEWORX_API_KEY": "<your key>" }` to the server entry.
|
|
121
|
+
The key is sent as a Bearer token, the same way a hosted connection sends it,
|
|
122
|
+
so calls are metered and billed exactly as they are there.
|
|
123
|
+
|
|
124
|
+
It lists **only** this pack's tools by default. Set `PIPEWORX_META_TOOLS=1` to
|
|
125
|
+
also list `ask_pipeworx` and the other gateway-wide tools.
|
|
126
|
+
|
|
127
|
+
Behind an HTTPS proxy: Node's built-in `fetch` does not read `HTTPS_PROXY` by
|
|
128
|
+
default. Newer Node releases honour it when `NODE_USE_ENV_PROXY=1` is set; check
|
|
129
|
+
your Node version's documentation.
|
|
130
|
+
|
|
131
|
+
## Using with ask_pipeworx
|
|
132
|
+
|
|
133
|
+
Instead of calling tools directly, you can ask questions in plain English —
|
|
134
|
+
this works on the pack endpoint above as well as on the full gateway:
|
|
135
|
+
|
|
136
|
+
```
|
|
137
|
+
ask_pipeworx({ question: "your question about Census Business data" })
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
The gateway picks the right tool and fills the arguments automatically.
|
|
141
|
+
|
|
142
|
+
## More
|
|
143
|
+
|
|
144
|
+
- [Docs and guides](https://pipeworx.io/docs)
|
|
145
|
+
- [pipeworx.io](https://pipeworx.io)
|
|
146
|
+
|
|
147
|
+
## License
|
|
148
|
+
|
|
149
|
+
MIT
|
package/bin/cli.js
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Entry point for `npx @pipeworx/mcp-<slug>` in gateway mode (bin/cli.js).
|
|
3
|
+
//
|
|
4
|
+
// A stdio MCP server that relays every message to the Pipeworx gateway's
|
|
5
|
+
// /<slug>/mcp endpoint -- fleet #3759, docs/standalone-via-gateway-plan.md.
|
|
6
|
+
// It carries no pack code and has no local mode. The relay itself lives in
|
|
7
|
+
// ../lib/index.js (copied from scripts/templates/standalone-gateway-lib.js);
|
|
8
|
+
// this file only owns stdin/stdout.
|
|
9
|
+
//
|
|
10
|
+
// Copied VERBATIM into every gateway-mode package by scripts/publish-pack.sh.
|
|
11
|
+
// Edit scripts/templates/standalone-gateway-cli.js in the monorepo, never a
|
|
12
|
+
// per-pack copy. Zero dependencies, Node 18+.
|
|
13
|
+
//
|
|
14
|
+
// stdout carries newline-delimited JSON-RPC and nothing else; every diagnostic
|
|
15
|
+
// goes to stderr, because a single stray line on stdout breaks the host's
|
|
16
|
+
// parser.
|
|
17
|
+
import { createInterface } from 'node:readline';
|
|
18
|
+
import { relay, bridgeConfig } from '../lib/index.js';
|
|
19
|
+
|
|
20
|
+
const cfg = bridgeConfig();
|
|
21
|
+
const warn = (line) => process.stderr.write(`${line}\n`);
|
|
22
|
+
const write = (msg) => { if (msg) process.stdout.write(`${JSON.stringify(msg)}\n`); };
|
|
23
|
+
|
|
24
|
+
const pending = new Set();
|
|
25
|
+
function track(p) {
|
|
26
|
+
pending.add(p);
|
|
27
|
+
p.finally(() => pending.delete(p));
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
async function handleLine(line) {
|
|
31
|
+
const text = line.trim();
|
|
32
|
+
if (!text) return;
|
|
33
|
+
let message;
|
|
34
|
+
try {
|
|
35
|
+
message = JSON.parse(text);
|
|
36
|
+
} catch {
|
|
37
|
+
write({ jsonrpc: '2.0', id: null, error: { code: -32700, message: 'Parse error' } });
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
// A JSON-RPC batch: relay each member, answer with the non-notification replies.
|
|
41
|
+
if (Array.isArray(message)) {
|
|
42
|
+
const replies = (await Promise.all(message.map((m) => relay(m, { cfg, warn })))).filter(Boolean);
|
|
43
|
+
if (replies.length) write(replies);
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
write(await relay(message, { cfg, warn }));
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// Requests are handled concurrently and answered as they finish: JSON-RPC ids
|
|
50
|
+
// let the host match them, and a slow tool call must not hold up a ping.
|
|
51
|
+
const rl = createInterface({ input: process.stdin, crlfDelay: Infinity });
|
|
52
|
+
rl.on('line', (line) => {
|
|
53
|
+
track(handleLine(line).catch((err) => warn(`pipeworx-standalone: ${err && err.stack ? err.stack : err}`)));
|
|
54
|
+
});
|
|
55
|
+
rl.on('close', async () => {
|
|
56
|
+
// stdin closed: finish what is in flight, then exit.
|
|
57
|
+
while (pending.size) await Promise.allSettled([...pending]);
|
|
58
|
+
// Exit only once stdout has flushed: on a pipe that is not synchronous
|
|
59
|
+
// everywhere, and a bare exit can drop the last reply.
|
|
60
|
+
process.stdout.write('', () => process.exit(0));
|
|
61
|
+
});
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
// @pipeworx/mcp-<slug> -- library half of the gateway bridge (lib/index.js).
|
|
2
|
+
//
|
|
3
|
+
// Copied VERBATIM into every gateway-mode pack package by scripts/publish-pack.sh
|
|
4
|
+
// (fleet #3759, docs/standalone-via-gateway-plan.md section 1). There is no
|
|
5
|
+
// per-pack templating: the slug and version are read from this package's own
|
|
6
|
+
// package.json (`pipeworx.slug`, `version`) at load time, so the same bytes
|
|
7
|
+
// ship in every package and the source hash can cover them once. Edit this
|
|
8
|
+
// file in the monorepo (scripts/templates/standalone-gateway-lib.js), never a
|
|
9
|
+
// per-pack copy.
|
|
10
|
+
//
|
|
11
|
+
// What it is: a relay. Every JSON-RPC message goes to
|
|
12
|
+
// ${PIPEWORX_GATEWAY_URL:-https://gateway.pipeworx.io}/<slug>/mcp, the same
|
|
13
|
+
// endpoint a hosted MCP client uses, so tiers, rate limits and credits apply
|
|
14
|
+
// exactly as they do there. There is no local mode: the pack's code is not in
|
|
15
|
+
// this package.
|
|
16
|
+
//
|
|
17
|
+
// Zero dependencies, plain ESM, Node 18+ (global fetch). Nothing here writes
|
|
18
|
+
// to stdout -- bin/cli.js owns stdout and it carries JSON-RPC only.
|
|
19
|
+
//
|
|
20
|
+
// Environment:
|
|
21
|
+
// PIPEWORX_API_KEY sent as `Authorization: Bearer <key>`. Never as
|
|
22
|
+
// X-API-Key: the gateway reads a pwx_ key sent that way
|
|
23
|
+
// as an unvalidated BYO string with no account.
|
|
24
|
+
// PIPEWORX_GATEWAY_URL gateway base URL (no path), default the public gateway.
|
|
25
|
+
// PIPEWORX_META_TOOLS=1 list the gateway-wide tools (ask_pipeworx, ...) too.
|
|
26
|
+
// PIPEWORX_TIMEOUT_MS per-request timeout, default 120000.
|
|
27
|
+
|
|
28
|
+
import { readFileSync } from 'node:fs';
|
|
29
|
+
|
|
30
|
+
const readJson = (rel) => JSON.parse(readFileSync(new URL(rel, import.meta.url), 'utf8'));
|
|
31
|
+
|
|
32
|
+
const PKG = readJson('../package.json');
|
|
33
|
+
export const SLUG = PKG.pipeworx && PKG.pipeworx.slug;
|
|
34
|
+
if (typeof SLUG !== 'string' || !/^[a-z0-9][a-z0-9_-]*$/.test(SLUG)) {
|
|
35
|
+
throw new Error(`${PKG.name}: package.json carries no valid pipeworx.slug -- this package was built wrong`);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* The pack's slug on the GATEWAY: the /<slug>/mcp route and the `_meta.pack`
|
|
39
|
+
* every listed tool carries. Usually the same as `slug` (the npm/directory
|
|
40
|
+
* name), but 14 packs differ -- `hex-pm` is `hex_pm` on the gateway -- and
|
|
41
|
+
* filtering tools/list on the npm slug would match none of their tools
|
|
42
|
+
* (fleet #3761). publish-pack.sh stamps it from the gateway manifest.
|
|
43
|
+
*/
|
|
44
|
+
export const GATEWAY_SLUG = (PKG.pipeworx && PKG.pipeworx.gatewaySlug) || SLUG;
|
|
45
|
+
if (typeof GATEWAY_SLUG !== 'string' || !/^[a-z0-9][a-z0-9_-]*$/.test(GATEWAY_SLUG)) {
|
|
46
|
+
throw new Error(`${PKG.name}: package.json carries an invalid pipeworx.gatewaySlug -- this package was built wrong`);
|
|
47
|
+
}
|
|
48
|
+
export const PACKAGE_NAME = PKG.name;
|
|
49
|
+
export const VERSION = PKG.version;
|
|
50
|
+
|
|
51
|
+
/** The pack's own tool definitions at publish time (the offline tools/list answer). */
|
|
52
|
+
export const tools = readJson('../tools.json');
|
|
53
|
+
|
|
54
|
+
const DEFAULT_GATEWAY = 'https://gateway.pipeworx.io';
|
|
55
|
+
const DEFAULT_TIMEOUT_MS = 120_000;
|
|
56
|
+
const SIGNUP_URL = 'https://pipeworx.io/signup';
|
|
57
|
+
const VIA = '(via pipeworx-standalone)';
|
|
58
|
+
|
|
59
|
+
/** Resolve the bridge's settings. Exported for the tests and for callTool. */
|
|
60
|
+
export function bridgeConfig(env = process.env, overrides = {}) {
|
|
61
|
+
const base = String(overrides.gatewayUrl || env.PIPEWORX_GATEWAY_URL || DEFAULT_GATEWAY).trim().replace(/\/+$/, '');
|
|
62
|
+
const apiKey = String(overrides.apiKey ?? env.PIPEWORX_API_KEY ?? '').trim();
|
|
63
|
+
const t = Number(overrides.timeoutMs ?? env.PIPEWORX_TIMEOUT_MS);
|
|
64
|
+
return {
|
|
65
|
+
endpoint: `${base}/${GATEWAY_SLUG}/mcp`,
|
|
66
|
+
apiKey,
|
|
67
|
+
timeoutMs: Number.isFinite(t) && t > 0 ? t : DEFAULT_TIMEOUT_MS,
|
|
68
|
+
metaTools: (overrides.metaTools ?? env.PIPEWORX_META_TOOLS) === '1' || overrides.metaTools === true,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function requestHeaders(cfg) {
|
|
73
|
+
const h = {
|
|
74
|
+
'Content-Type': 'application/json',
|
|
75
|
+
Accept: 'application/json',
|
|
76
|
+
// Stable per package version: the gateway remembers a client's name by
|
|
77
|
+
// identifier + User-Agent (workers/gateway/src/client-identity.ts).
|
|
78
|
+
'User-Agent': `pipeworx-standalone/${VERSION} (${PACKAGE_NAME})`,
|
|
79
|
+
// Analytics label only (blob11 = 'standalone'). It never changes tier,
|
|
80
|
+
// limits or price -- anyone can send it.
|
|
81
|
+
'X-Pipeworx-Surface': 'standalone',
|
|
82
|
+
};
|
|
83
|
+
if (cfg.apiKey) h.Authorization = `Bearer ${cfg.apiKey}`;
|
|
84
|
+
return h;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** Parse a gateway body: JSON, or the last JSON `data:` frame of an SSE stream. */
|
|
88
|
+
function parseBody(text, contentType) {
|
|
89
|
+
if (/text\/event-stream/i.test(contentType || '')) {
|
|
90
|
+
let last = null;
|
|
91
|
+
for (const line of text.split(/\r?\n/)) {
|
|
92
|
+
if (!line.startsWith('data:')) continue;
|
|
93
|
+
try { last = JSON.parse(line.slice(5).trim()); } catch { /* keep-alive or partial frame */ }
|
|
94
|
+
}
|
|
95
|
+
return last;
|
|
96
|
+
}
|
|
97
|
+
try { return JSON.parse(text); } catch { return null; }
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* POST one JSON-RPC message. Never throws: the outcome is one of
|
|
102
|
+
* { kind: 'http', status, headers, body, text } the gateway answered
|
|
103
|
+
* { kind: 'network', detail } DNS, TLS, refused, reset
|
|
104
|
+
* { kind: 'timeout' } no answer in cfg.timeoutMs
|
|
105
|
+
*/
|
|
106
|
+
export async function postToGateway(message, cfg) {
|
|
107
|
+
const ac = new AbortController();
|
|
108
|
+
const timer = setTimeout(() => ac.abort(), cfg.timeoutMs);
|
|
109
|
+
try {
|
|
110
|
+
const res = await fetch(cfg.endpoint, {
|
|
111
|
+
method: 'POST',
|
|
112
|
+
headers: requestHeaders(cfg),
|
|
113
|
+
body: JSON.stringify(message),
|
|
114
|
+
signal: ac.signal,
|
|
115
|
+
});
|
|
116
|
+
const text = await res.text();
|
|
117
|
+
return { kind: 'http', status: res.status, headers: res.headers, body: parseBody(text, res.headers.get('content-type')), text };
|
|
118
|
+
} catch (err) {
|
|
119
|
+
if (ac.signal.aborted || (err && (err.name === 'AbortError' || err.name === 'TimeoutError'))) return { kind: 'timeout' };
|
|
120
|
+
const cause = err && err.cause;
|
|
121
|
+
const detail = (cause && (cause.code || cause.message)) || (err && err.message) || String(err);
|
|
122
|
+
return { kind: 'network', detail };
|
|
123
|
+
} finally {
|
|
124
|
+
clearTimeout(timer);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// ── The key-not-accepted warning (one per process) ──────────────────
|
|
129
|
+
|
|
130
|
+
let warnedKeyIgnored = false;
|
|
131
|
+
const KEY_IGNORED = 'PIPEWORX_API_KEY was not accepted, calling anonymously.';
|
|
132
|
+
|
|
133
|
+
/** True when a key was sent but the gateway still served the call as anonymous. */
|
|
134
|
+
function keyIgnored(out, cfg) {
|
|
135
|
+
return !!cfg.apiKey && out.kind === 'http' && (out.headers.get('x-ratelimit-tier') || '').toLowerCase() === 'anonymous';
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function noteTier(out, cfg, warn) {
|
|
139
|
+
if (!keyIgnored(out, cfg) || warnedKeyIgnored) return;
|
|
140
|
+
warnedKeyIgnored = true;
|
|
141
|
+
warn(`${PACKAGE_NAME}: ${KEY_IGNORED} Check the key at ${SIGNUP_URL}.`);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/** Test hook: forget that the warning was printed. */
|
|
145
|
+
export function _resetWarnings() { warnedKeyIgnored = false; }
|
|
146
|
+
|
|
147
|
+
// ── Results the host shows to the model ─────────────────────────────
|
|
148
|
+
|
|
149
|
+
function errorResult(text, detail) {
|
|
150
|
+
const result = { content: [{ type: 'text', text }], isError: true };
|
|
151
|
+
if (detail) result._meta = { pipeworx_standalone: detail };
|
|
152
|
+
return result;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
const rpcResult = (id, result) => ({ jsonrpc: '2.0', id, result });
|
|
156
|
+
const rpcError = (id, code, message) => ({ jsonrpc: '2.0', id, error: { code, message } });
|
|
157
|
+
|
|
158
|
+
function firstLine(text) {
|
|
159
|
+
const line = String(text || '').split(/\r?\n/).map((l) => l.trim()).find(Boolean) || '(empty body)';
|
|
160
|
+
return line.length > 200 ? `${line.slice(0, 200)}...` : line;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
function unreachableText(cfg, out) {
|
|
164
|
+
if (out.kind === 'timeout') {
|
|
165
|
+
return `The Pipeworx gateway at ${cfg.endpoint} did not answer within ${Math.round(cfg.timeoutMs / 1000)}s, so this call timed out. `
|
|
166
|
+
+ `${PACKAGE_NAME} forwards every call to the Pipeworx gateway and has no local mode. Try again; a call that keeps timing out is worth reporting.`;
|
|
167
|
+
}
|
|
168
|
+
return `Could not reach the Pipeworx gateway at ${cfg.endpoint} (${out.detail}). `
|
|
169
|
+
+ `${PACKAGE_NAME} forwards every call to the Pipeworx gateway and has no local mode, so it needs network access.`;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
function isAuthRequired(body) {
|
|
173
|
+
return !!body && (body.error_code === 'authentication_required'
|
|
174
|
+
|| (body.error && body.error.data && body.error.data.reason === 'authentication_required'));
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/** Map a tools/call outcome to the JSON-RPC response the host gets. */
|
|
178
|
+
function toolsCallResponse(id, out, cfg) {
|
|
179
|
+
if (out.kind !== 'http') return rpcResult(id, errorResult(unreachableText(cfg, out), { reason: out.kind }));
|
|
180
|
+
const { status, body } = out;
|
|
181
|
+
|
|
182
|
+
// Anonymous daily cap: the gateway answers 401 with a JSON-RPC error whose
|
|
183
|
+
// message is the offer. Hosts often swallow protocol errors, so hand it over
|
|
184
|
+
// as a tool result the model actually reads.
|
|
185
|
+
if (status === 401 && isAuthRequired(body)) {
|
|
186
|
+
const data = (body.error && body.error.data) || {};
|
|
187
|
+
const parts = [body.error && body.error.message ? body.error.message : 'The anonymous daily allowance is used up.'];
|
|
188
|
+
if (data.resets_at) parts.push(`The anonymous allowance resets at ${data.resets_at}.`);
|
|
189
|
+
parts.push(cfg.apiKey
|
|
190
|
+
? `${KEY_IGNORED} Check the key, or get a free one at ${SIGNUP_URL}.`
|
|
191
|
+
: `To keep going now, set PIPEWORX_API_KEY in this MCP server's environment; a free key is at ${SIGNUP_URL}.`);
|
|
192
|
+
return rpcResult(id, errorResult(parts.join('\n\n'), { status, reason: 'authentication_required', resets_at: data.resets_at ?? null }));
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
// A keyed tier over its cap: today the gateway answers 429 with a RESULT
|
|
196
|
+
// that has no isError, which reads as a success (fleet #3760). Mark it.
|
|
197
|
+
if (status === 429 && body && body.result && typeof body.result === 'object') {
|
|
198
|
+
const result = { ...body.result, isError: true };
|
|
199
|
+
if (cfg.apiKey && keyIgnored(out, cfg)) {
|
|
200
|
+
result.content = [...(Array.isArray(result.content) ? result.content : []), { type: 'text', text: KEY_IGNORED }];
|
|
201
|
+
}
|
|
202
|
+
return rpcResult(id, result);
|
|
203
|
+
}
|
|
204
|
+
if ((status === 401 || status === 429) && body && body.error) {
|
|
205
|
+
const extra = keyIgnored(out, cfg) ? ` ${KEY_IGNORED}` : '';
|
|
206
|
+
return rpcResult(id, errorResult(`${body.error.message || `HTTP ${status}`}${extra}`, { status }));
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
// A real JSON-RPC answer (result or protocol error): relay it verbatim,
|
|
210
|
+
// structuredContent and _meta (cost, tier, provenance) included.
|
|
211
|
+
if (body && body.jsonrpc === '2.0' && (body.result !== undefined || body.error !== undefined) && status < 500) {
|
|
212
|
+
return { ...body, id };
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
// 5xx, an HTML edge page, or anything else that is not JSON-RPC.
|
|
216
|
+
return rpcResult(id, errorResult(`The Pipeworx gateway returned HTTP ${status}: ${firstLine(out.text)}`, { status }));
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
function localInitialize(params) {
|
|
220
|
+
return {
|
|
221
|
+
protocolVersion: (params && params.protocolVersion) || '2025-06-18',
|
|
222
|
+
capabilities: { tools: {} },
|
|
223
|
+
serverInfo: { name: PACKAGE_NAME, version: VERSION },
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
const scopedInstructions = () =>
|
|
228
|
+
`${PACKAGE_NAME} forwards to the Pipeworx gateway and lists only the ${SLUG} pack's tools. `
|
|
229
|
+
+ 'Set PIPEWORX_META_TOOLS=1 to also list ask_pipeworx and the other gateway-wide tools.';
|
|
230
|
+
|
|
231
|
+
/** `<host name> (via pipeworx-standalone)`. The slug stays OUT of the name: the
|
|
232
|
+
* gateway's scanner-name check substring-matches words like poll/watch/index. */
|
|
233
|
+
export function bridgedClientName(name) {
|
|
234
|
+
const n = typeof name === 'string' && name.trim() ? name.trim() : 'unknown';
|
|
235
|
+
return n.includes(VIA) ? n : `${n} ${VIA}`;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* Relay one JSON-RPC message to the gateway and return the response to write
|
|
240
|
+
* back, or null for a notification. Never throws.
|
|
241
|
+
*
|
|
242
|
+
* @param {object} message a parsed JSON-RPC request or notification
|
|
243
|
+
* @param {{cfg?: object, warn?: (line: string) => void}} [opts]
|
|
244
|
+
*/
|
|
245
|
+
export async function relay(message, opts = {}) {
|
|
246
|
+
const cfg = opts.cfg || bridgeConfig();
|
|
247
|
+
const warn = opts.warn || ((line) => process.stderr.write(`${line}\n`));
|
|
248
|
+
if (!message || typeof message !== 'object' || message.jsonrpc !== '2.0' || typeof message.method !== 'string') {
|
|
249
|
+
const id = message && typeof message === 'object' && 'id' in message ? message.id : null;
|
|
250
|
+
return rpcError(id ?? null, -32600, 'Invalid Request');
|
|
251
|
+
}
|
|
252
|
+
const isNotification = !('id' in message) || message.id === undefined;
|
|
253
|
+
const id = message.id;
|
|
254
|
+
|
|
255
|
+
if (isNotification) {
|
|
256
|
+
const out = await postToGateway(message, cfg);
|
|
257
|
+
if (out.kind !== 'http') warn(`${PACKAGE_NAME}: notification ${message.method} not delivered: ${unreachableText(cfg, out)}`);
|
|
258
|
+
return null;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
if (message.method === 'initialize') {
|
|
262
|
+
const params = { ...(message.params || {}) };
|
|
263
|
+
params.clientInfo = { ...(params.clientInfo || {}), name: bridgedClientName(params.clientInfo && params.clientInfo.name) };
|
|
264
|
+
if (!params.clientInfo.version) params.clientInfo.version = '0';
|
|
265
|
+
const out = await postToGateway({ ...message, params }, cfg);
|
|
266
|
+
noteTier(out, cfg, warn);
|
|
267
|
+
if (out.kind === 'http' && out.body && out.body.result && typeof out.body.result === 'object') {
|
|
268
|
+
const result = { ...out.body.result, serverInfo: { name: PACKAGE_NAME, version: VERSION } };
|
|
269
|
+
if (!cfg.metaTools) result.instructions = scopedInstructions();
|
|
270
|
+
return rpcResult(id, result);
|
|
271
|
+
}
|
|
272
|
+
// The host must still start: answer locally and let the calls report the
|
|
273
|
+
// gateway problem when they happen.
|
|
274
|
+
warn(`${PACKAGE_NAME}: initialize answered locally -- ${out.kind === 'http' ? `gateway HTTP ${out.status}` : unreachableText(cfg, out)}`);
|
|
275
|
+
return rpcResult(id, { ...localInitialize(message.params), instructions: scopedInstructions() });
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
if (message.method === 'tools/list') {
|
|
279
|
+
const out = await postToGateway(message, cfg);
|
|
280
|
+
noteTier(out, cfg, warn);
|
|
281
|
+
const listed = out.kind === 'http' && out.body && out.body.result && Array.isArray(out.body.result.tools)
|
|
282
|
+
? out.body.result : null;
|
|
283
|
+
if (listed) {
|
|
284
|
+
if (cfg.metaTools) return rpcResult(id, listed);
|
|
285
|
+
const own = listed.tools.filter((t) => t && t._meta && (t._meta.pack === GATEWAY_SLUG || t._meta.pack === SLUG));
|
|
286
|
+
if (own.length > 0) return rpcResult(id, { ...listed, tools: own });
|
|
287
|
+
warn(`${PACKAGE_NAME}: the gateway listed no ${SLUG} tools; serving the tool list bundled with this package`);
|
|
288
|
+
} else {
|
|
289
|
+
warn(`${PACKAGE_NAME}: tools/list served from the snapshot bundled with this package -- ${out.kind === 'http' ? `gateway HTTP ${out.status}` : unreachableText(cfg, out)}`);
|
|
290
|
+
}
|
|
291
|
+
return rpcResult(id, { tools });
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
if (message.method === 'tools/call') {
|
|
295
|
+
const out = await postToGateway(message, cfg);
|
|
296
|
+
noteTier(out, cfg, warn);
|
|
297
|
+
return toolsCallResponse(id, out, cfg);
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
// Everything else (ping, resources/*, prompts/*, ...): relay as-is.
|
|
301
|
+
const out = await postToGateway(message, cfg);
|
|
302
|
+
noteTier(out, cfg, warn);
|
|
303
|
+
if (out.kind === 'http' && out.body && out.body.jsonrpc === '2.0') return { ...out.body, id };
|
|
304
|
+
if (message.method === 'ping') return rpcResult(id, {});
|
|
305
|
+
return rpcError(id, -32603, out.kind === 'http'
|
|
306
|
+
? `The Pipeworx gateway returned HTTP ${out.status}: ${firstLine(out.text)}`
|
|
307
|
+
: unreachableText(cfg, out));
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* Call one of this pack's tools through the gateway -- the `{tools, callTool}`
|
|
312
|
+
* shape earlier versions of this package exported. Resolves with the tool's
|
|
313
|
+
* structured result; rejects with the gateway's message on any error.
|
|
314
|
+
*
|
|
315
|
+
* @param {string} name
|
|
316
|
+
* @param {Record<string, unknown>} [args]
|
|
317
|
+
* @param {{apiKey?: string, gatewayUrl?: string, timeoutMs?: number}} [opts]
|
|
318
|
+
* apiKey defaults to process.env.PIPEWORX_API_KEY.
|
|
319
|
+
*/
|
|
320
|
+
export async function callTool(name, args = {}, opts = {}) {
|
|
321
|
+
const cfg = bridgeConfig(process.env, opts);
|
|
322
|
+
const res = await relay({ jsonrpc: '2.0', id: 1, method: 'tools/call', params: { name, arguments: args } }, { cfg });
|
|
323
|
+
if (res.error) throw new Error(res.error.message);
|
|
324
|
+
const result = res.result || {};
|
|
325
|
+
const text = Array.isArray(result.content)
|
|
326
|
+
? result.content.filter((c) => c && c.type === 'text').map((c) => c.text).join('\n')
|
|
327
|
+
: '';
|
|
328
|
+
if (result.isError) throw new Error(text || `${name} failed`);
|
|
329
|
+
if (result.structuredContent !== undefined) return result.structuredContent;
|
|
330
|
+
try { return JSON.parse(text); } catch { return text; }
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
export default { tools, callTool };
|
package/package.json
CHANGED
|
@@ -1,6 +1,33 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pipeworx/mcp-census-business",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Census business statistics -- how big is an industry, by NAICS code and geography (fleet #4608).",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "lib/index.js",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": "./lib/index.js",
|
|
9
|
+
"./tools.json": "./tools.json",
|
|
10
|
+
"./package.json": "./package.json"
|
|
11
|
+
},
|
|
12
|
+
"bin": {
|
|
13
|
+
"mcp-census-business": "bin/cli.js"
|
|
14
|
+
},
|
|
15
|
+
"files": ["bin/", "lib/", "tools.json", "server.json"],
|
|
16
|
+
"engines": {
|
|
17
|
+
"node": ">=18"
|
|
18
|
+
},
|
|
19
|
+
"keywords": ["mcp", "mcp-server", "model-context-protocol", "pipeworx", "census-business"],
|
|
20
|
+
"license": "MIT",
|
|
21
|
+
"repository": {
|
|
22
|
+
"type": "git",
|
|
23
|
+
"url": "git+https://github.com/pipeworx-io/mcp-census-business.git"
|
|
24
|
+
},
|
|
25
|
+
"mcpName": "io.github.pipeworx-io/census-business",
|
|
26
|
+
"pipeworx": {
|
|
27
|
+
"mode": "gateway",
|
|
28
|
+
"slug": "census-business",
|
|
29
|
+
"gatewaySlug": "census-business",
|
|
30
|
+
"sourceHash": "v1-cbf8edc6981a53124c3cfc1de12eea38411a0b1d8c76311826b46e4540009240",
|
|
31
|
+
"sourceCommit": "06cab3af0fa5a65a398f12db1e5f09892c0d0c25"
|
|
32
|
+
}
|
|
33
|
+
}
|
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/census-business",
|
|
4
|
+
"title": "Census Business",
|
|
5
|
+
"description": "Census business statistics -- how big is an industry, by NAICS code and geography (fleet #4608).",
|
|
6
|
+
"version": "0.1.0",
|
|
7
|
+
"websiteUrl": "https://pipeworx.io/packs/census-business",
|
|
8
|
+
"repository": {
|
|
9
|
+
"url": "https://github.com/pipeworx-io/mcp-census-business",
|
|
10
|
+
"source": "github"
|
|
11
|
+
},
|
|
12
|
+
"remotes": [
|
|
13
|
+
{
|
|
14
|
+
"type": "streamable-http",
|
|
15
|
+
"url": "https://gateway.pipeworx.io/census-business/mcp"
|
|
16
|
+
}
|
|
17
|
+
]
|
|
18
|
+
}
|
package/tools.json
ADDED
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"name": "industry_code_search",
|
|
4
|
+
"description": "Find the NAICS industry code Census statistics use for plain industry words (\"dental offices\", \"software publishers\", \"breweries\"), straight from the Census Bureau's own industry list for its business datasets. Returns up to 15 matching codes with titles. Use it before industry_size when the exact code matters. For the full NAICS hierarchy, descriptions and edition crosswalks use the naics pack.",
|
|
5
|
+
"inputSchema": {
|
|
6
|
+
"type": "object",
|
|
7
|
+
"properties": {
|
|
8
|
+
"query": {
|
|
9
|
+
"type": "string",
|
|
10
|
+
"description": "Industry words, e.g. \"dental offices\"."
|
|
11
|
+
},
|
|
12
|
+
"_apiKey": {
|
|
13
|
+
"type": "string",
|
|
14
|
+
"description": "Census API key. Supplied by the platform; callers do not pass it."
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"required": [
|
|
18
|
+
"query"
|
|
19
|
+
]
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"name": "industry_size",
|
|
24
|
+
"description": "How big is an industry, by NAICS code (or plain words) and geography: number of employer establishments, employees and annual payroll from Census County Business Patterns (latest year published), plus the count and receipts of nonemployer businesses (sole proprietors with no payroll) from Census Nonemployer Statistics. Nation, state or county; or rank every state (breakdown \"state\") or every county in a state. Answers \"how many dental offices are there in Texas and what is their total payroll\". Payroll and receipts are returned in dollars. U.S. Census Bureau; each response names the dataset, year and any noise or suppression flag.",
|
|
25
|
+
"inputSchema": {
|
|
26
|
+
"type": "object",
|
|
27
|
+
"properties": {
|
|
28
|
+
"industry": {
|
|
29
|
+
"type": "string",
|
|
30
|
+
"description": "NAICS code (\"621210\", \"54\", \"31-33\") or plain industry words (\"dental offices\"). Words resolve to the best-matching industry in the dataset and the response lists the alternatives it did not pick."
|
|
31
|
+
},
|
|
32
|
+
"state": {
|
|
33
|
+
"type": "string",
|
|
34
|
+
"description": "U.S. state name, postal abbreviation or FIPS code (e.g. \"Texas\", \"TX\", \"48\"). Omit for the nation."
|
|
35
|
+
},
|
|
36
|
+
"county": {
|
|
37
|
+
"type": "string",
|
|
38
|
+
"description": "3-digit county FIPS (needs state) or the 5-digit state+county FIPS, e.g. \"48201\" for Harris County, Texas."
|
|
39
|
+
},
|
|
40
|
+
"year": {
|
|
41
|
+
"type": "integer",
|
|
42
|
+
"description": "County Business Patterns reference year (default: the latest published, 2023)."
|
|
43
|
+
},
|
|
44
|
+
"breakdown": {
|
|
45
|
+
"type": "string",
|
|
46
|
+
"enum": [
|
|
47
|
+
"state",
|
|
48
|
+
"county"
|
|
49
|
+
],
|
|
50
|
+
"description": "Return one row per state (ranked by establishments), or per county of the given state."
|
|
51
|
+
},
|
|
52
|
+
"include_nonemployer": {
|
|
53
|
+
"type": "boolean",
|
|
54
|
+
"description": "Also fetch nonemployer businesses (default true)."
|
|
55
|
+
},
|
|
56
|
+
"limit": {
|
|
57
|
+
"type": "integer",
|
|
58
|
+
"description": "Max rows for a breakdown (default 15, max 100)."
|
|
59
|
+
},
|
|
60
|
+
"_apiKey": {
|
|
61
|
+
"type": "string",
|
|
62
|
+
"description": "Census API key. Supplied by the platform; callers do not pass it."
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
"required": [
|
|
66
|
+
"industry"
|
|
67
|
+
]
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
"name": "establishment_size_split",
|
|
72
|
+
"description": "How an industry splits by establishment size: establishments, employees and annual payroll for each employment-size class (1-4, 5-9, 10-19, 20-49, 50-99 ... 1,000+ employees) from Census County Business Patterns, for the nation, a state or a county. Answers \"what share of dental offices have fewer than 10 employees\". This counts establishments (locations), not firms: the firm-size tables (Statistics of U.S. Businesses) are not offered through the Census data service. U.S. Census Bureau.",
|
|
73
|
+
"inputSchema": {
|
|
74
|
+
"type": "object",
|
|
75
|
+
"properties": {
|
|
76
|
+
"industry": {
|
|
77
|
+
"type": "string",
|
|
78
|
+
"description": "NAICS code (\"621210\", \"54\", \"31-33\") or plain industry words (\"dental offices\"). Words resolve to the best-matching industry in the dataset and the response lists the alternatives it did not pick."
|
|
79
|
+
},
|
|
80
|
+
"state": {
|
|
81
|
+
"type": "string",
|
|
82
|
+
"description": "U.S. state name, postal abbreviation or FIPS code (e.g. \"Texas\", \"TX\", \"48\"). Omit for the nation."
|
|
83
|
+
},
|
|
84
|
+
"county": {
|
|
85
|
+
"type": "string",
|
|
86
|
+
"description": "3-digit county FIPS (needs state) or the 5-digit state+county FIPS, e.g. \"48201\" for Harris County, Texas."
|
|
87
|
+
},
|
|
88
|
+
"year": {
|
|
89
|
+
"type": "integer",
|
|
90
|
+
"description": "Reference year (default: latest, 2023)."
|
|
91
|
+
},
|
|
92
|
+
"_apiKey": {
|
|
93
|
+
"type": "string",
|
|
94
|
+
"description": "Census API key. Supplied by the platform; callers do not pass it."
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
"required": [
|
|
98
|
+
"industry"
|
|
99
|
+
]
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
"name": "economic_census_industry",
|
|
104
|
+
"description": "Industry receipts and structure from the Economic Census (every five years: 2022 default, 2017): number of establishments and firms, sales / value of shipments / revenue, annual payroll and employees by NAICS industry, for the nation, a state or a county. Use it for total industry revenue; County Business Patterns (industry_size) has no receipts. U.S. Census Bureau.",
|
|
105
|
+
"inputSchema": {
|
|
106
|
+
"type": "object",
|
|
107
|
+
"properties": {
|
|
108
|
+
"industry": {
|
|
109
|
+
"type": "string",
|
|
110
|
+
"description": "NAICS code (\"621210\", \"54\", \"31-33\") or plain industry words (\"dental offices\"). Words resolve to the best-matching industry in the dataset and the response lists the alternatives it did not pick."
|
|
111
|
+
},
|
|
112
|
+
"state": {
|
|
113
|
+
"type": "string",
|
|
114
|
+
"description": "U.S. state name, postal abbreviation or FIPS code (e.g. \"Texas\", \"TX\", \"48\"). Omit for the nation."
|
|
115
|
+
},
|
|
116
|
+
"county": {
|
|
117
|
+
"type": "string",
|
|
118
|
+
"description": "3-digit county FIPS (needs state) or the 5-digit state+county FIPS, e.g. \"48201\" for Harris County, Texas."
|
|
119
|
+
},
|
|
120
|
+
"year": {
|
|
121
|
+
"type": "integer",
|
|
122
|
+
"enum": [
|
|
123
|
+
2022,
|
|
124
|
+
2017
|
|
125
|
+
],
|
|
126
|
+
"description": "Economic Census year (default 2022)."
|
|
127
|
+
},
|
|
128
|
+
"_apiKey": {
|
|
129
|
+
"type": "string",
|
|
130
|
+
"description": "Census API key. Supplied by the platform; callers do not pass it."
|
|
131
|
+
}
|
|
132
|
+
},
|
|
133
|
+
"required": [
|
|
134
|
+
"industry"
|
|
135
|
+
]
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
"name": "business_owner_demographics",
|
|
140
|
+
"description": "Who owns the employer firms in an industry: number of firms, receipts, employees and payroll split by owner sex, ethnicity, race or veteran status, from the Census Annual Business Survey. Nation or state, all industries or one. Answers \"how many women-owned employer firms are in construction in Ohio\". U.S. Census Bureau.",
|
|
141
|
+
"inputSchema": {
|
|
142
|
+
"type": "object",
|
|
143
|
+
"properties": {
|
|
144
|
+
"industry": {
|
|
145
|
+
"type": "string",
|
|
146
|
+
"description": "NAICS code or words; omit for all sectors combined."
|
|
147
|
+
},
|
|
148
|
+
"dimension": {
|
|
149
|
+
"type": "string",
|
|
150
|
+
"enum": [
|
|
151
|
+
"sex",
|
|
152
|
+
"ethnicity",
|
|
153
|
+
"race",
|
|
154
|
+
"veteran"
|
|
155
|
+
],
|
|
156
|
+
"description": "Owner characteristic to split by (default \"sex\")."
|
|
157
|
+
},
|
|
158
|
+
"state": {
|
|
159
|
+
"type": "string",
|
|
160
|
+
"description": "U.S. state name, postal abbreviation or FIPS code (e.g. \"Texas\", \"TX\", \"48\"). Omit for the nation."
|
|
161
|
+
},
|
|
162
|
+
"year": {
|
|
163
|
+
"type": "integer",
|
|
164
|
+
"description": "Survey year (default: latest published, 2023)."
|
|
165
|
+
},
|
|
166
|
+
"_apiKey": {
|
|
167
|
+
"type": "string",
|
|
168
|
+
"description": "Census API key. Supplied by the platform; callers do not pass it."
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
"name": "monthly_sales_series",
|
|
175
|
+
"description": "Monthly or quarterly industry sales series from the Census Bureau economic indicators: Monthly Retail Trade Survey (program \"mrts\": retail and food services sales, default category 44X72 total) and Quarterly Services Survey (program \"qss\"). Returns the time series with seasonal adjustment and error flag. Pass list_codes true to see which category and data-type codes a program publishes before asking for a series. U.S. Census Bureau.",
|
|
176
|
+
"inputSchema": {
|
|
177
|
+
"type": "object",
|
|
178
|
+
"properties": {
|
|
179
|
+
"program": {
|
|
180
|
+
"type": "string",
|
|
181
|
+
"enum": [
|
|
182
|
+
"mrts",
|
|
183
|
+
"qss"
|
|
184
|
+
],
|
|
185
|
+
"description": "mrts = Monthly Retail Trade, qss = Quarterly Services Survey (default mrts)."
|
|
186
|
+
},
|
|
187
|
+
"category_code": {
|
|
188
|
+
"type": "string",
|
|
189
|
+
"description": "Industry category code the program publishes (mrts default \"44X72\", retail and food services total)."
|
|
190
|
+
},
|
|
191
|
+
"data_type_code": {
|
|
192
|
+
"type": "string",
|
|
193
|
+
"description": "Measure code (mrts default \"SM\", sales). Use list_codes to see the program's codes."
|
|
194
|
+
},
|
|
195
|
+
"seasonally_adj": {
|
|
196
|
+
"type": "string",
|
|
197
|
+
"enum": [
|
|
198
|
+
"yes",
|
|
199
|
+
"no"
|
|
200
|
+
],
|
|
201
|
+
"description": "Seasonally adjusted (default \"yes\")."
|
|
202
|
+
},
|
|
203
|
+
"from": {
|
|
204
|
+
"type": "string",
|
|
205
|
+
"description": "First period, \"YYYY\" or \"YYYY-MM\" (default: two years back)."
|
|
206
|
+
},
|
|
207
|
+
"to": {
|
|
208
|
+
"type": "string",
|
|
209
|
+
"description": "Last period, \"YYYY\" or \"YYYY-MM\" (default: latest)."
|
|
210
|
+
},
|
|
211
|
+
"list_codes": {
|
|
212
|
+
"type": "boolean",
|
|
213
|
+
"description": "List the category and data-type codes instead of a series."
|
|
214
|
+
},
|
|
215
|
+
"_apiKey": {
|
|
216
|
+
"type": "string",
|
|
217
|
+
"description": "Census API key. Supplied by the platform; callers do not pass it."
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
]
|