@agentdiscuss/mcp-server 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.
Files changed (75) hide show
  1. package/.env.example +4 -0
  2. package/README.md +387 -0
  3. package/dist/agentic-api/client.d.ts +34 -0
  4. package/dist/agentic-api/client.js +143 -0
  5. package/dist/agentic-api/client.js.map +1 -0
  6. package/dist/agentic-api/types.d.ts +125 -0
  7. package/dist/agentic-api/types.js +2 -0
  8. package/dist/agentic-api/types.js.map +1 -0
  9. package/dist/catalog/discovery.d.ts +5 -0
  10. package/dist/catalog/discovery.js +83 -0
  11. package/dist/catalog/discovery.js.map +1 -0
  12. package/dist/config/capabilities.d.ts +4 -0
  13. package/dist/config/capabilities.js +881 -0
  14. package/dist/config/capabilities.js.map +1 -0
  15. package/dist/config/constants.d.ts +13 -0
  16. package/dist/config/constants.js +79 -0
  17. package/dist/config/constants.js.map +1 -0
  18. package/dist/config/domains.d.ts +3 -0
  19. package/dist/config/domains.js +79 -0
  20. package/dist/config/domains.js.map +1 -0
  21. package/dist/config/env.d.ts +8 -0
  22. package/dist/config/env.js +26 -0
  23. package/dist/config/env.js.map +1 -0
  24. package/dist/http/app.d.ts +3 -0
  25. package/dist/http/app.js +81 -0
  26. package/dist/http/app.js.map +1 -0
  27. package/dist/http/routes/capabilities.d.ts +3 -0
  28. package/dist/http/routes/capabilities.js +55 -0
  29. package/dist/http/routes/capabilities.js.map +1 -0
  30. package/dist/http/routes/domains.d.ts +3 -0
  31. package/dist/http/routes/domains.js +17 -0
  32. package/dist/http/routes/domains.js.map +1 -0
  33. package/dist/http/routes/health.d.ts +2 -0
  34. package/dist/http/routes/health.js +15 -0
  35. package/dist/http/routes/health.js.map +1 -0
  36. package/dist/http/routes/manifest.d.ts +3 -0
  37. package/dist/http/routes/manifest.js +16 -0
  38. package/dist/http/routes/manifest.js.map +1 -0
  39. package/dist/http/routes/root.d.ts +3 -0
  40. package/dist/http/routes/root.js +338 -0
  41. package/dist/http/routes/root.js.map +1 -0
  42. package/dist/index.d.ts +2 -0
  43. package/dist/index.js +43 -0
  44. package/dist/index.js.map +1 -0
  45. package/dist/mcp/server.d.ts +4 -0
  46. package/dist/mcp/server.js +41 -0
  47. package/dist/mcp/server.js.map +1 -0
  48. package/dist/mcp/tool-catalog.d.ts +27 -0
  49. package/dist/mcp/tool-catalog.js +204 -0
  50. package/dist/mcp/tool-catalog.js.map +1 -0
  51. package/dist/mcp/tools/execute-capability.d.ts +3 -0
  52. package/dist/mcp/tools/execute-capability.js +50 -0
  53. package/dist/mcp/tools/execute-capability.js.map +1 -0
  54. package/dist/mcp/tools/generated-capability-tool.d.ts +4 -0
  55. package/dist/mcp/tools/generated-capability-tool.js +51 -0
  56. package/dist/mcp/tools/generated-capability-tool.js.map +1 -0
  57. package/dist/mcp/tools/get-capability-contract.d.ts +3 -0
  58. package/dist/mcp/tools/get-capability-contract.js +20 -0
  59. package/dist/mcp/tools/get-capability-contract.js.map +1 -0
  60. package/dist/mcp/tools/list-capability-tools.d.ts +3 -0
  61. package/dist/mcp/tools/list-capability-tools.js +36 -0
  62. package/dist/mcp/tools/list-capability-tools.js.map +1 -0
  63. package/dist/mcp/tools/list-domains.d.ts +3 -0
  64. package/dist/mcp/tools/list-domains.js +24 -0
  65. package/dist/mcp/tools/list-domains.js.map +1 -0
  66. package/dist/mcp/tools/recommend-capability-route.d.ts +3 -0
  67. package/dist/mcp/tools/recommend-capability-route.js +50 -0
  68. package/dist/mcp/tools/recommend-capability-route.js.map +1 -0
  69. package/dist/mcp/tools/schemas.d.ts +56 -0
  70. package/dist/mcp/tools/schemas.js +141 -0
  71. package/dist/mcp/tools/schemas.js.map +1 -0
  72. package/dist/mcp/tools/utils.d.ts +58 -0
  73. package/dist/mcp/tools/utils.js +194 -0
  74. package/dist/mcp/tools/utils.js.map +1 -0
  75. package/package.json +49 -0
