mcp-from-openapi 2.6.0 → 2.7.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/README.md +25 -3
- package/annotations.d.ts +16 -1
- package/arazzo-expressions.d.ts +19 -0
- package/arazzo-types.d.ts +262 -0
- package/arazzo.d.ts +45 -0
- package/elicitation.d.ts +44 -0
- package/errors.d.ts +15 -0
- package/esm/index.mjs +2668 -93
- package/esm/package.json +5 -3
- package/generator.d.ts +22 -0
- package/index.d.ts +18 -2
- package/index.js +2681 -93
- package/lint.d.ts +33 -0
- package/naming-presets.d.ts +49 -0
- package/overlay.d.ts +43 -0
- package/package.json +5 -3
- package/schema-builder.d.ts +17 -0
- package/token-report.d.ts +65 -0
- package/type-signature.d.ts +43 -0
- package/types.d.ts +154 -4
- package/validator.d.ts +5 -0
package/lint.d.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { OpenAPIDocument } from './types';
|
|
2
|
+
export type LintSeverity = 'error' | 'warning' | 'info';
|
|
3
|
+
/**
|
|
4
|
+
* One agent-readiness finding. `path` names the operation (`GET /users`);
|
|
5
|
+
* `hint` says how to fix it — in the spec or via generate options/overlays.
|
|
6
|
+
*/
|
|
7
|
+
export interface LintFinding {
|
|
8
|
+
severity: LintSeverity;
|
|
9
|
+
/** Stable kebab-case finding code */
|
|
10
|
+
code: string;
|
|
11
|
+
message: string;
|
|
12
|
+
path: string;
|
|
13
|
+
hint?: string;
|
|
14
|
+
}
|
|
15
|
+
export interface LintResult {
|
|
16
|
+
/** Sorted: errors first, then warnings, then infos; by path within each */
|
|
17
|
+
findings: LintFinding[];
|
|
18
|
+
counts: {
|
|
19
|
+
error: number;
|
|
20
|
+
warning: number;
|
|
21
|
+
info: number;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
/** Query-parameter names that read as pagination controls (shared with response hints) */
|
|
25
|
+
export declare const PAGINATION_PARAM: RegExp;
|
|
26
|
+
/**
|
|
27
|
+
* Lint an OpenAPI document for agent-readiness: the spec-quality gaps that
|
|
28
|
+
* measurably degrade tool-calling accuracy (missing operationIds, absent or
|
|
29
|
+
* vague descriptions, unpaginated list endpoints, oversized schemas, missing
|
|
30
|
+
* examples). Small spec fixes routinely take tool-call success rates from
|
|
31
|
+
* mediocre to near-perfect — each finding carries a concrete hint.
|
|
32
|
+
*/
|
|
33
|
+
export declare function lintDocument(document: OpenAPIDocument): LintResult;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Naming presets.
|
|
3
|
+
*
|
|
4
|
+
* `dottedNaming` produces two-segment `ns.method` tool names whose halves are
|
|
5
|
+
* valid JavaScript identifiers — the shape code-execution surfaces (FrontMCP
|
|
6
|
+
* CodeCall) bind as ergonomic namespaces: a tool named `billing.listInvoices`
|
|
7
|
+
* becomes `await billing.listInvoices({...})` in sandbox code. Names with any
|
|
8
|
+
* other shape (no dot, or a half that is not an identifier) still work via
|
|
9
|
+
* `callTool('name', input)` but get no namespace binding.
|
|
10
|
+
*/
|
|
11
|
+
import type { NamingStrategy } from './types';
|
|
12
|
+
/**
|
|
13
|
+
* Namespace identifiers reserved by FrontMCP CodeCall's sandbox globals —
|
|
14
|
+
* a namespace equal to one of these would shadow (or be shadowed by) a
|
|
15
|
+
* sandbox binding, so `dottedNaming` suffixes it with `_`.
|
|
16
|
+
*/
|
|
17
|
+
export declare const CODECALL_RESERVED_NAMESPACES: readonly string[];
|
|
18
|
+
/** Options for the {@link dottedNaming} preset. */
|
|
19
|
+
export interface DottedNamingOptions {
|
|
20
|
+
/**
|
|
21
|
+
* Where the namespace half comes from: the operation's first tag, or the
|
|
22
|
+
* first path segment. `'tag'` falls back to the first path segment when the
|
|
23
|
+
* operation has no tags, then to `'api'`.
|
|
24
|
+
* @default 'tag'
|
|
25
|
+
*/
|
|
26
|
+
namespaceFrom?: 'tag' | 'firstPathSegment';
|
|
27
|
+
/**
|
|
28
|
+
* Additional reserved namespace names, merged with
|
|
29
|
+
* {@link CODECALL_RESERVED_NAMESPACES}.
|
|
30
|
+
*/
|
|
31
|
+
reservedNamespaces?: string[];
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Naming preset producing two-segment `ns.method` tool names bindable by
|
|
35
|
+
* code-execution namespaces (e.g. FrontMCP CodeCall's `await ns.method({...})`).
|
|
36
|
+
*
|
|
37
|
+
* The namespace half comes from the operation's first tag (or first path
|
|
38
|
+
* segment); the method half from the operationId (an `x-mcp` family name
|
|
39
|
+
* override arrives through the operationId argument), falling back to the
|
|
40
|
+
* HTTP method plus the path. Both halves are sanitized to identifiers, so the
|
|
41
|
+
* emitted name contains exactly one dot.
|
|
42
|
+
*
|
|
43
|
+
* Collision dedup in `generateTools()` appends `_<hash>` to the method half,
|
|
44
|
+
* which keeps the name namespace-parseable. Hash truncation can remove the
|
|
45
|
+
* dot when the namespace half alone approaches `maxToolNameLength` (≥ 55
|
|
46
|
+
* chars at the default cap of 64) — such names remain valid MCP names but
|
|
47
|
+
* lose namespace binding.
|
|
48
|
+
*/
|
|
49
|
+
export declare function dottedNaming(options?: DottedNamingOptions): NamingStrategy;
|
package/overlay.d.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A single Overlay action (OpenAPI Overlay Specification 1.0.0).
|
|
3
|
+
*/
|
|
4
|
+
export interface OverlayAction {
|
|
5
|
+
/** JSONPath expression selecting the nodes to act on (see supported subset below) */
|
|
6
|
+
target: string;
|
|
7
|
+
/** Human note; ignored by the processor */
|
|
8
|
+
description?: string;
|
|
9
|
+
/**
|
|
10
|
+
* Value merged into each matched node: objects deep-merge, arrays append
|
|
11
|
+
* the value, primitives are replaced.
|
|
12
|
+
*/
|
|
13
|
+
update?: unknown;
|
|
14
|
+
/** Remove each matched node from its parent instead of updating */
|
|
15
|
+
remove?: boolean;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* An OpenAPI Overlay document. Applied to specs at load time (before
|
|
19
|
+
* dereferencing and validation), overlays keep spec curation — agent-tuned
|
|
20
|
+
* descriptions, `x-mcp` flags — in a small separate file that survives every
|
|
21
|
+
* regeneration of the source spec.
|
|
22
|
+
*/
|
|
23
|
+
export interface OverlayDocument {
|
|
24
|
+
/** Overlay Specification version (1.x) */
|
|
25
|
+
overlay: string;
|
|
26
|
+
info?: {
|
|
27
|
+
title?: string;
|
|
28
|
+
version?: string;
|
|
29
|
+
};
|
|
30
|
+
/** URL of the spec this overlay targets; informational here */
|
|
31
|
+
extends?: string;
|
|
32
|
+
actions: OverlayAction[];
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Apply an OpenAPI Overlay 1.0 document to a spec, returning a NEW document
|
|
36
|
+
* (the input is never mutated). Actions run in order; targets that match
|
|
37
|
+
* nothing are skipped silently, per the Overlay specification.
|
|
38
|
+
*
|
|
39
|
+
* Update semantics: object targets deep-merge the update, array targets
|
|
40
|
+
* append it, primitive targets are replaced. `remove: true` deletes matched
|
|
41
|
+
* nodes (array elements are spliced, preserving order).
|
|
42
|
+
*/
|
|
43
|
+
export declare function applyOverlay<T extends object>(document: T, overlay: OverlayDocument): T;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mcp-from-openapi",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.7.0",
|
|
4
4
|
"description": "Production-ready library for converting OpenAPI specifications into MCP tool definitions",
|
|
5
5
|
"author": "AgentFront <info@agentfront.dev>",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -49,20 +49,22 @@
|
|
|
49
49
|
}
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@apidevtools/json-schema-ref-parser": "^15.
|
|
52
|
+
"@apidevtools/json-schema-ref-parser": "^15.5.1",
|
|
53
53
|
"openapi-types": "^12.1.3",
|
|
54
|
-
"yaml": "^2.
|
|
54
|
+
"yaml": "^2.9.0"
|
|
55
55
|
},
|
|
56
56
|
"peerDependencies": {
|
|
57
57
|
"zod": "^4.0.0"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
|
+
"@modelcontextprotocol/sdk": "^1.30.0",
|
|
60
61
|
"@swc/core": "~1.5.7",
|
|
61
62
|
"@swc/helpers": "^0.5.18",
|
|
62
63
|
"@swc/jest": "~0.2.38",
|
|
63
64
|
"@types/jest": "^29.5.0",
|
|
64
65
|
"@types/json-schema": "^7.0.15",
|
|
65
66
|
"@types/node": "^24.0.0",
|
|
67
|
+
"ajv": "^8.17.0",
|
|
66
68
|
"esbuild": "^0.27.2",
|
|
67
69
|
"jest": "^29.7.0",
|
|
68
70
|
"tslib": "^2.8.1",
|
package/schema-builder.d.ts
CHANGED
|
@@ -127,6 +127,23 @@ export declare class SchemaBuilder {
|
|
|
127
127
|
/** Keys whose value is an array of schemas */
|
|
128
128
|
private static readonly TRUNCATE_LIST_KEYS;
|
|
129
129
|
private static truncateDepthRecursive;
|
|
130
|
+
private static walkCopy;
|
|
131
|
+
/**
|
|
132
|
+
* Limit every object node to its first `max` properties (declaration
|
|
133
|
+
* order). Dropped properties are pruned from `required` and counted in a
|
|
134
|
+
* note appended to the node's description.
|
|
135
|
+
*/
|
|
136
|
+
static limitProperties(schema: JsonSchema, max: number): JsonSchema;
|
|
137
|
+
/**
|
|
138
|
+
* Cap every description in the schema tree to `maxLength` characters,
|
|
139
|
+
* truncating with an ellipsis.
|
|
140
|
+
*/
|
|
141
|
+
static capDescriptions(schema: JsonSchema, maxLength: number): JsonSchema;
|
|
142
|
+
/**
|
|
143
|
+
* Remove every `examples` array from the schema tree (a token-budget
|
|
144
|
+
* trimming step — validation keywords are untouched).
|
|
145
|
+
*/
|
|
146
|
+
static stripExamples(schema: JsonSchema): JsonSchema;
|
|
130
147
|
/**
|
|
131
148
|
* Simplify schema by removing unnecessary fields
|
|
132
149
|
*/
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { McpOpenAPITool } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Per-tool token estimate for the definition a client ships to the model.
|
|
4
|
+
*/
|
|
5
|
+
export interface ToolTokenEstimate {
|
|
6
|
+
name: string;
|
|
7
|
+
/** Estimated tokens for the full advertised definition */
|
|
8
|
+
tokens: number;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Context-budget report for a generated tool set.
|
|
12
|
+
*/
|
|
13
|
+
export interface ToolSetReport {
|
|
14
|
+
toolCount: number;
|
|
15
|
+
/** Sum of all per-tool estimates */
|
|
16
|
+
estimatedTokens: number;
|
|
17
|
+
/** Every tool, heaviest first */
|
|
18
|
+
perTool: ToolTokenEstimate[];
|
|
19
|
+
/** Human-readable budget warnings (empty when the set is comfortably sized) */
|
|
20
|
+
warnings: string[];
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Thresholds for {@link analyzeToolSet} warnings.
|
|
24
|
+
*/
|
|
25
|
+
export interface AnalyzeToolSetOptions {
|
|
26
|
+
/**
|
|
27
|
+
* Estimated-token budget for the whole tool set before a warning fires.
|
|
28
|
+
* ~1,000 tokens per tool is typical; ecosystem guidance flags pain beyond
|
|
29
|
+
* ~10K tokens of definitions.
|
|
30
|
+
* @default 10000
|
|
31
|
+
*/
|
|
32
|
+
tokenBudget?: number;
|
|
33
|
+
/**
|
|
34
|
+
* Tool count beyond which model selection accuracy measurably degrades
|
|
35
|
+
* (public evaluations put the cliff at ~30-40 tools).
|
|
36
|
+
* @default 40
|
|
37
|
+
*/
|
|
38
|
+
maxRecommendedTools?: number;
|
|
39
|
+
/**
|
|
40
|
+
* Per-tool estimate that marks a single tool as disproportionately heavy.
|
|
41
|
+
* @default 2000
|
|
42
|
+
*/
|
|
43
|
+
perToolWarning?: number;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Estimate the context-window cost of ONE tool definition — the fields a
|
|
47
|
+
* client advertises to the model (name, title, description, annotations,
|
|
48
|
+
* input/output schemas), serialized as JSON.
|
|
49
|
+
*
|
|
50
|
+
* The estimate is `ceil(chars / 4)` — the common BPE average for JSON-heavy
|
|
51
|
+
* English text. It is a sizing signal for curation decisions, not a
|
|
52
|
+
* tokenizer: real counts vary by model within roughly ±20%.
|
|
53
|
+
*/
|
|
54
|
+
export declare function estimateToolTokens(tool: McpOpenAPITool): number;
|
|
55
|
+
/**
|
|
56
|
+
* Analyze a generated tool set's context-window bill: per-tool estimates
|
|
57
|
+
* (heaviest first), the total, and curation warnings when the set crosses
|
|
58
|
+
* the thresholds where agent accuracy is known to degrade.
|
|
59
|
+
*
|
|
60
|
+
* ```ts
|
|
61
|
+
* const report = analyzeToolSet(await generator.generateTools());
|
|
62
|
+
* report.warnings.forEach((w) => console.warn(w));
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
export declare function analyzeToolSet(tools: McpOpenAPITool[], options?: AnalyzeToolSetOptions): ToolSetReport;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TypeScript call-signature emission.
|
|
3
|
+
*
|
|
4
|
+
* Renders a tool's final JSON Schemas (2020-12, post client-target transforms)
|
|
5
|
+
* as TypeScript type text for code-execution surfaces such as FrontMCP
|
|
6
|
+
* CodeCall, which present tools as importable typed functions instead of raw
|
|
7
|
+
* tool JSON. The emitted return type is always the UNWRAPPED OpenAPI response
|
|
8
|
+
* type — consumers that wrap results (e.g. `{status, ok, data, error}`) must
|
|
9
|
+
* wrap the type themselves.
|
|
10
|
+
*/
|
|
11
|
+
import type { JsonSchema } from './types';
|
|
12
|
+
/** TypeScript rendering of one tool's call contract. */
|
|
13
|
+
export interface ToolTypeScriptInfo {
|
|
14
|
+
/**
|
|
15
|
+
* One-line arrow type with inline anonymous types, e.g.
|
|
16
|
+
* `(input: { id: string; limit?: number }) => Promise<{ name: string }>`
|
|
17
|
+
*/
|
|
18
|
+
signature: string;
|
|
19
|
+
/**
|
|
20
|
+
* Self-contained declaration text: JSDoc from schema descriptions, named
|
|
21
|
+
* `<ToolName>Input` / `<ToolName>Output` types, and a `declare function`.
|
|
22
|
+
*/
|
|
23
|
+
declaration: string;
|
|
24
|
+
}
|
|
25
|
+
/** Options for the type-signature printer. */
|
|
26
|
+
export interface TypeSignatureOptions {
|
|
27
|
+
/**
|
|
28
|
+
* Nesting depth beyond which types collapse to `unknown`.
|
|
29
|
+
* @default 8
|
|
30
|
+
*/
|
|
31
|
+
maxDepth?: number;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Derive a PascalCase TypeScript identifier from an MCP tool name
|
|
35
|
+
* (`[A-Za-z0-9_.-]`). Empty results become `Tool`; a leading digit is
|
|
36
|
+
* prefixed with `T` (`3d.scan` → `T3dScan`).
|
|
37
|
+
*/
|
|
38
|
+
export declare function toPascalIdentifier(toolName: string): string;
|
|
39
|
+
/**
|
|
40
|
+
* Render a tool's TypeScript signature and self-contained declaration from
|
|
41
|
+
* its final (post-transform) schemas. Pure and deterministic.
|
|
42
|
+
*/
|
|
43
|
+
export declare function emitToolTypeScript(toolName: string, description: string | undefined, inputSchema: JsonSchema, outputSchema: JsonSchema | undefined, options?: TypeSignatureOptions): ToolTypeScriptInfo;
|
package/types.d.ts
CHANGED
|
@@ -84,6 +84,23 @@ export interface ToolAnnotations {
|
|
|
84
84
|
*/
|
|
85
85
|
openWorldHint?: boolean;
|
|
86
86
|
}
|
|
87
|
+
/**
|
|
88
|
+
* Tool icon (MCP spec 2025-11-25).
|
|
89
|
+
*/
|
|
90
|
+
export interface ToolIcon {
|
|
91
|
+
/**
|
|
92
|
+
* Icon URI (`https:` or `data:`).
|
|
93
|
+
*/
|
|
94
|
+
src: string;
|
|
95
|
+
/**
|
|
96
|
+
* MIME type, e.g. `image/png`.
|
|
97
|
+
*/
|
|
98
|
+
mimeType?: string;
|
|
99
|
+
/**
|
|
100
|
+
* Sizes the icon is available in, e.g. `['48x48', 'any']`.
|
|
101
|
+
*/
|
|
102
|
+
sizes?: string[];
|
|
103
|
+
}
|
|
87
104
|
/**
|
|
88
105
|
* Main MCP Tool definition generated from OpenAPI.
|
|
89
106
|
*
|
|
@@ -111,6 +128,21 @@ export interface McpOpenAPITool<TMeta extends ToolMetadata = ToolMetadata> {
|
|
|
111
128
|
* precedence).
|
|
112
129
|
*/
|
|
113
130
|
annotations?: ToolAnnotations;
|
|
131
|
+
/**
|
|
132
|
+
* MCP `_meta` (spec 2025-06-18): namespaced, client-visible metadata.
|
|
133
|
+
* Contains the `dev.agentfront.openapi/operation` entry when
|
|
134
|
+
* `GenerateOptions.emitMeta` is set, plus any `meta` object supplied via
|
|
135
|
+
* the `x-mcp` / `x-frontmcp` extensions (emitted even when the flag is
|
|
136
|
+
* off). Extension keys under `dev.agentfront.openapi/` are ignored, and
|
|
137
|
+
* pollution-gadget keys are stripped recursively.
|
|
138
|
+
*/
|
|
139
|
+
_meta?: Record<string, unknown>;
|
|
140
|
+
/**
|
|
141
|
+
* Tool icons (MCP spec 2025-11-25). From `x-frontmcp.icons` /
|
|
142
|
+
* `x-mcp.icons`, or the document's `info['x-logo']` when
|
|
143
|
+
* `GenerateOptions.inheritDocumentIcons` is set.
|
|
144
|
+
*/
|
|
145
|
+
icons?: ToolIcon[];
|
|
114
146
|
/**
|
|
115
147
|
* Combined input schema including all parameters
|
|
116
148
|
* (path, query, header, cookie, body)
|
|
@@ -292,6 +324,39 @@ export interface ToolMetadata {
|
|
|
292
324
|
* Contains annotations, cache config, codecall config, tags, etc.
|
|
293
325
|
*/
|
|
294
326
|
frontmcp?: FrontMcpExtensionData;
|
|
327
|
+
/**
|
|
328
|
+
* Response-shaping signals for consumers that paginate, truncate, or cache:
|
|
329
|
+
* present only when there is something to know.
|
|
330
|
+
*/
|
|
331
|
+
responseHints?: ResponseHints;
|
|
332
|
+
/**
|
|
333
|
+
* TypeScript rendering of the tool's call contract — present when
|
|
334
|
+
* `GenerateOptions.emitTypeSignatures` is set. Computed on the FINAL
|
|
335
|
+
* schemas (after formats, depth truncation, trimming, and client-target
|
|
336
|
+
* transforms). The return type is the UNWRAPPED response type.
|
|
337
|
+
*/
|
|
338
|
+
typescript?: import('./type-signature').ToolTypeScriptInfo;
|
|
339
|
+
/**
|
|
340
|
+
* Arazzo workflow IR — present only on tools produced by `fromArazzo()`.
|
|
341
|
+
* When set, `path`/`method` are non-HTTP placeholders
|
|
342
|
+
* (`arazzo:<workflowId>` / `'post'`); executors must drive requests from
|
|
343
|
+
* `workflow.steps[*].operation.mapper`, never from this tool's (empty)
|
|
344
|
+
* top-level mapper.
|
|
345
|
+
*/
|
|
346
|
+
workflow?: import('./arazzo-types').WorkflowIR;
|
|
347
|
+
}
|
|
348
|
+
/**
|
|
349
|
+
* Detected response-shaping signals. Clients cap tool results hard (Claude
|
|
350
|
+
* Code: 25K tokens) — these hints tell a consumer WHICH tools need paging or
|
|
351
|
+
* truncation before the first oversized response happens.
|
|
352
|
+
*/
|
|
353
|
+
export interface ResponseHints {
|
|
354
|
+
/** The success response contains an array without `maxItems` */
|
|
355
|
+
unboundedArray?: boolean;
|
|
356
|
+
/** Query parameters that look like pagination controls (limit, cursor, ...) */
|
|
357
|
+
paginationParams?: string[];
|
|
358
|
+
/** Unbounded array AND no pagination controls: truncate or shape server-side */
|
|
359
|
+
largeResponseRisk?: boolean;
|
|
295
360
|
}
|
|
296
361
|
/**
|
|
297
362
|
* FrontMCP extension data extracted from x-frontmcp in OpenAPI operations.
|
|
@@ -333,6 +398,14 @@ export interface FrontMcpExtensionData {
|
|
|
333
398
|
input: Record<string, unknown>;
|
|
334
399
|
output?: unknown;
|
|
335
400
|
}>;
|
|
401
|
+
/**
|
|
402
|
+
* MCP `_meta` entries to emit on the tool.
|
|
403
|
+
*/
|
|
404
|
+
meta?: Record<string, unknown>;
|
|
405
|
+
/**
|
|
406
|
+
* Tool icons to emit on the tool.
|
|
407
|
+
*/
|
|
408
|
+
icons?: ToolIcon[];
|
|
336
409
|
}
|
|
337
410
|
/**
|
|
338
411
|
* Security requirement definition
|
|
@@ -461,6 +534,14 @@ export interface LoadOptions {
|
|
|
461
534
|
* @default true (false when `secureDefaults` is set)
|
|
462
535
|
*/
|
|
463
536
|
followRedirects?: boolean;
|
|
537
|
+
/**
|
|
538
|
+
* OpenAPI Overlay 1.0 document(s) applied to the spec at load time, BEFORE
|
|
539
|
+
* dereferencing and validation, in order. Overlays keep curation
|
|
540
|
+
* (agent-tuned descriptions, `x-mcp` flags) in a separate file that
|
|
541
|
+
* survives spec regeneration. See `applyOverlay` for the supported
|
|
542
|
+
* JSONPath subset.
|
|
543
|
+
*/
|
|
544
|
+
overlays?: import('./overlay').OverlayDocument | import('./overlay').OverlayDocument[];
|
|
464
545
|
/**
|
|
465
546
|
* Opt into the strictest loading posture in one flag: redirects are not
|
|
466
547
|
* followed and external `$ref` resolution is disabled entirely
|
|
@@ -562,6 +643,43 @@ export interface GenerateOptions {
|
|
|
562
643
|
* @default 10
|
|
563
644
|
*/
|
|
564
645
|
maxSchemaDepth?: number;
|
|
646
|
+
/**
|
|
647
|
+
* How the tool description is assembled from the operation:
|
|
648
|
+
* - `summaryOnly` (default): summary, else description, else `METHOD path`
|
|
649
|
+
* - `descriptionOnly`: description, else summary, else `METHOD path`
|
|
650
|
+
* - `combined`: summary + blank line + description (whichever exist)
|
|
651
|
+
* - `full`: summary, description, `Operation: <id>`, and `METHOD path`
|
|
652
|
+
* An `x-mcp`-family description override always wins over the strategy.
|
|
653
|
+
* @default 'summaryOnly'
|
|
654
|
+
*/
|
|
655
|
+
descriptionStrategy?: 'summaryOnly' | 'descriptionOnly' | 'combined' | 'full';
|
|
656
|
+
/**
|
|
657
|
+
* Append a compact `Returns: ...` line to each tool description,
|
|
658
|
+
* summarizing the output schema (top-level shape and field names) — cheap
|
|
659
|
+
* context that measurably improves result-handling without shipping the
|
|
660
|
+
* whole response schema in prose.
|
|
661
|
+
* @default false
|
|
662
|
+
*/
|
|
663
|
+
appendResponseSummary?: boolean;
|
|
664
|
+
/**
|
|
665
|
+
* Limit object nodes in generated schemas to their first N properties
|
|
666
|
+
* (declaration order). Dropped properties are pruned from `required` and
|
|
667
|
+
* counted in a description note. The ROOT of `inputSchema` is exempt: its
|
|
668
|
+
* properties are mapper-backed parameters, so the cap applies inside each
|
|
669
|
+
* parameter subtree (and throughout output schemas). Unset = no limit.
|
|
670
|
+
*/
|
|
671
|
+
maxProperties?: number;
|
|
672
|
+
/**
|
|
673
|
+
* Cap every description in generated schemas to N characters (ellipsis
|
|
674
|
+
* truncation). Unset = no cap.
|
|
675
|
+
*/
|
|
676
|
+
maxDescriptionLength?: number;
|
|
677
|
+
/**
|
|
678
|
+
* Remove all `examples` arrays from generated schemas — a token-budget
|
|
679
|
+
* trimming step that leaves validation keywords untouched.
|
|
680
|
+
* @default false
|
|
681
|
+
*/
|
|
682
|
+
stripExamples?: boolean;
|
|
565
683
|
/**
|
|
566
684
|
* Include OpenAPI parameter-level and media-type-level `example`/`examples`
|
|
567
685
|
* values in generated schemas (as JSON Schema `examples` arrays). These
|
|
@@ -628,6 +746,35 @@ export interface GenerateOptions {
|
|
|
628
746
|
* When used without `resolveFormats`, only custom resolvers are applied.
|
|
629
747
|
*/
|
|
630
748
|
formatResolvers?: Record<string, FormatResolver>;
|
|
749
|
+
/**
|
|
750
|
+
* Emit a TypeScript rendering of each tool's call contract as
|
|
751
|
+
* `metadata.typescript = { signature, declaration }`. The signature is a
|
|
752
|
+
* one-line arrow type with inline anonymous types; the declaration is a
|
|
753
|
+
* self-contained block with named `<ToolName>Input` / `<ToolName>Output`
|
|
754
|
+
* types and JSDoc from schema descriptions. Computed on the FINAL schemas
|
|
755
|
+
* (after format resolution, depth truncation, trimming, and client-target
|
|
756
|
+
* transforms). The return type is the unwrapped OpenAPI response type —
|
|
757
|
+
* consumers that wrap results must wrap the type themselves.
|
|
758
|
+
* @default false
|
|
759
|
+
*/
|
|
760
|
+
emitTypeSignatures?: boolean;
|
|
761
|
+
/**
|
|
762
|
+
* Emit `_meta['dev.agentfront.openapi/operation']` on every tool with the
|
|
763
|
+
* source operation's coordinates: `{ path, method, operationId?, tags?,
|
|
764
|
+
* deprecated?, specTitle?, specVersion? }` (reverse-DNS key per MCP `_meta`
|
|
765
|
+
* conventions). Extension-supplied `meta` (`x-mcp` / `x-frontmcp`) merges
|
|
766
|
+
* on top and is emitted even when this flag is off.
|
|
767
|
+
* @default false
|
|
768
|
+
*/
|
|
769
|
+
emitMeta?: boolean;
|
|
770
|
+
/**
|
|
771
|
+
* When an operation has no extension-supplied icons, fall back to the
|
|
772
|
+
* document's `info['x-logo']` (Redoc convention) as a single icon applied
|
|
773
|
+
* to every tool. Off by default so one logo doesn't silently inflate all
|
|
774
|
+
* tool definitions.
|
|
775
|
+
* @default false
|
|
776
|
+
*/
|
|
777
|
+
inheritDocumentIcons?: boolean;
|
|
631
778
|
}
|
|
632
779
|
/**
|
|
633
780
|
* A function that enriches a JSON Schema based on its format field.
|
|
@@ -639,21 +786,24 @@ export type FormatResolver = (schema: JsonSchema) => JsonSchema;
|
|
|
639
786
|
*/
|
|
640
787
|
export interface NamingStrategy {
|
|
641
788
|
/**
|
|
642
|
-
* Resolver function for parameter name conflicts
|
|
789
|
+
* Resolver function for parameter name conflicts.
|
|
643
790
|
* @param paramName - Original parameter name
|
|
644
791
|
* @param location - Parameter location
|
|
645
792
|
* @param index - Index of conflicting parameter (0-based)
|
|
646
793
|
* @returns New parameter name
|
|
794
|
+
* @default a location-prefix resolver (`headerX_Trace`-style)
|
|
647
795
|
*/
|
|
648
|
-
conflictResolver
|
|
796
|
+
conflictResolver?: (paramName: string, location: ParameterLocation, index: number) => string;
|
|
649
797
|
/**
|
|
650
798
|
* Function to generate tool names
|
|
651
799
|
* @param path - OpenAPI path
|
|
652
800
|
* @param method - HTTP method
|
|
653
|
-
* @param operationId - Operation ID if available
|
|
801
|
+
* @param operationId - Operation ID if available (an `x-mcp` family name
|
|
802
|
+
* override arrives through this argument in place of the operationId)
|
|
803
|
+
* @param operation - The full operation object (for tag-aware strategies)
|
|
654
804
|
* @returns Tool name
|
|
655
805
|
*/
|
|
656
|
-
toolNameGenerator?: (path: string, method: HTTPMethod, operationId?: string) => string;
|
|
806
|
+
toolNameGenerator?: (path: string, method: HTTPMethod, operationId?: string, operation?: OperationObject) => string;
|
|
657
807
|
}
|
|
658
808
|
/**
|
|
659
809
|
* Validation result
|
package/validator.d.ts
CHANGED
|
@@ -14,6 +14,11 @@ export declare class Validator {
|
|
|
14
14
|
/**
|
|
15
15
|
* Validate paths
|
|
16
16
|
*/
|
|
17
|
+
/**
|
|
18
|
+
* Resolve a local `#/components/parameters/<name>` reference (JSON Pointer
|
|
19
|
+
* tokens decoded). Returns undefined for external or dangling references.
|
|
20
|
+
*/
|
|
21
|
+
private resolveParameterRef;
|
|
17
22
|
private validatePaths;
|
|
18
23
|
/**
|
|
19
24
|
* Validate an operation
|