@qverisai/mcp 0.8.0 → 0.10.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.
Files changed (39) hide show
  1. package/CHANGELOG.md +29 -1
  2. package/README.md +392 -385
  3. package/dist/api/client.d.ts +2 -2
  4. package/dist/api/client.d.ts.map +1 -1
  5. package/dist/api/client.js +42 -42
  6. package/dist/api/client.js.map +1 -1
  7. package/dist/http.d.ts +26 -5
  8. package/dist/http.d.ts.map +1 -1
  9. package/dist/http.js +115 -23
  10. package/dist/http.js.map +1 -1
  11. package/dist/index.d.ts +107 -9
  12. package/dist/index.d.ts.map +1 -1
  13. package/dist/index.js +139 -47
  14. package/dist/index.js.map +1 -1
  15. package/dist/output-schemas.d.ts +12 -0
  16. package/dist/output-schemas.d.ts.map +1 -0
  17. package/dist/output-schemas.js +61 -0
  18. package/dist/output-schemas.js.map +1 -0
  19. package/dist/server-card.d.ts +1 -1
  20. package/dist/server-card.d.ts.map +1 -1
  21. package/dist/server-card.js +7 -5
  22. package/dist/server-card.js.map +1 -1
  23. package/dist/tools/audit-utils.d.ts.map +1 -1
  24. package/dist/tools/audit-utils.js +11 -16
  25. package/dist/tools/audit-utils.js.map +1 -1
  26. package/dist/tools/credits-ledger.d.ts +1 -2
  27. package/dist/tools/credits-ledger.d.ts.map +1 -1
  28. package/dist/tools/credits-ledger.js.map +1 -1
  29. package/dist/tools/execute.d.ts.map +1 -1
  30. package/dist/tools/execute.js.map +1 -1
  31. package/dist/tools/get-by-ids.d.ts.map +1 -1
  32. package/dist/tools/get-by-ids.js +1 -2
  33. package/dist/tools/get-by-ids.js.map +1 -1
  34. package/dist/tools/usage-history.d.ts +1 -2
  35. package/dist/tools/usage-history.d.ts.map +1 -1
  36. package/dist/tools/usage-history.js.map +1 -1
  37. package/dist/types.d.ts +1 -1
  38. package/dist/types.d.ts.map +1 -1
  39. package/package.json +17 -4
