@opthr/mcp-server 0.2.0 → 0.2.3
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/README.md +166 -32
- package/package.json +4 -2
- package/src/index.js +1137 -189
package/README.md
CHANGED
|
@@ -1,42 +1,76 @@
|
|
|
1
1
|
# @opthr/mcp-server
|
|
2
2
|
|
|
3
|
-
Model Context Protocol server for **OptHR** — exposes the Skill Gap and
|
|
3
|
+
Model Context Protocol server for **OptHR** — exposes the OptHR product surfaces plus the Compensation, Pay-Equity, Skill Gap and Rapporto Biennale agents to MCP-aware clients (Claude Desktop, Cursor, etc.).
|
|
4
4
|
|
|
5
|
-
This is a thin Node.js wrapper around the OptHR FastAPI backend
|
|
5
|
+
This is a thin Node.js wrapper around the OptHR FastAPI backend. All tools call the **same endpoints** the OptHR web app uses — there is no separate "MCP backend". The MCP cannot run analyses without a reachable hosted (or local) OptHR backend.
|
|
6
6
|
|
|
7
|
-
##
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npx -y @opthr/mcp-server@latest
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Requires Node 18+.
|
|
14
|
+
|
|
15
|
+
## Tools
|
|
16
|
+
|
|
17
|
+
The public MCP surface is deliberately small — 10 tools. Read-only browsing (job lists, samples, schemas, product URLs) is exposed as **resources**, not tools.
|
|
8
18
|
|
|
9
19
|
| Tool | What it does |
|
|
10
20
|
|---|---|
|
|
11
|
-
| `opthr_health` |
|
|
12
|
-
| `
|
|
13
|
-
| `
|
|
14
|
-
| `
|
|
15
|
-
| `
|
|
16
|
-
| `
|
|
17
|
-
| `
|
|
21
|
+
| `opthr_health` | Sanity-check connectivity and active LLM |
|
|
22
|
+
| `opthr_run_skill_gap` | Skill gap vs a target role |
|
|
23
|
+
| `opthr_run_compensation` | Compensation + pay-equity for a single employee |
|
|
24
|
+
| `opthr_run_pay_equity` | Pay-equity from a payroll CSV |
|
|
25
|
+
| `opthr_run_rapporto_biennale` | Legge 162/2021 workflow — full Modello XLSX (Sez B/C/E/F/H) |
|
|
26
|
+
| `opthr_wait_for_job` | Poll until `completed` / `failed` or timeout |
|
|
27
|
+
| `opthr_get_job_summary` | Compact merged summary (comp + pay-equity + skill-gap + recs) |
|
|
28
|
+
| `opthr_export` | Download PDF / XLSX / DOCX / PPTX / JSON |
|
|
29
|
+
| `opthr_answer` | Send a clarification to a paused job |
|
|
30
|
+
| `opthr_review_step` | Approve / revise compensation, pay_equity, skills, recommendations, or manager_feedback |
|
|
31
|
+
|
|
32
|
+
## Resources
|
|
33
|
+
|
|
34
|
+
| URI | Mime | What it gives clients |
|
|
35
|
+
|---|---|---|
|
|
36
|
+
| `opthr://dashboard` | json | Current dashboard URL + API base |
|
|
37
|
+
| `opthr://figma` | json | Configured Figma handoff URL |
|
|
38
|
+
| `opthr://product-surfaces` | json | Dashboard / landing / API / Figma metadata |
|
|
39
|
+
| `opthr://samples` | json | List of bundled sample documents |
|
|
40
|
+
| `opthr://schemas` | json | JobState, JobModule, DocumentType, UserRole enums, review payloads, error codes |
|
|
41
|
+
| `opthr://tool-guide` | md | When to use which tool |
|
|
42
|
+
| `opthr://recent-jobs` | json | Live: last 20 analyses for the tenant |
|
|
43
|
+
| `opthr://sample-payroll-csv` | csv | Minimal payroll CSV template |
|
|
44
|
+
| `opthr://rapporto-biennale-template` | json | Legge 162/2021 column layout |
|
|
18
45
|
|
|
19
|
-
##
|
|
46
|
+
## Prompts
|
|
20
47
|
|
|
21
|
-
|
|
48
|
+
- `opthr-quick-comp` — one-shot compensation + pay-equity for a single employee
|
|
49
|
+
- `opthr-explain-job` — pull a job and summarise what was computed
|
|
50
|
+
- `opthr-rapporto-biennale` — Rapporto Biennale workflow including trasmissione
|
|
51
|
+
- `opthr-calibrate-team` — loop comp analyses for a team
|
|
52
|
+
|
|
53
|
+
## Local setup (against a backend on your laptop)
|
|
22
54
|
|
|
23
55
|
```bash
|
|
56
|
+
# Start the OptHR FastAPI backend
|
|
57
|
+
cd backend && uvicorn HR_Suite_Agents.api.app:app --reload --port 8765
|
|
58
|
+
|
|
59
|
+
# Run the MCP (stdio)
|
|
24
60
|
cd mcp-server
|
|
25
61
|
npm install
|
|
26
|
-
npm test
|
|
27
|
-
npm start
|
|
62
|
+
npm test # smoke-tests the backend connection
|
|
63
|
+
npm start
|
|
28
64
|
```
|
|
29
65
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
Add to `~/Library/Application Support/Claude/claude_desktop_config.json`:
|
|
66
|
+
Claude Desktop config (`~/Library/Application Support/Claude/claude_desktop_config.json`):
|
|
33
67
|
|
|
34
68
|
```json
|
|
35
69
|
{
|
|
36
70
|
"mcpServers": {
|
|
37
71
|
"opthr": {
|
|
38
|
-
"command": "
|
|
39
|
-
"args": ["/
|
|
72
|
+
"command": "npx",
|
|
73
|
+
"args": ["-y", "@opthr/mcp-server@latest"],
|
|
40
74
|
"env": {
|
|
41
75
|
"OPTHR_API_BASE": "http://localhost:8765",
|
|
42
76
|
"OPTHR_DEV_ROLE": "admin_hr",
|
|
@@ -47,32 +81,132 @@ Add to `~/Library/Application Support/Claude/claude_desktop_config.json`:
|
|
|
47
81
|
}
|
|
48
82
|
```
|
|
49
83
|
|
|
50
|
-
|
|
84
|
+
## Hosted setup (production / customer demos)
|
|
85
|
+
|
|
86
|
+
For the current OptHR pilot backend, use:
|
|
87
|
+
|
|
88
|
+
```text
|
|
89
|
+
OPTHR_API_BASE=https://opthrr.onrender.com
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Create the API key from the OptHR dashboard:
|
|
93
|
+
|
|
94
|
+
1. Open `https://opthrr.onrender.com/prototype/OptHR%20Redesign.html`.
|
|
95
|
+
2. Log in as a tenant admin.
|
|
96
|
+
3. Go to `Integrate -> REST API`.
|
|
97
|
+
4. Click `Generate key`.
|
|
98
|
+
5. Use the generated `optkey_live_...` value as `OPTHR_API_KEY`.
|
|
51
99
|
|
|
52
100
|
```json
|
|
53
|
-
|
|
54
|
-
"
|
|
101
|
+
{
|
|
102
|
+
"mcpServers": {
|
|
103
|
+
"opthr": {
|
|
104
|
+
"command": "npx",
|
|
105
|
+
"args": ["-y", "@opthr/mcp-server@latest"],
|
|
106
|
+
"env": {
|
|
107
|
+
"OPTHR_API_BASE": "https://opthrr.onrender.com",
|
|
108
|
+
"OPTHR_API_KEY": "optkey_live_xxx",
|
|
109
|
+
"OPTHR_DOCUMENT_SEARCH_ROOT": "/Users/<you>/Documents/OptHR"
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
55
114
|
```
|
|
56
115
|
|
|
57
|
-
|
|
116
|
+
The hosted backend must:
|
|
117
|
+
|
|
118
|
+
1. Be reachable at `OPTHR_API_BASE`.
|
|
119
|
+
2. Accept `X-API-Key` — generate keys from the dashboard/API so they carry tenant scope and role.
|
|
120
|
+
3. Enforce tenant scoping and rate limits on every endpoint the MCP touches.
|
|
121
|
+
|
|
122
|
+
See [`docs/MCP_PLATFORM_READINESS.md`](../docs/MCP_PLATFORM_READINESS.md) for the production checklist.
|
|
58
123
|
|
|
59
|
-
|
|
124
|
+
## Document handling
|
|
60
125
|
|
|
61
|
-
|
|
126
|
+
Analysis tools accept three ways to provide source documents:
|
|
127
|
+
|
|
128
|
+
1. **`document_url`** — `http://`, `https://`, or `file://` URL.
|
|
129
|
+
2. **`document_path`** — absolute local path, or a path relative to `OPTHR_DOCUMENT_SEARCH_ROOT`.
|
|
130
|
+
3. **`use_sample_data: true`** — explicit opt-in to the backend's bundled demo files.
|
|
131
|
+
|
|
132
|
+
Sample data is **never** attached implicitly. If neither `document_url`, `document_path`, nor `use_sample_data` is supplied, the tool returns `state: needs_document` and a dashboard URL for manual upload.
|
|
133
|
+
|
|
134
|
+
If `OPTHR_DOCUMENT_SEARCH_ROOT` is set, any resolved `document_path` (and any `file://` URL) must live inside that directory after `realpath` resolution. Symlink escape attempts return `DOCUMENT_NOT_FOUND`.
|
|
62
135
|
|
|
63
136
|
## Environment variables
|
|
64
137
|
|
|
65
138
|
| Var | Default | What |
|
|
66
139
|
|---|---|---|
|
|
67
|
-
| `OPTHR_API_BASE` | `http://localhost:8765` |
|
|
68
|
-
| `OPTHR_API_KEY` | — | Sent as `X-API-Key`
|
|
69
|
-
| `OPTHR_BEARER_TOKEN` | — | Sent as `Authorization: Bearer …`
|
|
70
|
-
| `OPTHR_DEV_ROLE` | `admin_hr` |
|
|
71
|
-
| `OPTHR_DEV_TENANT_ID` | `tenant_demo` |
|
|
140
|
+
| `OPTHR_API_BASE` | `http://localhost:8765` | FastAPI backend base URL |
|
|
141
|
+
| `OPTHR_API_KEY` | — | Sent as `X-API-Key` (hosted/production) |
|
|
142
|
+
| `OPTHR_BEARER_TOKEN` | — | Sent as `Authorization: Bearer …` |
|
|
143
|
+
| `OPTHR_DEV_ROLE` | `admin_hr` | Legacy fallback `X-Role` (local dev only) |
|
|
144
|
+
| `OPTHR_DEV_TENANT_ID` | `tenant_demo` | Legacy fallback `X-Tenant-ID` (local dev only) |
|
|
145
|
+
| `OPTHR_DOCUMENT_SEARCH_ROOT` | — | Restrict `document_path` to this directory |
|
|
146
|
+
| `OPTHR_DASHBOARD_URL` | `${OPTHR_API_BASE}/OptHR%20Redesign.html#/app` | Dashboard URL exposed via resources |
|
|
147
|
+
| `OPTHR_LANDING_URL` | `https://opthr-landing-site.vercel.app/` | Public landing URL |
|
|
148
|
+
| `OPTHR_FIGMA_URL` | — | Optional Figma handoff URL |
|
|
149
|
+
| `OPTHR_TELEMETRY_URL` | — | Optional HTTPS endpoint to POST one JSON line per tool call (fire-and-forget). |
|
|
150
|
+
| `OPTHR_TELEMETRY_AUTH` | — | Optional `Authorization` header value sent with each telemetry POST (e.g. `Bearer abc`). |
|
|
151
|
+
|
|
152
|
+
## Error codes
|
|
153
|
+
|
|
154
|
+
The MCP returns structured errors with one of these codes (also surfaced via `opthr://schemas`):
|
|
155
|
+
|
|
156
|
+
| Code | Meaning |
|
|
157
|
+
|---|---|
|
|
158
|
+
| `BACKEND_UNREACHABLE` | The MCP can't reach `OPTHR_API_BASE` at all. |
|
|
159
|
+
| `AUTH_FAILED` | Backend returned 401/403 — API key, bearer, or role missing/invalid. |
|
|
160
|
+
| `DOCUMENT_NOT_FOUND` | `document_url` / `document_path` resolution failed. |
|
|
161
|
+
| `INVALID_DOCUMENT_TYPE` | A scheme or type check rejected the input. |
|
|
162
|
+
| `JOB_TIMEOUT` | `opthr_wait_for_job` exhausted its deadline. |
|
|
163
|
+
| `BACKEND_ERROR` | Any other non-2xx backend response. |
|
|
164
|
+
|
|
165
|
+
See [`docs/MCP_ERROR_CATALOG.md`](../docs/MCP_ERROR_CATALOG.md) for symptoms, root-cause analysis, and runbook steps for each code (plus the `429` rate-limit response).
|
|
166
|
+
|
|
167
|
+
## Observability
|
|
168
|
+
|
|
169
|
+
The MCP logs one structured JSON line per tool call to **stderr** (stdout is reserved for the MCP transport):
|
|
170
|
+
|
|
171
|
+
```json
|
|
172
|
+
{"ts":"…","svc":"opthr-mcp-server","version":"0.2.2","tenant_id":"tenant_demo",
|
|
173
|
+
"backend_host":"api.opthr.io","event":"tool_call","tool":"opthr_run_compensation",
|
|
174
|
+
"outcome":"ok","latency_ms":1820}
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
PII, salaries, raw documents, and request/response bodies are **never** logged — by design, only the tool name, latency, outcome, and error code.
|
|
178
|
+
|
|
179
|
+
### Telemetry sink
|
|
180
|
+
|
|
181
|
+
Set `OPTHR_TELEMETRY_URL` to an HTTPS endpoint to also POST each line, fire-and-forget. The payload is exactly the JSON shown above. Telemetry failures (HTTP errors, DNS failures, timeouts) are swallowed — they never affect tool calls.
|
|
72
182
|
|
|
73
|
-
|
|
183
|
+
```jsonc
|
|
184
|
+
// claude_desktop_config.json
|
|
185
|
+
{
|
|
186
|
+
"mcpServers": {
|
|
187
|
+
"opthr": {
|
|
188
|
+
"command": "npx",
|
|
189
|
+
"args": ["-y", "@opthr/mcp-server@latest"],
|
|
190
|
+
"env": {
|
|
191
|
+
"OPTHR_API_BASE": "https://<hosted-api>",
|
|
192
|
+
"OPTHR_API_KEY": "optkey_live_xxx",
|
|
193
|
+
"OPTHR_TELEMETRY_URL": "https://telemetry.opthr.io/mcp",
|
|
194
|
+
"OPTHR_TELEMETRY_AUTH": "Bearer <ingest-token>"
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
## Publishing
|
|
202
|
+
|
|
203
|
+
```bash
|
|
204
|
+
# from mcp-server/
|
|
205
|
+
npm version patch # → 0.2.x
|
|
206
|
+
npm publish --access public
|
|
207
|
+
```
|
|
74
208
|
|
|
75
|
-
|
|
209
|
+
`files` in `package.json` already pins the npm tarball to `src/`, `assets/`, and `README.md`.
|
|
76
210
|
|
|
77
211
|
## License
|
|
78
212
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opthr/mcp-server",
|
|
3
|
-
"version": "0.2.
|
|
4
|
-
"description": "Model Context Protocol server for OptHR —
|
|
3
|
+
"version": "0.2.3",
|
|
4
|
+
"description": "Model Context Protocol server for OptHR — Compensation, Pay-Equity, Skill Gap and Rapporto Biennale agents for Claude Desktop, Cursor, and other MCP clients.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
7
7
|
"opthr-mcp-server": "src/index.js"
|
|
@@ -25,6 +25,8 @@
|
|
|
25
25
|
"opthr",
|
|
26
26
|
"compensation",
|
|
27
27
|
"skill-gap",
|
|
28
|
+
"pay-equity",
|
|
29
|
+
"rapporto-biennale",
|
|
28
30
|
"anthropic"
|
|
29
31
|
],
|
|
30
32
|
"author": "OptHR",
|