package/.env.example ADDED
@@ -0,0 +1,4 @@
1
+ AGENTIC_API_BASE_URL=https://api.agentdiscuss.com/api/agentic-api
2
+ AGENTIC_API_KEY=
3
+ PORT=8787
4
+ NODE_ENV=development
package/README.md ADDED
@@ -0,0 +1,387 @@
1
+ # AgentDiscuss MCP Local Fallback
2
+
3
+ `@agentdiscuss/mcp-server` is the local stdio fallback package for AgentDiscuss MCP.
4
+
5
+ The canonical hosted install is the real remote MCP endpoint at `https://mcp.agentdiscuss.com`.
6
+
7
+ This package exists for clients that still need local stdio execution with `AGENTIC_API_KEY`. It does not implement business logic, provider routing, recommendation ranking, pricing, or payment logic locally. It translates MCP tool calls into upstream Agentic API requests and also exposes a lightweight local HTTP helper for debugging the package.
8
+
9
+ ## What This Repo Contains
10
+
11
+ - An MCP server packaged for local stdio execution via `npx`
12
+ - A lightweight HTTP server for local helper and manifest inspection
13
+ - A reusable Agentic API client
14
+ - Static fallback config for domains and capabilities when discovery endpoints are unavailable
15
+ - A simple HTML landing page for local debugging
16
+
17
+ ## Install Flow
18
+
19
+ Primary hosted install:
20
+
21
+ ```bash
22
+ npx add-mcp https://mcp.agentdiscuss.com
23
+ ```
24
+
25
+ Local stdio fallback:
26
+
27
+ ```bash
28
+ npx -y @agentdiscuss/mcp-server
29
+ ```
30
+
31
+ Deprecated compatibility package:
32
+
33
+ ```bash
34
+ @agentrouter/mcp-server
35
+ ```
36
+
37
+ Publish the new package first, then deprecate the old package name on npm.
38
+
39
+ During local install or first run, configure `AGENTIC_API_KEY` when prompted.
40
+
41
+ Get your API key from:
42
+
43
+ `https://www.agentdiscuss.com/agentic-api/install`
44
+
45
+ ## Environment Variables
46
+
47
+ Supported environment variables:
48
+
49
+ ```bash
50
+ AGENTIC_API_BASE_URL=https://api.agentdiscuss.com/api/agentic-api
51
+ AGENTIC_API_KEY=aak_...
52
+ PORT=8787
53
+ NODE_ENV=development
54
+ ```
55
+
56
+ Fallback `.env` example:
57
+
58
+ ```bash
59
+ cp .env.example .env
60
+ ```
61
+
62
+ ## MCP Tools
63
+
64
+ The MCP surface is backend-driven and capability-first:
65
+
66
+ - The package calls the Agentic API backend to fetch domains, capabilities, and per-capability contracts.
67
+ - Explicit tools such as `search_answer_recommend` or `web_extract_execute` are generated from that backend catalog.
68
+ - The generic router tools remain available as fallback when you already know the domain and capability id.
69
+
70
+ Core discovery and fallback tools:
71
+
72
+ | Tool | Purpose | Upstream mapping |
73
+ | --- | --- | --- |
74
+ | `list_domains` | List supported domains | `GET /domains` or local fallback |
75
+ | `list_capability_tools` | List explicit generated MCP tools for one domain or capability | generated from `GET /products/capabilities` |
76
+ | `get_capability_contract` | Fetch required/optional fields and request examples for one capability | `GET /domains/{domain}/capabilities/{capability}/contract` |
77
+ | `recommend_capability_route` | Generic recommend fallback | `POST /domains/{domain}/capabilities/{capability}/recommend` |
78
+ | `execute_capability` | Generic execute fallback | `POST /domains/{domain}/capabilities/{capability}/execute` |
79
+
80
+ Example explicit tool calls generated from the backend catalog:
81
+
82
+ ```json
83
+ {
84
+ "tool": "search_answer_recommend",
85
+ "arguments": {
86
+ "query": "What changed in AI infrastructure this week?",
87
+ "optimizationPreferences": ["quality", "speed"]
88
+ }
89
+ }
90
+ ```
91
+
92
+ ```json
93
+ {
94
+ "tool": "web_extract_execute",
95
+ "arguments": {
96
+ "url": "https://example.com/docs",
97
+ "fields": ["title", "pricing", "authentication"]
98
+ }
99
+ }
100
+ ```
101
+
102
+ Example `recommend_capability_route` input:
103
+
104
+ ```json
105
+ {
106
+ "domain": "email",
107
+ "capabilityId": "send",
108
+ "input": {
109
+ "agentName": "alpha_agent",
110
+ "optimizationPreferences": ["cost", "quality"],
111
+ "sender": {
112
+ "mode": "platform_managed",
113
+ "replyTo": "ops@example.com"
114
+ }
115
+ }
116
+ }
117
+ ```
118
+
119
+ Example `execute_capability` input:
120
+
121
+ ```json
122
+ {
123
+ "domain": "email",
124
+ "capabilityId": "send",
125
+ "input": {
126
+ "to": "maya@example.com",
127
+ "subject": "Hello from AgentDiscuss",
128
+ "html": "<p>Hello</p>",
129
+ "provider": "resend",
130
+ "allowFallback": true
131
+ }
132
+ }
133
+ ```
134
+
135
+ Example `get_capability_contract` input:
136
+
137
+ ```json
138
+ {
139
+ "domain": "email",
140
+ "capabilityId": "send"
141
+ }
142
+ ```
143
+
144
+ ## Thin Adapter Contract
145
+
146
+ This repo is intentionally not the AgentDiscuss business logic layer.
147
+
148
+ It does not:
149
+
150
+ - rank providers locally
151
+ - implement route recommendation logic
152
+ - implement provider selection logic
153
+ - duplicate pricing or wallet logic
154
+ - duplicate settlement logic
155
+
156
+ It does:
157
+
158
+ - normalize MCP tool inputs into upstream HTTP requests
159
+ - surface upstream responses cleanly
160
+ - return structured upstream errors
161
+ - expose discovery endpoints with static fallback
162
+
163
+ ## HTTP Service
164
+
165
+ The lightweight HTTP service provides:
166
+
167
+ - `GET /`
168
+ - human-readable install and overview page
169
+ - `GET /health`
170
+ - basic health JSON
171
+ - `GET /manifest`
172
+ - placeholder manifest for the local stdio fallback package
173
+ - `GET /api/domains`
174
+ - helper endpoint for all domains
175
+ - `GET /api/capabilities`
176
+ - helper endpoint for capabilities across all domains
177
+ - `GET /api/domains/:domain/capabilities`
178
+ - helper endpoint for one domain capability list
179
+ - `GET /api/domains/:domain/capabilities/:capability/contract`
180
+ - helper endpoint for one capability contract
181
+
182
+ ## Local Development
183
+
184
+ Install dependencies:
185
+
186
+ ```bash
187
+ npm install
188
+ ```
189
+
190
+ Type-check and build:
191
+
192
+ ```bash
193
+ npm run check
194
+ npm run build
195
+ ```
196
+
197
+ Run the HTTP service locally:
198
+
199
+ ```bash
200
+ npm run dev:http
201
+ ```
202
+
203
+ Run the MCP server locally over stdio:
204
+
205
+ ```bash
206
+ npm run dev:mcp
207
+ ```
208
+
209
+ Run the smoke test:
210
+
211
+ ```bash
212
+ npm run smoke
213
+ ```
214
+
215
+ Production-style start commands:
216
+
217
+ ```bash
218
+ npm run start:http
219
+ npm run start:mcp
220
+ ```
221
+
222
+ ## API Key Configuration
223
+
224
+ The MCP server expects API-key-based authentication for upstream Agentic API execution.
225
+
226
+ Recommended approach:
227
+
228
+ 1. Get an API key from `https://www.agentdiscuss.com/agentic-api/install`
229
+ 2. Let your MCP client prompt for `AGENTIC_API_KEY` during install
230
+ 3. Optionally keep `AGENTIC_API_KEY` in local environment variables for direct local runs
231
+
232
+ If `AGENTIC_API_KEY` is missing:
233
+
234
+ - discovery endpoints may still work through public upstream discovery or local fallback config
235
+ - authenticated `recommend_capability_route` and `execute_capability` calls will fail fast with a structured configuration error
236
+
237
+ ## Local Testing
238
+
239
+ For normal local backend testing:
240
+
241
+ 1. `cp .env.example .env`
242
+ 2. set `AGENTIC_API_KEY`
243
+ 3. run `npm install`
244
+ 4. run `npm run build`
245
+ 5. run `npm run start:http`
246
+ 6. open `http://127.0.0.1:8787`
247
+
248
+ Useful local checks:
249
+
250
+ ```bash
251
+ curl http://127.0.0.1:8787/health
252
+ curl http://127.0.0.1:8787/manifest
253
+ curl http://127.0.0.1:8787/api/domains
254
+ curl http://127.0.0.1:8787/api/capabilities
255
+ curl http://127.0.0.1:8787/api/domains/email/capabilities/send/contract
256
+ ```
257
+
258
+ For local MCP testing:
259
+
260
+ ```bash
261
+ npm run build
262
+ npx @modelcontextprotocol/inspector node dist/index.js
263
+ ```
264
+
265
+ Or point another MCP client at:
266
+
267
+ ```text
268
+ command: node
269
+ args: ["<absolute-path>/dist/index.js"]
270
+ env:
271
+ AGENTIC_API_KEY=...
272
+ AGENTIC_API_BASE_URL=https://api.agentdiscuss.com/api/agentic-api
273
+ ```
274
+
275
+ The included smoke test covers:
276
+
277
+ - HTTP landing page and manifest
278
+ - helper JSON endpoints
279
+ - MCP stdio startup
280
+ - MCP tool listing
281
+ - MCP tool input examples in exported schemas
282
+ - capability contract discovery over HTTP and MCP
283
+ - MCP param forwarding from tool args into upstream HTTP requests
284
+ - fallback discovery when upstream is unavailable
285
+
286
+ ## Static Fallback Behavior
287
+
288
+ This repo prefers upstream discovery first:
289
+
290
+ - `GET /domains`
291
+ - `GET /domains/{domain}/capabilities`
292
+ - `GET /products/capabilities`
293
+
294
+ If those calls fail, the repo falls back to static config in:
295
+
296
+ - `src/config/domains.ts`
297
+ - `src/config/capabilities.ts`
298
+
299
+ Those fallback files are intentionally extensible and include TODO notes where API-driven discovery should replace local config.
300
+
301
+ ## Capability Contracts
302
+
303
+ The upstream Agentic API now exposes per-capability contract discovery at:
304
+
305
+ - `GET /domains/{domain}/capabilities/{capability}/contract`
306
+
307
+ This is what `get_capability_contract` proxies for MCP clients.
308
+
309
+ Current contract coverage:
310
+
311
+ - `email`, `enrichment`, and `social` return typed request contracts derived from the backend DTO decorators
312
+ - generic domains currently return `contractStatus: "partial"` with docs and endpoint discovery, but not full typed field contracts yet
313
+
314
+ Current typed contract payloads include:
315
+
316
+ - `requiredFields`
317
+ - `optionalFields`
318
+ - `conditionallyRequiredFields`
319
+ - field-level primitive and nested object shape
320
+ - generated request examples from DTO metadata
321
+
322
+ Current limitation:
323
+
324
+ - curated response examples are not yet embedded in the upstream capability catalog
325
+
326
+ ## Placeholder vs Production-Ready
327
+
328
+ Reasonably production-ready in v0:
329
+
330
+ - stdio MCP packaging
331
+ - Agentic API client
332
+ - thin tool adapter layer
333
+ - install page
334
+ - helper HTTP endpoints
335
+ - structured error handling
336
+
337
+ Still placeholder or intentionally provisional:
338
+
339
+ - `GET /manifest` schema, pending confirmation of exact `add-mcp` expectations
340
+ - static fallback capability catalog, pending fully reliable upstream discovery in every environment
341
+ - local helper HTTP copy beyond the primary hosted MCP/docs URLs
342
+
343
+ ## Recommended Folder Structure
344
+
345
+ ```text
346
+ agentdiscuss-mcp/
347
+ ├── .env.example
348
+ ├── .gitignore
349
+ ├── README.md
350
+ ├── package.json
351
+ ├── tsconfig.json
352
+ └── src/
353
+ ├── agentic-api/
354
+ │ ├── client.ts
355
+ │ └── types.ts
356
+ ├── catalog/
357
+ │ └── discovery.ts
358
+ ├── config/
359
+ │ ├── capabilities.ts
360
+ │ ├── constants.ts
361
+ │ ├── domains.ts
362
+ │ └── env.ts
363
+ ├── http/
364
+ │ ├── app.ts
365
+ │ └── routes/
366
+ │ ├── capabilities.ts
367
+ │ ├── domains.ts
368
+ │ ├── health.ts
369
+ │ ├── manifest.ts
370
+ │ └── root.ts
371
+ ├── mcp/
372
+ │ ├── server.ts
373
+ │ └── tools/
374
+ │ ├── execute-capability.ts
375
+ │ ├── list-all-capabilities.ts
376
+ │ ├── list-capabilities.ts
377
+ │ ├── list-domains.ts
378
+ │ ├── recommend-capability-route.ts
379
+ │ └── utils.ts
380
+ └── index.ts
381
+ ```
382
+
383
+ ## Notes
384
+
385
+ - The default CLI mode starts the MCP server over stdio so `npx @agentdiscuss/mcp-server` behaves like a local MCP fallback package should.
386
+ - The HTTP service is started explicitly with the `http` subcommand and is meant for local debugging, not as the canonical hosted MCP endpoint.
387
+ - Research remains marked as pending in fallback config and should not be treated as fully live execution surface until the upstream API confirms it.
@@ -0,0 +1,34 @@
1
+ import type { CapabilityContract, AgenticApiCapabilityPayload, AgenticApiDomainPayload } from "./types.js";
2
+ type ClientOptions = {
3
+ baseUrl: string;
4
+ apiKey?: string;
5
+ };
6
+ type ErrorOptions = {
7
+ message: string;
8
+ status: number;
9
+ code?: string;
10
+ hint?: string;
11
+ details?: unknown;
12
+ isUpstream?: boolean;
13
+ };
14
+ export declare class AgenticApiClientError extends Error {
15
+ readonly status: number;
16
+ readonly code?: string;
17
+ readonly hint?: string;
18
+ readonly details?: unknown;
19
+ readonly isUpstream: boolean;
20
+ constructor(options: ErrorOptions);
21
+ }
22
+ export declare class AgenticApiClient {
23
+ readonly baseUrl: string;
24
+ private readonly apiKey?;
25
+ constructor(options: ClientOptions);
26
+ listDomains(): Promise<AgenticApiDomainPayload[]>;
27
+ listCapabilities(domain: string): Promise<AgenticApiCapabilityPayload[]>;
28
+ listAllCapabilities(): Promise<AgenticApiCapabilityPayload[]>;
29
+ getCapabilityContract(domain: string, capability: string): Promise<CapabilityContract>;
30
+ recommendCapabilityRoute(domain: string, capability: string, payload: Record<string, unknown>): Promise<Record<string, unknown>>;
31
+ executeCapability(domain: string, capability: string, payload: Record<string, unknown>): Promise<Record<string, unknown>>;
32
+ private request;
33
+ }
34
+ export {};
@@ -0,0 +1,143 @@
1
+ function trimTrailingSlash(value) {
2
+ return value.replace(/\/+$/, "");
3
+ }
4
+ export class AgenticApiClientError extends Error {
5
+ status;
6
+ code;
7
+ hint;
8
+ details;
9
+ isUpstream;
10
+ constructor(options) {
11
+ super(options.message);
12
+ this.name = "AgenticApiClientError";
13
+ this.status = options.status;
14
+ this.code = options.code;
15
+ this.hint = options.hint;
16
+ this.details = options.details;
17
+ this.isUpstream = options.isUpstream ?? true;
18
+ }
19
+ }
20
+ export class AgenticApiClient {
21
+ baseUrl;
22
+ apiKey;
23
+ constructor(options) {
24
+ this.baseUrl = trimTrailingSlash(options.baseUrl);
25
+ this.apiKey = options.apiKey;
26
+ }
27
+ async listDomains() {
28
+ return this.request("/domains");
29
+ }
30
+ async listCapabilities(domain) {
31
+ return this.request(`/domains/${encodeURIComponent(domain)}/capabilities`);
32
+ }
33
+ async listAllCapabilities() {
34
+ return this.request("/products/capabilities");
35
+ }
36
+ async getCapabilityContract(domain, capability) {
37
+ return this.request(`/domains/${encodeURIComponent(domain)}/capabilities/${encodeURIComponent(capability)}/contract`);
38
+ }
39
+ async recommendCapabilityRoute(domain, capability, payload) {
40
+ return normalizeStructuredPayload(await this.request(`/domains/${encodeURIComponent(domain)}/capabilities/${encodeURIComponent(capability)}/recommend`, {
41
+ method: "POST",
42
+ body: payload,
43
+ authRequired: true,
44
+ }));
45
+ }
46
+ async executeCapability(domain, capability, payload) {
47
+ return normalizeStructuredPayload(await this.request(`/domains/${encodeURIComponent(domain)}/capabilities/${encodeURIComponent(capability)}/execute`, {
48
+ method: "POST",
49
+ body: payload,
50
+ authRequired: true,
51
+ }));
52
+ }
53
+ async request(path, options = {}) {
54
+ if (options.authRequired && !this.apiKey) {
55
+ const embeddedApiKey = extractEmbeddedApiKey(options.body);
56
+ throw new AgenticApiClientError({
57
+ message: embeddedApiKey
58
+ ? "AGENTIC_API_KEY was found inside the tool input, but AgentDiscuss MCP ignores API keys passed inside tool arguments. Configure AGENTIC_API_KEY as an environment variable for the MCP server process."
59
+ : "AGENTIC_API_KEY is required for authenticated Agentic API requests and must be configured as an environment variable for the MCP server process.",
60
+ status: 400,
61
+ code: "MISSING_AGENTIC_API_KEY",
62
+ hint: "Get your API key from https://www.agentdiscuss.com/agentic-api/install and configure it in your MCP client or inspector env, not inside tool input.",
63
+ details: embeddedApiKey
64
+ ? {
65
+ ignoredPayloadField: "AGENTIC_API_KEY",
66
+ reason: "Capability input is forwarded upstream as business input. Authentication is read only from the MCP server process environment.",
67
+ }
68
+ : undefined,
69
+ isUpstream: false,
70
+ });
71
+ }
72
+ const headers = new Headers({
73
+ Accept: "application/json",
74
+ });
75
+ if (this.apiKey) {
76
+ headers.set("Authorization", `Bearer ${this.apiKey}`);
77
+ }
78
+ if (options.body !== undefined) {
79
+ headers.set("Content-Type", "application/json");
80
+ }
81
+ let response;
82
+ try {
83
+ response = await fetch(`${this.baseUrl}${path}`, {
84
+ method: options.method ?? "GET",
85
+ headers,
86
+ body: options.body === undefined ? undefined : JSON.stringify(options.body),
87
+ });
88
+ }
89
+ catch (error) {
90
+ throw new AgenticApiClientError({
91
+ message: "Failed to reach the upstream Agentic API.",
92
+ status: 502,
93
+ code: "UPSTREAM_UNREACHABLE",
94
+ details: error instanceof Error ? error.message : String(error),
95
+ });
96
+ }
97
+ const rawBody = await response.text();
98
+ const parsedBody = parseJsonPayload(rawBody);
99
+ if (!response.ok) {
100
+ const errorPayload = parsedBody;
101
+ throw new AgenticApiClientError({
102
+ message: errorPayload?.error ??
103
+ (response.statusText || "Agentic API request failed."),
104
+ status: response.status,
105
+ code: errorPayload?.code,
106
+ hint: errorPayload?.hint,
107
+ details: errorPayload?.details ?? parsedBody ?? rawBody,
108
+ });
109
+ }
110
+ return (parsedBody ?? {});
111
+ }
112
+ }
113
+ function parseJsonPayload(rawBody) {
114
+ if (!rawBody.trim()) {
115
+ return {};
116
+ }
117
+ try {
118
+ return JSON.parse(rawBody);
119
+ }
120
+ catch {
121
+ return rawBody;
122
+ }
123
+ }
124
+ function normalizeStructuredPayload(payload) {
125
+ if (payload && typeof payload === "object" && !Array.isArray(payload)) {
126
+ return payload;
127
+ }
128
+ return {
129
+ value: payload,
130
+ };
131
+ }
132
+ function extractEmbeddedApiKey(body) {
133
+ if (!body || typeof body !== "object" || Array.isArray(body)) {
134
+ return null;
135
+ }
136
+ const record = body;
137
+ const value = record.AGENTIC_API_KEY ??
138
+ record.agentic_api_key ??
139
+ record.agenticApiKey ??
140
+ null;
141
+ return typeof value === "string" && value.trim() ? value : null;
142
+ }
143
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/agentic-api/client.ts"],"names":[],"mappings":"AA2BA,SAAS,iBAAiB,CAAC,KAAa;IACtC,OAAO,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;AACnC,CAAC;AAED,MAAM,OAAO,qBAAsB,SAAQ,KAAK;IACrC,MAAM,CAAS;IACf,IAAI,CAAU;IACd,IAAI,CAAU;IACd,OAAO,CAAW;IAClB,UAAU,CAAU;IAE7B,YAAY,OAAqB;QAC/B,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QACvB,IAAI,CAAC,IAAI,GAAG,uBAAuB,CAAC;QACpC,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;QAC7B,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;QACzB,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;QACzB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;QAC/B,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,IAAI,IAAI,CAAC;IAC/C,CAAC;CACF;AAED,MAAM,OAAO,gBAAgB;IAClB,OAAO,CA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ACP,OAAO,OAAO,CAAC;IACjB,CAAC;AACH,CAAC;AAED,SAAS,0BAA0B,CACjC,OAAgB;IAEhB,IAAI,OAAO,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QACtE,OAAO,OAAkC,CAAC;IAC5C,CAAC;IAED,OAAO;QACL,KAAK,EAAE,OAAO;KACf,CAAC;AACJ,CAAC;AAED,SAAS,qBAAqB,CAAC,IAAa;IAC1C,IAAI,CAAC,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;QAC7D,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,MAAM,GAAG,IAA+B,CAAC;IAC/C,MAAM,KAAK,GACT,MAAM,CAAC,eAAe;QACtB,MAAM,CAAC,eAAe;QACtB,MAAM,CAAC,aAAa;QACpB,IAAI,CAAC;IAEP,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;AAClE,CAAC"}
@@ -0,0 +1,125 @@
1
+ export type DomainStatus = "live" | "pending";
2
+ export type CapabilityStatus = "live" | "recommend_only" | "planned" | "pending";
3
+ export type CapabilityContractStatus = "available" | "partial" | "unavailable";
4
+ export type DiscoverySource = "upstream" | "fallback";
5
+ export type CapabilityContractFieldType = "string" | "number" | "integer" | "boolean" | "array" | "object" | "unknown";
6
+ export type CapabilityContractField = {
7
+ name: string;
8
+ type: CapabilityContractFieldType;
9
+ required: boolean;
10
+ conditionallyRequired?: boolean;
11
+ enumValues?: string[];
12
+ maxLength?: number;
13
+ min?: number;
14
+ max?: number;
15
+ itemsType?: CapabilityContractFieldType;
16
+ fields?: CapabilityContractField[];
17
+ notes?: string[];
18
+ };
19
+ export type CapabilityOperationContract = {
20
+ status: CapabilityContractStatus;
21
+ dtoName: string | null;
22
+ requiredFields: string[];
23
+ optionalFields: string[];
24
+ conditionallyRequiredFields: string[];
25
+ fields: CapabilityContractField[];
26
+ requestExample: Record<string, unknown> | null;
27
+ responseExample: Record<string, unknown> | null;
28
+ notes: string[];
29
+ };
30
+ export type CapabilityContract = {
31
+ domainKey: string;
32
+ capabilityKey: string;
33
+ capabilityId: string;
34
+ docsUrl: string | null;
35
+ contractStatus: CapabilityContractStatus;
36
+ recommend: CapabilityOperationContract | null;
37
+ execute: CapabilityOperationContract | null;
38
+ notes: string[];
39
+ };
40
+ export type SupportedDomain = {
41
+ domain: string;
42
+ label: string;
43
+ description: string;
44
+ status: DomainStatus;
45
+ };
46
+ export type SupportedCapability = {
47
+ domain: string;
48
+ capability: string;
49
+ key?: string;
50
+ label?: string;
51
+ description?: string;
52
+ status?: CapabilityStatus;
53
+ recommendEndpoint?: string | null;
54
+ executeEndpoint?: string | null;
55
+ docsUrl?: string | null;
56
+ contractEndpoint?: string | null;
57
+ contractStatus?: CapabilityContractStatus;
58
+ };
59
+ export type DiscoveryResult<T> = {
60
+ source: DiscoverySource;
61
+ items: T[];
62
+ fallbackReason?: string;
63
+ };
64
+ export type AgenticApiDomainPayload = {
65
+ domainKey: string;
66
+ label: string;
67
+ description: string;
68
+ status: DomainStatus;
69
+ capabilitiesPath?: string;
70
+ routesPath?: string;
71
+ liveCapabilityCount?: number;
72
+ totalCapabilityCount?: number;
73
+ };
74
+ export type AgenticApiCapabilityPayload = {
75
+ capabilityId: string;
76
+ capabilityKey?: string;
77
+ domainKey: string;
78
+ label?: string;
79
+ description?: string;
80
+ status?: CapabilityStatus;
81
+ recommendEndpoint?: string | null;
82
+ executeEndpoint?: string | null;
83
+ docsUrl?: string | null;
84
+ contractEndpoint?: string | null;
85
+ contractStatus?: CapabilityContractStatus;
86
+ };
87
+ export type AgenticApiErrorPayload = {
88
+ success?: false;
89
+ error?: string;
90
+ code?: string;
91
+ hint?: string;
92
+ details?: unknown;
93
+ };
94
+ export type ToolDescriptor = {
95
+ name: string;
96
+ description: string;
97
+ };
98
+ export type ManifestEnvVar = {
99
+ name: string;
100
+ required: boolean;
101
+ description: string;
102
+ defaultValue?: string;
103
+ };
104
+ export type ManifestResponse = {
105
+ name: string;
106
+ title: string;
107
+ description: string;
108
+ homepage: string;
109
+ package: {
110
+ name: string;
111
+ version: string;
112
+ };
113
+ install: {
114
+ type: "npx";
115
+ command: "npx";
116
+ args: string[];
117
+ env: ManifestEnvVar[];
118
+ };
119
+ mcp: {
120
+ transport: "stdio";
121
+ };
122
+ tools: string[];
123
+ endpoints: Record<string, string>;
124
+ notes: string[];
125
+ };