package/README.md CHANGED
@@ -1,385 +1,392 @@
1
- # @qverisai/mcp
2
-
3
- Official QVeris MCP Server — Dynamically search and execute tools via natural language.
4
-
5
- [![npm version](https://img.shields.io/npm/v/@qverisai/mcp.svg)](https://www.npmjs.com/package/@qverisai/mcp)
6
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
7
-
8
- ## Overview
9
-
10
- This SDK provides a [Model Context Protocol (MCP)](https://modelcontextprotocol.io/) server that enables LLMs to discover and execute third-party tools through the QVeris API. With a small set of tools, your AI assistant can:
11
-
12
- - **Discover** tools using natural language queries
13
- - **Inspect** detailed information about specific tools by their IDs
14
- - **Call** any discovered tool with the appropriate parameters
15
- - **Audit usage** with context-safe summaries or precise filtered records
16
- - **Review credits ledger** without dumping full account history into context
17
-
18
- ## Quick Start
19
-
20
- ### 1. Get Your API Key
21
-
22
- Visit [QVeris](https://qveris.ai) (Global) or [QVeris](https://qveris.cn) (China) to get your API key.
23
-
24
- ### 2. Configure Your MCP Client
25
-
26
- Use the QVeris CLI to generate config without hand-editing JSON. Placeholder output intentionally fails API key validation until you replace it or use `--include-key`:
27
-
28
- ```bash
29
- # Print safe config with YOUR_QVERIS_API_KEY placeholder
30
- qveris mcp configure --target cursor
31
-
32
- # Write a working config using your resolved API key
33
- qveris mcp configure --target cursor --write --include-key
34
- qveris mcp configure --target claude-desktop --write --include-key
35
- qveris mcp configure --target opencode --write --include-key
36
- qveris mcp configure --target openclaw --write --include-key
37
-
38
- # Validate config, or live-probe visible tools for stdio clients
39
- qveris mcp validate --target cursor
40
- qveris mcp validate --target cursor --probe
41
- ```
42
-
43
- Add the QVeris server to your MCP client configuration:
44
-
45
- **Claude Desktop** (`claude_desktop_config.json`):
46
-
47
- ```json
48
- {
49
- "mcpServers": {
50
- "qveris": {
51
- "command": "npx",
52
- "args": ["-y", "@qverisai/mcp"],
53
- "env": {
54
- "QVERIS_API_KEY": "your-api-key-here"
55
- }
56
- }
57
- }
58
- }
59
- ```
60
-
61
- **Cursor** (Settings → MCP Servers):
62
-
63
- ```json
64
- {
65
- "mcpServers": {
66
- "qveris": {
67
- "command": "npx",
68
- "args": ["-y", "@qverisai/mcp"],
69
- "env": {
70
- "QVERIS_API_KEY": "your-api-key-here"
71
- }
72
- }
73
- }
74
- }
75
- ```
76
-
77
- ### 3. Start Using
78
-
79
- Once configured, You could add this to system prompt:
80
-
81
- > "You can use qveris MCP Server to dynamically discover and call tools to help the user. First think about what kind of tools might be useful to accomplish the user's task. Then use the discover tool with a query describing the capability of the tool, not what params you want to pass to the tool later. Then call a suitable tool using the call tool, passing parameters through params_to_tool. You could reference the examples given if any for each tool. You may make multiple tool calls in a single response."
82
-
83
- Then your AI assistant can discover and call tools:
84
-
85
- > "Find me a weather tool and get the current weather in Tokyo"
86
-
87
- The assistant will:
88
- 1. Call `discover` with query "weather"
89
- 2. Optionally call `inspect` to review tool details
90
- 3. Call `call` with the tool_id and parameters
91
- 4. Use `usage_history` or `credits_ledger` only when the user asks about charge status or balance changes
92
-
93
- ## Available Tools
94
-
95
- ### `discover`
96
-
97
- Discover available tools based on natural language queries.
98
-
99
- | Parameter | Type | Required | Description |
100
- |-----------|------|----------|-------------|
101
- | `query` | string | ✓ | Natural language description of the capability you need |
102
- | `limit` | number | | Max results to return (1-100, default: 20) |
103
- | `session_id` | string | | Session identifier for tracking (auto-generated if omitted) |
104
-
105
- **Example:**
106
-
107
- ```json
108
- {
109
- "query": "send email notification",
110
- "limit": 10
111
- }
112
- ```
113
-
114
- ### `inspect`
115
-
116
- Inspect tools by their IDs to get detailed information (parameters, success rate, latency, examples, and billing_rule when available).
117
-
118
- | Parameter | Type | Required | Description |
119
- |-----------|------|----------|-------------|
120
- | `tool_ids` | array | ✓ | Array of tool IDs to retrieve (at least one required) |
121
- | `search_id` | string | | Search ID from the discover call that returned the tool(s) |
122
- | `session_id` | string | | Session identifier (auto-generated if omitted) |
123
-
124
- **Example:**
125
-
126
- ```json
127
- {
128
- "tool_ids": ["openweathermap.weather.execute.v1", "worldbank_refined.search_indicators.v1"],
129
- "search_id": "abcd1234-ab12-ab12-ab12-abcdef123456"
130
- }
131
- ```
132
-
133
- ### `call`
134
-
135
- Call a discovered tool with specific parameters.
136
-
137
- | Parameter | Type | Required | Description |
138
- |-----------|------|----------|-------------|
139
- | `tool_id` | string | ✓ | Tool ID from discover results |
140
- | `search_id` | string | ✓ | Search ID from the discover call that found this tool |
141
- | `params_to_tool` | object | ✓ | A dictionary of parameters to pass to the tool |
142
- | `session_id` | string | | Session identifier (auto-generated if omitted) |
143
- | `max_response_size` | number | | Max response size in bytes (default: 20480) |
144
-
145
- **Example:**
146
-
147
- ```json
148
- {
149
- "tool_id": "openweathermap.weather.execute.v1",
150
- "search_id": "abcd1234-ab12-ab12-ab12-abcdef123456",
151
- "params_to_tool": {"city": "London", "units": "metric"}
152
- }
153
- ```
154
-
155
- The `call` response may include compact pre-settlement `billing`. Final charge status should be checked with `usage_history` or `credits_ledger`.
156
-
157
- ### `usage_history`
158
-
159
- Context-safe request-level usage audit. Defaults to aggregated `summary` mode.
160
- Summary mode requests service-side `summary=true` aggregates when available and falls back to bounded client-side aggregation for older deployments.
161
-
162
- | Parameter | Type | Required | Description |
163
- |-----------|------|----------|-------------|
164
- | `mode` | string | | `summary`, `search`, or `export_file` (default: `summary`) |
165
- | `start_date` | string | | Start date, `YYYY-MM-DD` |
166
- | `end_date` | string | | End date, `YYYY-MM-DD` |
167
- | `bucket` | string | | `hour`, `day`, or `week` for summary aggregation |
168
- | `execution_id` | string | | Precise execution lookup |
169
- | `search_id` | string | | Precise search lookup |
170
- | `charge_outcome` | string | | `charged`, `included`, `failed_not_charged`, `failed_charged_review` |
171
- | `min_credits` | number | | Lower credit amount bound |
172
- | `max_credits` | number | | Upper credit amount bound |
173
- | `limit` | number | | Search row cap, default 10, hard max 50 |
174
-
175
- Examples:
176
-
177
- ```json
178
- { "mode": "summary", "bucket": "hour" }
179
- ```
180
-
181
- ```json
182
- { "mode": "search", "execution_id": "exec-123" }
183
- ```
184
-
185
- ```json
186
- { "mode": "search", "min_credits": 30, "max_credits": 100 }
187
- ```
188
-
189
- ### `credits_ledger`
190
-
191
- Context-safe final credit ledger query. Defaults to aggregated `summary` mode.
192
- Summary mode requests service-side `summary=true` aggregates when available and falls back to bounded client-side aggregation for older deployments.
193
-
194
- | Parameter | Type | Required | Description |
195
- |-----------|------|----------|-------------|
196
- | `mode` | string | | `summary`, `search`, or `export_file` (default: `summary`) |
197
- | `start_date` | string | | Start date, `YYYY-MM-DD` |
198
- | `end_date` | string | | End date, `YYYY-MM-DD` |
199
- | `bucket` | string | | `hour`, `day`, or `week` for summary aggregation |
200
- | `entry_type` | string | | Ledger entry type, for example `consume_tool_execute` |
201
- | `direction` | string | | `consume`, `grant`, or `any` |
202
- | `min_credits` | number | | Lower absolute credit amount bound |
203
- | `max_credits` | number | | Upper absolute credit amount bound |
204
- | `limit` | number | | Search row cap, default 10, hard max 50 |
205
-
206
- Examples:
207
-
208
- ```json
209
- { "mode": "summary", "bucket": "day" }
210
- ```
211
-
212
- ```json
213
- { "mode": "search", "direction": "consume", "min_credits": 50 }
214
- ```
215
-
216
- Large result sets should use `mode: "export_file"`. The server writes JSONL under `.qveris/exports/` and returns the file path instead of emitting every row into MCP context.
217
-
218
- ### Deprecated tool names
219
-
220
- For backward compatibility, the old tool names are still supported but emit a deprecation warning:
221
-
222
- | Old name (deprecated) | New name |
223
- |----------------------|----------|
224
- | `search_tools` | `discover` |
225
- | `get_tools_by_ids` | `inspect` |
226
- | `execute_tool` | `call` |
227
-
228
- ## Session Management
229
-
230
- Providing a consistent `session_id` in a same user session in any tool call enables:
231
- - Consistent user tracking across multiple tool calls
232
- - Better analytics and usage patterns
233
- - Improved tool recommendations over time
234
-
235
- If not provided, the SDK automatically generates and maintains a session ID for the lifetime of the server process. However, this result in a much larger granularity of user sessions.
236
-
237
- ## Response Handling
238
-
239
- ### Successful Execution
240
-
241
- ```json
242
- {
243
- "execution_id": "abcd1234-ab12-ab12-ab12-abcdef123456",
244
- "tool_id": "openweathermap.weather.execute.v1",
245
- "success": true,
246
- "result": {
247
- "data": {
248
- "temperature": 15.5,
249
- "humidity": 72,
250
- "description": "partly cloudy"
251
- }
252
- },
253
- "execution_time": 0.847
254
- }
255
- ```
256
-
257
- ### Large Responses
258
-
259
- When tool output exceeds `max_response_size`, you'll receive:
260
-
261
- ```json
262
- {
263
- "result": {
264
- "message": "Result content is too long...",
265
- "truncated_content": "[[1678233600000, \"22198.56...",
266
- "full_content_file_url": "https://..."
267
- }
268
- }
269
- ```
270
-
271
- The `full_content_file_url` is valid for 120 minutes.
272
-
273
- ## Transport modes
274
-
275
- The server speaks two MCP transports from the same binary:
276
-
277
- - **stdio** (default) — used by Claude Desktop, Cursor and other local clients. No change to existing configs.
278
- - **Streamable HTTP** — for remote deployment (e.g. Claude Desktop Custom Connectors, hosted/edge runtimes). Each client session gets its own session id (`Mcp-Session-Id` header), managed automatically.
279
-
280
- Enable HTTP mode with any of `--http`, `QVERIS_MCP_TRANSPORT=http`, or by setting an HTTP port/host:
281
-
282
- ```bash
283
- # Local only (loopback): no inbound auth required
284
- QVERIS_API_KEY=sk-... npx -y @qverisai/mcp --http --port 3000
285
-
286
- # Exposed: bind all interfaces, require a bearer token, allow-list the public host
287
- QVERIS_API_KEY=sk-... \
288
- QVERIS_MCP_TRANSPORT=http \
289
- QVERIS_MCP_HTTP_HOST=0.0.0.0 \
290
- QVERIS_MCP_HTTP_AUTH_TOKEN=$(openssl rand -hex 32) \
291
- QVERIS_MCP_ALLOWED_HOSTS=mcp.example.com \
292
- npx -y @qverisai/mcp
293
- ```
294
-
295
- - The endpoint is `POST/GET/DELETE {path}` (default `/mcp`); `GET /health` returns an unauthenticated liveness probe.
296
- - **Inbound auth:** set `QVERIS_MCP_HTTP_AUTH_TOKEN` to require `Authorization: Bearer <token>` on the MCP endpoint. The server **refuses to start** when binding a non-loopback host without a token, unless you set `QVERIS_MCP_HTTP_ALLOW_UNAUTHENTICATED=true` to delegate auth to an external proxy/gateway. Your `QVERIS_API_KEY` is the server's *outbound* credential to QVeris — it is **not** an inbound check, so anyone reaching an unauthenticated endpoint would spend your credits.
297
- - DNS-rebinding protection is **on by default** (localhost + the bound host/port are allow-listed). When exposing the server publicly, add your public host via `QVERIS_MCP_ALLOWED_HOSTS`.
298
- - Requests are capped at 4 MiB by default (`QVERIS_MCP_MAX_BODY_BYTES`), and idle sessions are evicted after 5 minutes (`QVERIS_MCP_SESSION_TIMEOUT_MS`).
299
- - **Discovery:** registries and crawlers can learn about the server without connecting:
300
- - **Server Card** at `GET {path}/server-card` (default `/mcp/server-card`), media type `application/mcp-server-card+json` — server identity, version, and the remote endpoint.
301
- - **MCP Catalog** at `GET /.well-known/mcp/catalog.json` — a site-wide index pointing at the Server Card.
302
- - Both are public (unauthenticated, CORS-enabled), even when an auth token is set. Behind a TLS proxy, set `QVERIS_MCP_PUBLIC_URL` (or send `X-Forwarded-Proto`) so the advertised URLs use your public origin.
303
- - Full OAuth 2.1 authorization is tracked as a follow-up in [#107](https://github.com/QVerisAI/qveris-agent-toolkit/issues/107).
304
-
305
- ## Environment Variables
306
-
307
- | Variable | Required | Description |
308
- |----------|----------|-------------|
309
- | `QVERIS_API_KEY` | ✓ | Your QVeris API key |
310
- | `QVERIS_REGION` | | Force region: `global` or `cn` (auto-detected from key prefix if not set) |
311
- | `QVERIS_BASE_URL` | | Override API base URL (highest priority, for custom endpoints) |
312
- | `QVERIS_MAX_RETRIES` | | Retries for rate-limited (429) / transient (503) responses (default 3; `0` disables). Honors `Retry-After`, else backs off with jitter. |
313
- | `QVERIS_MCP_TRANSPORT` | | `stdio` (default) or `http` |
314
- | `QVERIS_MCP_HTTP_PORT` | | HTTP port (default `3000`; setting it implies HTTP mode) |
315
- | `QVERIS_MCP_HTTP_HOST` | | HTTP bind host (default `127.0.0.1`) |
316
- | `QVERIS_MCP_HTTP_PATH` | | MCP endpoint path (default `/mcp`) |
317
- | `QVERIS_MCP_ALLOWED_HOSTS` | | Comma-separated extra `Host` values to allow (for DNS-rebinding protection) |
318
- | `QVERIS_MCP_ALLOWED_ORIGINS` | | Comma-separated extra `Origin` values to allow |
319
- | `QVERIS_MCP_DNS_REBINDING_PROTECTION` | | `true` (default) / `false` |
320
- | `QVERIS_MCP_HTTP_JSON` | | `true` to return JSON responses instead of SSE (default `false`) |
321
- | `QVERIS_MCP_HTTP_AUTH_TOKEN` | | Require `Authorization: Bearer <token>` on the MCP endpoint |
322
- | `QVERIS_MCP_HTTP_ALLOW_UNAUTHENTICATED` | | `true` to allow a non-loopback bind without a token (auth delegated externally) |
323
- | `QVERIS_MCP_MAX_BODY_BYTES` | | Max request body size in bytes (default `4194304`) |
324
- | `QVERIS_MCP_SESSION_TIMEOUT_MS` | | Idle session TTL in ms (default `300000`) |
325
- | `QVERIS_MCP_PUBLIC_URL` | | Public origin advertised in discovery documents (e.g. `https://mcp.example.com`) |
326
-
327
- ## Region
328
-
329
- Region is auto-detected from your API key prefix — no extra configuration needed.
330
-
331
- | Key prefix | Region | API endpoint |
332
- |------------|--------|--------------|
333
- | `sk-xxx` | Global | `https://qveris.ai/api/v1` |
334
- | `sk-cn-xxx` | China | `https://qveris.cn/api/v1` |
335
-
336
- To override manually, set environment variables in your MCP client config:
337
-
338
- ```json
339
- {
340
- "mcpServers": {
341
- "qveris": {
342
- "command": "npx",
343
- "args": ["-y", "@qverisai/mcp"],
344
- "env": {
345
- "QVERIS_API_KEY": "your-api-key",
346
- "QVERIS_REGION": "cn"
347
- }
348
- }
349
- }
350
- }
351
- ```
352
-
353
- **Priority:** `QVERIS_BASE_URL` > `QVERIS_REGION` > API key prefix auto-detection > default (global)
354
-
355
- ## Requirements
356
-
357
- - Node.js 18.0.0 or higher
358
- - A valid QVeris API key ([qveris.ai](https://qveris.ai) or [qveris.cn](https://qveris.cn))
359
-
360
- ## Development
361
-
362
- ```bash
363
- # Clone the repository
364
- git clone https://github.com/QVerisAI/qveris-agent-toolkit.git
365
- cd qveris-agent-toolkit/packages/mcp
366
-
367
- # Install dependencies
368
- npm install
369
-
370
- # Build
371
- npm run build
372
-
373
- # Run locally
374
- QVERIS_API_KEY=your-key node dist/index.js
375
- ```
376
-
377
- ## License
378
-
379
- MIT © [QVerisAI](https://github.com/QVerisAI)
380
-
381
- ## Support
382
-
383
- - 🐛 [Issue Tracker](https://github.com/QVerisAI/qveris-agent-toolkit/issues)
384
- - 💬 Contact: contact@qveris.ai
385
-
1
+ # @qverisai/mcp
2
+
3
+ Official QVeris MCP Server — Dynamically search and execute tools via natural language.
4
+
5
+ [![npm version](https://img.shields.io/npm/v/@qverisai/mcp.svg)](https://www.npmjs.com/package/@qverisai/mcp)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
7
+
8
+ ## Overview
9
+
10
+ This SDK provides a [Model Context Protocol (MCP)](https://modelcontextprotocol.io/) server that enables LLMs to discover and execute third-party tools through the QVeris API. With a small set of tools, your AI assistant can:
11
+
12
+ - **Discover** tools using natural language queries
13
+ - **Inspect** detailed information about specific tools by their IDs
14
+ - **Call** any discovered tool with the appropriate parameters
15
+ - **Audit usage** with context-safe summaries or precise filtered records
16
+ - **Review credits ledger** without dumping full account history into context
17
+
18
+ ## Quick Start
19
+
20
+ ### 1. Get Your API Key
21
+
22
+ Visit [QVeris](https://qveris.ai) to get your API key.
23
+
24
+ ### 2. Configure Your MCP Client
25
+
26
+ Use the QVeris CLI to generate config without hand-editing JSON. Placeholder output intentionally fails API key validation until you replace it or use `--include-key`:
27
+
28
+ ```bash
29
+ # Print safe config with YOUR_QVERIS_API_KEY placeholder
30
+ qveris mcp configure --target cursor
31
+
32
+ # Write a working config using your resolved API key
33
+ qveris mcp configure --target cursor --write --include-key
34
+ qveris mcp configure --target claude-desktop --write --include-key
35
+ qveris mcp configure --target opencode --write --include-key
36
+ qveris mcp configure --target openclaw --write --include-key
37
+
38
+ # Validate config, or live-probe visible tools for stdio clients
39
+ qveris mcp validate --target cursor
40
+ qveris mcp validate --target cursor --probe
41
+ ```
42
+
43
+ Add the QVeris server to your MCP client configuration:
44
+
45
+ **Claude Desktop** (`claude_desktop_config.json`):
46
+
47
+ ```json
48
+ {
49
+ "mcpServers": {
50
+ "qveris": {
51
+ "command": "npx",
52
+ "args": ["-y", "@qverisai/mcp"],
53
+ "env": {
54
+ "QVERIS_API_KEY": "your-api-key-here"
55
+ }
56
+ }
57
+ }
58
+ }
59
+ ```
60
+
61
+ **Cursor** (Settings → MCP Servers):
62
+
63
+ ```json
64
+ {
65
+ "mcpServers": {
66
+ "qveris": {
67
+ "command": "npx",
68
+ "args": ["-y", "@qverisai/mcp"],
69
+ "env": {
70
+ "QVERIS_API_KEY": "your-api-key-here"
71
+ }
72
+ }
73
+ }
74
+ }
75
+ ```
76
+
77
+ ### 3. Start Using
78
+
79
+ Once configured, You could add this to system prompt:
80
+
81
+ > "You can use qveris MCP Server to dynamically discover and call tools to help the user. First think about what kind of tools might be useful to accomplish the user's task. Then use the discover tool with a query describing the capability of the tool, not what params you want to pass to the tool later. Then call a suitable tool using the call tool, passing parameters through params_to_tool. You could reference the examples given if any for each tool. You may make multiple tool calls in a single response."
82
+
83
+ Then your AI assistant can discover and call tools:
84
+
85
+ > "Find me a weather tool and get the current weather in Tokyo"
86
+
87
+ The assistant will:
88
+ 1. Call `discover` with query "weather"
89
+ 2. Optionally call `inspect` to review tool details
90
+ 3. Call `call` with the tool_id and parameters
91
+ 4. Use `usage_history` or `credits_ledger` only when the user asks about charge status or balance changes
92
+
93
+ ## Available Tools
94
+
95
+ ### `discover`
96
+
97
+ Discover available tools based on natural language queries.
98
+
99
+ | Parameter | Type | Required | Description |
100
+ |-----------|------|----------|-------------|
101
+ | `query` | string | ✓ | Natural language description of the capability you need |
102
+ | `limit` | number | | Max results to return (1-100, default: 20) |
103
+ | `session_id` | string | | Session identifier for tracking (auto-generated if omitted) |
104
+
105
+ **Example:**
106
+
107
+ ```json
108
+ {
109
+ "query": "send email notification",
110
+ "limit": 10
111
+ }
112
+ ```
113
+
114
+ ### `inspect`
115
+
116
+ Inspect tools by their IDs to get detailed information (parameters, success rate, latency, examples, and billing_rule when available).
117
+
118
+ | Parameter | Type | Required | Description |
119
+ |-----------|------|----------|-------------|
120
+ | `tool_ids` | array | ✓ | Array of tool IDs to retrieve (at least one required) |
121
+ | `search_id` | string | | Search ID from the discover call that returned the tool(s) |
122
+ | `session_id` | string | | Session identifier (auto-generated if omitted) |
123
+
124
+ **Example:**
125
+
126
+ ```json
127
+ {
128
+ "tool_ids": ["openweathermap.weather.execute.v1", "worldbank_refined.search_indicators.v1"],
129
+ "search_id": "abcd1234-ab12-ab12-ab12-abcdef123456"
130
+ }
131
+ ```
132
+
133
+ ### `call`
134
+
135
+ Call a discovered tool with specific parameters.
136
+
137
+ | Parameter | Type | Required | Description |
138
+ |-----------|------|----------|-------------|
139
+ | `tool_id` | string | ✓ | Tool ID from discover results |
140
+ | `search_id` | string | ✓ | Search ID from the discover call that found this tool |
141
+ | `params_to_tool` | object | ✓ | A dictionary of parameters to pass to the tool |
142
+ | `session_id` | string | | Session identifier (auto-generated if omitted) |
143
+ | `max_response_size` | number | | Max response size in bytes (default: 20480) |
144
+
145
+ **Example:**
146
+
147
+ ```json
148
+ {
149
+ "tool_id": "openweathermap.weather.execute.v1",
150
+ "search_id": "abcd1234-ab12-ab12-ab12-abcdef123456",
151
+ "params_to_tool": {"city": "London", "units": "metric"}
152
+ }
153
+ ```
154
+
155
+ The `call` response may include compact pre-settlement `billing`. Final charge status should be checked with `usage_history` or `credits_ledger`.
156
+
157
+ ### `usage_history`
158
+
159
+ Context-safe request-level usage audit. Defaults to aggregated `summary` mode.
160
+ Summary mode requests service-side `summary=true` aggregates when available and falls back to bounded client-side aggregation for older deployments.
161
+
162
+ | Parameter | Type | Required | Description |
163
+ |-----------|------|----------|-------------|
164
+ | `mode` | string | | `summary`, `search`, or `export_file` (default: `summary`) |
165
+ | `start_date` | string | | Start date, `YYYY-MM-DD` |
166
+ | `end_date` | string | | End date, `YYYY-MM-DD` |
167
+ | `bucket` | string | | `hour`, `day`, or `week` for summary aggregation |
168
+ | `execution_id` | string | | Precise execution lookup |
169
+ | `search_id` | string | | Precise search lookup |
170
+ | `charge_outcome` | string | | `charged`, `included`, `failed_not_charged`, `failed_charged_review` |
171
+ | `min_credits` | number | | Lower credit amount bound |
172
+ | `max_credits` | number | | Upper credit amount bound |
173
+ | `limit` | number | | Search row cap, default 10, hard max 50 |
174
+
175
+ Examples:
176
+
177
+ ```json
178
+ { "mode": "summary", "bucket": "hour" }
179
+ ```
180
+
181
+ ```json
182
+ { "mode": "search", "execution_id": "exec-123" }
183
+ ```
184
+
185
+ ```json
186
+ { "mode": "search", "min_credits": 30, "max_credits": 100 }
187
+ ```
188
+
189
+ ### `credits_ledger`
190
+
191
+ Context-safe final credit ledger query. Defaults to aggregated `summary` mode.
192
+ Summary mode requests service-side `summary=true` aggregates when available and falls back to bounded client-side aggregation for older deployments.
193
+
194
+ | Parameter | Type | Required | Description |
195
+ |-----------|------|----------|-------------|
196
+ | `mode` | string | | `summary`, `search`, or `export_file` (default: `summary`) |
197
+ | `start_date` | string | | Start date, `YYYY-MM-DD` |
198
+ | `end_date` | string | | End date, `YYYY-MM-DD` |
199
+ | `bucket` | string | | `hour`, `day`, or `week` for summary aggregation |
200
+ | `entry_type` | string | | Ledger entry type, for example `consume_tool_execute` |
201
+ | `direction` | string | | `consume`, `grant`, or `any` |
202
+ | `min_credits` | number | | Lower absolute credit amount bound |
203
+ | `max_credits` | number | | Upper absolute credit amount bound |
204
+ | `limit` | number | | Search row cap, default 10, hard max 50 |
205
+
206
+ Examples:
207
+
208
+ ```json
209
+ { "mode": "summary", "bucket": "day" }
210
+ ```
211
+
212
+ ```json
213
+ { "mode": "search", "direction": "consume", "min_credits": 50 }
214
+ ```
215
+
216
+ Large result sets should use `mode: "export_file"`. The server writes JSONL under `.qveris/exports/` and returns the file path instead of emitting every row into MCP context.
217
+
218
+ ### Deprecated tool names
219
+
220
+ For backward compatibility, the old tool names are still supported but emit a deprecation warning:
221
+
222
+ | Old name (deprecated) | New name |
223
+ |----------------------|----------|
224
+ | `search_tools` | `discover` |
225
+ | `get_tools_by_ids` | `inspect` |
226
+ | `execute_tool` | `call` |
227
+
228
+ ## Beyond tools: schemas, consent, resources
229
+
230
+ - Every tool declares an `outputSchema` and returns `structuredContent` alongside the JSON text (MCP 2025-06-18), so clients get typed results.
231
+ - With `QVERIS_MCP_CONFIRM_CALLS=true`, a charged `call` first asks the user to confirm via MCP **elicitation** (billing consent); declining cancels the call before any credits are spent. Off by default.
232
+ - **Resources**: read `qveris://server-card` for the server's identity card, or `qveris://capability/{tool_id}` for a capability's full metadata (parameters, examples, stats, billing) without spending a tool call.
233
+
234
+ ## Session Management
235
+
236
+ Providing a consistent `session_id` in a same user session in any tool call enables:
237
+ - Consistent user tracking across multiple tool calls
238
+ - Better analytics and usage patterns
239
+ - Improved tool recommendations over time
240
+
241
+ If not provided, the SDK automatically generates and maintains a session ID for the lifetime of the server process. However, this result in a much larger granularity of user sessions.
242
+
243
+ ## Response Handling
244
+
245
+ ### Successful Execution
246
+
247
+ ```json
248
+ {
249
+ "execution_id": "abcd1234-ab12-ab12-ab12-abcdef123456",
250
+ "tool_id": "openweathermap.weather.execute.v1",
251
+ "success": true,
252
+ "result": {
253
+ "data": {
254
+ "temperature": 15.5,
255
+ "humidity": 72,
256
+ "description": "partly cloudy"
257
+ }
258
+ },
259
+ "execution_time": 0.847
260
+ }
261
+ ```
262
+
263
+ ### Large Responses
264
+
265
+ When tool output exceeds `max_response_size`, you'll receive:
266
+
267
+ ```json
268
+ {
269
+ "result": {
270
+ "message": "Result content is too long...",
271
+ "truncated_content": "[[1678233600000, \"22198.56...",
272
+ "full_content_file_url": "https://..."
273
+ }
274
+ }
275
+ ```
276
+
277
+ The `full_content_file_url` is valid for 120 minutes.
278
+
279
+ ## Transport modes
280
+
281
+ The server speaks two MCP transports from the same binary:
282
+
283
+ - **stdio** (default) — used by Claude Desktop, Cursor and other local clients. No change to existing configs.
284
+ - **Streamable HTTP** — for remote deployment (e.g. Claude Desktop Custom Connectors, hosted/edge runtimes). Each client session gets its own session id (`Mcp-Session-Id` header), managed automatically.
285
+
286
+ Enable HTTP mode with any of `--http`, `QVERIS_MCP_TRANSPORT=http`, or by setting an HTTP port/host:
287
+
288
+ ```bash
289
+ # Local only (loopback): no inbound auth required
290
+ QVERIS_API_KEY=sk-... npx -y @qverisai/mcp --http --port 3000
291
+
292
+ # Exposed: bind all interfaces, require a bearer token, allow-list the public host
293
+ QVERIS_API_KEY=sk-... \
294
+ QVERIS_MCP_TRANSPORT=http \
295
+ QVERIS_MCP_HTTP_HOST=0.0.0.0 \
296
+ QVERIS_MCP_HTTP_AUTH_TOKEN=$(openssl rand -hex 32) \
297
+ QVERIS_MCP_ALLOWED_HOSTS=mcp.example.com \
298
+ npx -y @qverisai/mcp
299
+ ```
300
+
301
+ - The endpoint is `POST/GET/DELETE {path}` (default `/mcp`); `GET /health` returns an unauthenticated liveness probe.
302
+ - **Inbound auth:** set `QVERIS_MCP_HTTP_AUTH_TOKEN` to require `Authorization: Bearer <token>` on the MCP endpoint. The server **refuses to start** when binding a non-loopback host without a token, unless you set `QVERIS_MCP_HTTP_ALLOW_UNAUTHENTICATED=true` to delegate auth to an external proxy/gateway. Your `QVERIS_API_KEY` is the server's *outbound* credential to QVeris — it is **not** an inbound check, so anyone reaching an unauthenticated endpoint would spend your credits.
303
+ - **Embedding API:** the package root exports `startHttpServer`, `resolveTransportConfig`, `QverisClient`, and the session-auth types. An independently operated service can set `requireSessionBearer` on its resolved transport config and provide an asynchronous session factory. The transport requires a bearer, passes it only to that factory, stores only a credential fingerprint for session binding, and rejects credential changes. The embedding service owns validation, client construction, rate limits, deployment, and operations.
304
+ - DNS-rebinding protection is **on by default** (localhost + the bound host/port are allow-listed). When exposing the server publicly, add your public host via `QVERIS_MCP_ALLOWED_HOSTS`.
305
+ - Requests are capped at 4 MiB by default (`QVERIS_MCP_MAX_BODY_BYTES`), and idle sessions are evicted after 5 minutes (`QVERIS_MCP_SESSION_TIMEOUT_MS`).
306
+ - **Discovery:** registries and crawlers can learn about the server without connecting:
307
+ - **Server Card** at `GET {path}/server-card` (default `/mcp/server-card`), media type `application/mcp-server-card+json` — server identity, version, and the remote endpoint.
308
+ - **MCP Catalog** at `GET /.well-known/mcp/catalog.json` — a site-wide index pointing at the Server Card.
309
+ - Both are public (unauthenticated, CORS-enabled), even when an auth token is set. Behind a TLS proxy, set `QVERIS_MCP_PUBLIC_URL` (or send `X-Forwarded-Proto`) so the advertised URLs use your public origin.
310
+ - Full OAuth 2.1 authorization is tracked as a follow-up in [#107](https://github.com/QVerisAI/qveris-agent-toolkit/issues/107).
311
+
312
+ ## Environment Variables
313
+
314
+ | Variable | Required | Description |
315
+ |----------|----------|-------------|
316
+ | `QVERIS_API_KEY` | ✓ | Your QVeris API key |
317
+ | `QVERIS_BASE_URL` | | Override the built-in API base URL |
318
+ | `QVERIS_MAX_RETRIES` | | Retries for rate-limited (429) / transient (503) responses (default 3; `0` disables). Honors `Retry-After`, else backs off with jitter. |
319
+ | `QVERIS_MCP_TRANSPORT` | | `stdio` (default) or `http` |
320
+ | `QVERIS_MCP_HTTP_PORT` | | HTTP port (default `3000`; setting it implies HTTP mode) |
321
+ | `QVERIS_MCP_HTTP_HOST` | | HTTP bind host (default `127.0.0.1`) |
322
+ | `QVERIS_MCP_HTTP_PATH` | | MCP endpoint path (default `/mcp`) |
323
+ | `QVERIS_MCP_ALLOWED_HOSTS` | | Comma-separated extra `Host` values to allow (for DNS-rebinding protection) |
324
+ | `QVERIS_MCP_ALLOWED_ORIGINS` | | Comma-separated extra `Origin` values to allow |
325
+ | `QVERIS_MCP_DNS_REBINDING_PROTECTION` | | `true` (default) / `false` |
326
+ | `QVERIS_MCP_HTTP_JSON` | | `true` to return JSON responses instead of SSE (default `false`) |
327
+ | `QVERIS_MCP_HTTP_AUTH_TOKEN` | | Require `Authorization: Bearer <token>` on the MCP endpoint |
328
+ | `QVERIS_MCP_HTTP_ALLOW_UNAUTHENTICATED` | | `true` to allow a non-loopback bind without a token (auth delegated externally) |
329
+ | `QVERIS_MCP_MAX_BODY_BYTES` | | Max request body size in bytes (default `4194304`) |
330
+ | `QVERIS_MCP_SESSION_TIMEOUT_MS` | | Idle session TTL in ms (default `300000`) |
331
+ | `QVERIS_MCP_CONFIRM_CALLS` | | `true` to ask the user (via MCP elicitation) before each charged `call`; clients without elicitation proceed as before |
332
+ | `QVERIS_MCP_PUBLIC_URL` | | Public origin advertised in discovery documents (e.g. `https://mcp.example.com`) |
333
+
334
+ ## API Endpoint Override
335
+
336
+ The server uses its built-in API endpoint unless `QVERIS_BASE_URL` is set. API key prefixes and other environment variables do not select an endpoint. To target a custom endpoint, set `QVERIS_BASE_URL` in your MCP client config:
337
+
338
+ ```json
339
+ {
340
+ "mcpServers": {
341
+ "qveris": {
342
+ "command": "npx",
343
+ "args": ["-y", "@qverisai/mcp"],
344
+ "env": {
345
+ "QVERIS_API_KEY": "your-api-key",
346
+ "QVERIS_BASE_URL": "https://qveris.ai/api/v1"
347
+ }
348
+ }
349
+ }
350
+ }
351
+ ```
352
+
353
+ The override must be an HTTP(S) URL without credentials, a query string, or a fragment.
354
+
355
+ ## Examples
356
+
357
+ [`examples/agent-loop.ts`](examples/agent-loop.ts) drives this server over stdio
358
+ the way an agent runtime does: spawn it, list the tools, then run
359
+ discover → inspect → call by calling those tools. It is safe to run without an
360
+ API key (tool listing works unconfigured), and the call step is gated behind
361
+ `RUN_QVERIS_CALLS=1`.
362
+
363
+ ## Requirements
364
+
365
+ - Node.js 18.0.0 or higher
366
+ - A valid QVeris API key ([qveris.ai](https://qveris.ai))
367
+
368
+ ## Development
369
+
370
+ ```bash
371
+ # Clone the repository
372
+ git clone https://github.com/QVerisAI/qveris-agent-toolkit.git
373
+ cd qveris-agent-toolkit/packages/mcp
374
+
375
+ # Install dependencies
376
+ npm install
377
+
378
+ # Build
379
+ npm run build
380
+
381
+ # Run locally
382
+ QVERIS_API_KEY=your-key node dist/index.js
383
+ ```
384
+
385
+ ## License
386
+
387
+ MIT © [QVerisAI](https://github.com/QVerisAI)
388
+
389
+ ## Support
390
+
391
+ - 🐛 [Issue Tracker](https://github.com/QVerisAI/qveris-agent-toolkit/issues)
392
+ - 💬 Contact: contact@qveris.ai