@runapi.ai/mcp-core 0.1.0 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -9,6 +9,7 @@ export declare function findModel(model: string, source: Contract): ModelInfo |
9
9
  export declare function findModels(model: string, source: Contract): ModelInfo[];
10
10
  export declare function findModelForAction(service: string, action: string, model: string | undefined, source: Contract): ModelInfo | undefined;
11
11
  export declare function fieldsForModel(action: ContractAction, model: string): Record<string, ContractField>;
12
+ export declare function declaredFieldsForAction(action: ContractAction): Record<string, ContractField>;
12
13
  export declare function fieldSummary(fields: Record<string, ContractField>): {
13
14
  name: string;
14
15
  required: boolean;
package/dist/contract.js CHANGED
@@ -6,7 +6,6 @@ export function listContractModels(source) {
6
6
  service,
7
7
  action: action.endpoint,
8
8
  route_action: routeAction(actionSlug),
9
- provider: action.provider,
10
9
  model_line: action.model,
11
10
  model,
12
11
  fields: fieldsForModel(action, model)
@@ -48,6 +47,18 @@ export function findModelForAction(service, action, model, source) {
48
47
  if (!entry) {
49
48
  return undefined;
50
49
  }
50
+ // No-model endpoints (models: []) carry their fields under the "_" roster and
51
+ // resolve to a ModelInfo with no model slug.
52
+ if (entry.models.length === 0) {
53
+ return {
54
+ service,
55
+ action: entry.endpoint,
56
+ route_action: entry.endpoint,
57
+ model_line: entry.model,
58
+ model: undefined,
59
+ fields: fieldsForModel(entry, "_")
60
+ };
61
+ }
51
62
  const selectedModel = model || entry.models[0];
52
63
  if (!entry.models.includes(selectedModel)) {
53
64
  return undefined;
@@ -56,14 +67,61 @@ export function findModelForAction(service, action, model, source) {
56
67
  service,
57
68
  action: entry.endpoint,
58
69
  route_action: entry.endpoint,
59
- provider: entry.provider,
60
70
  model_line: entry.model,
61
71
  model: selectedModel,
62
72
  fields: fieldsForModel(entry, selectedModel)
63
73
  };
64
74
  }
65
75
  export function fieldsForModel(action, model) {
66
- return action.fields_by_model[model] || action.fields_by_model.__nil_model__ || {};
76
+ return action.fields_by_model[model] || action.fields_by_model._ || {};
77
+ }
78
+ const RESERVED_DECLARED_FIELDS = new Set(["model"]);
79
+ // Union of every roster's fields for an action's advertised tool schema.
80
+ //
81
+ // Canonical fields share type/shape across models (ADR-0007); what diverges per
82
+ // model is the allowed value set and whether the field is required. So the
83
+ // advertised schema is the loosest envelope that accepts every model's valid
84
+ // input, and the per-model runtime check (validateParams against the resolved
85
+ // roster) does the precise enforcement:
86
+ // - required: only when required in every roster (the safe intersection);
87
+ // divergent-required fields stay optional here.
88
+ // - enum: the union of every roster's values, but only when every roster that
89
+ // defines the field constrains it — if any model leaves it free-form, the
90
+ // field is advertised unconstrained. Otherwise the declared schema could
91
+ // reject a value valid for one model before its runtime check runs.
92
+ // - other constraints (type/min/max): first-seen, since canonical fields do
93
+ // not diverge on those.
94
+ export function declaredFieldsForAction(action) {
95
+ const rosters = action.models.length > 0 ? action.models : ["_"];
96
+ const defsByName = new Map();
97
+ const order = [];
98
+ for (const roster of rosters) {
99
+ for (const [name, field] of Object.entries(fieldsForModel(action, roster))) {
100
+ if (RESERVED_DECLARED_FIELDS.has(name)) {
101
+ continue;
102
+ }
103
+ if (!defsByName.has(name)) {
104
+ defsByName.set(name, []);
105
+ order.push(name);
106
+ }
107
+ defsByName.get(name).push(field);
108
+ }
109
+ }
110
+ const merged = {};
111
+ for (const name of order) {
112
+ const defs = defsByName.get(name);
113
+ const field = { ...defs[0] };
114
+ if (defs.every((def) => def.enum?.length)) {
115
+ const seen = new Set();
116
+ field.enum = defs.flatMap((def) => def.enum).filter((value) => !seen.has(value) && seen.add(value));
117
+ }
118
+ else {
119
+ delete field.enum;
120
+ }
121
+ field.required = rosters.every((roster) => fieldsForModel(action, roster)[name]?.required === true);
122
+ merged[name] = field;
123
+ }
124
+ return merged;
67
125
  }
68
126
  export function fieldSummary(fields) {
69
127
  return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B,GAAG,EAAE,KAAK,CAAC,GAAG,IAAI,KAAK,CAAC,OAAO;QAC/B,GAAG,EAAE,KAAK,CAAC,GAAG,IAAI,KAAK,CAAC,OAAO;QAC/B,IAAI,EAAE,KAAK,CAAC,IAAI;KACjB,CAAC,CAAC,CAAC;AACN,CAAC"}
package/dist/pricing.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import type { ModelInfo, PricingConfig } from "./types.js";
1
+ import type { ModelInfo, PricingConfig, PricingEndpoint } from "./types.js";
2
2
  export declare function priceForModel(info: ModelInfo, source: PricingConfig): {
3
- pricing: Record<string, unknown> | undefined;
3
+ pricing: PricingEndpoint | undefined;
4
4
  pricing_source: string;
5
5
  pricing_url: string;
6
6
  };
package/dist/pricing.js CHANGED
@@ -1,44 +1,16 @@
1
+ // Packages embed final customer prices keyed by `${model}/${endpoint}`. This is
2
+ // a pure lookup — the markup math already ran when the price was embedded.
1
3
  export function priceForModel(info, source) {
2
- const key = pricingKey(info);
3
- const endpoint = source.endpoints?.[key];
4
+ // No-model endpoints are keyed under the "_" sentinel, matching the contract roster.
5
+ const endpoint = source.endpoints?.[`${info.model ?? "_"}/${info.action}`];
4
6
  const hasPrice = endpoint ? hasPriceData(endpoint) : false;
5
- const markup = effectiveMarkup(key, info.provider, source);
6
7
  return {
7
- pricing: endpoint && hasPrice ? presentPrice(endpoint, markup) : undefined,
8
+ pricing: hasPrice ? endpoint : undefined,
8
9
  pricing_source: hasPrice ? "build-time pricing snapshot" : "pricing page",
9
10
  pricing_url: "https://runapi.ai/pricing"
10
11
  };
11
12
  }
12
- function pricingKey(info) {
13
- return `${info.provider}/${info.model_line}/${info.model}/${info.action}`;
14
- }
15
- function effectiveMarkup(key, provider, source) {
16
- return source.endpoint_markup?.[key] ?? source.provider_markup?.[provider] ?? source.markup_rate ?? 1;
17
- }
18
13
  function hasPriceData(endpoint) {
19
14
  return Object.values(endpoint).some((value) => value !== undefined && value !== null);
20
15
  }
21
- function presentPrice(endpoint, markup) {
22
- const result = {};
23
- for (const [name, value] of Object.entries(endpoint)) {
24
- if (name === "cost_billing_config") {
25
- result.billing_config = presentBillingConfig(endpoint.cost_billing_config, markup);
26
- continue;
27
- }
28
- if (typeof value === "number") {
29
- const publicName = name.replace(/^cost_/, "");
30
- result[publicName] = Number.isInteger(value * markup) ? value * markup : Math.ceil(value * markup);
31
- }
32
- }
33
- return result;
34
- }
35
- function presentBillingConfig(config, markup) {
36
- if (!config) {
37
- return undefined;
38
- }
39
- return {
40
- key: config.key,
41
- overrides: Object.fromEntries(Object.entries(config.overrides || {}).map(([key, value]) => [key, value * markup]))
42
- };
43
- }
44
16
  //# sourceMappingURL=pricing.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"pricing.js","sourceRoot":"","sources":["../src/pricing.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,aAAa,CAAC,IAAe,EAAE,MAAqB;IAClE,MAAM,GAAG,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC;IAC7B,MAAM,QAAQ,GAAG,MAAM,CAAC,SAAS,EAAE,CAAC,GAAG,CAAC,CAAC;IACzC,MAAM,QAAQ,GAAG,QAAQ,CAAC,CAAC,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;IAC3D,MAAM,MAAM,GAAG,eAAe,CAAC,GAAG,EAAE,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IAE3D,OAAO;QACL,OAAO,EAAE,QAAQ,IAAI,QAAQ,CAAC,CAAC,CAAC,YAAY,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS;QAC1E,cAAc,EAAE,QAAQ,CAAC,CAAC,CAAC,6BAA6B,CAAC,CAAC,CAAC,cAAc;QACzE,WAAW,EAAE,2BAA2B;KACzC,CAAC;AACJ,CAAC;AAED,SAAS,UAAU,CAAC,IAAe;IACjC,OAAO,GAAG,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,UAAU,IAAI,IAAI,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ShapeForFields(fields) {
9
9
  }
10
10
  function zodForField(field) {
11
11
  let schema;
12
+ const min = field.min ?? field.minimum;
13
+ const max = field.max ?? field.maximum;
12
14
  if (field.enum?.length) {
13
15
  schema = z.union(field.enum.map((value) => literalFor(value)));
14
16
  }
15
- else if (field.type === "number" || field.type === "integer" || field.min !== undefined || field.max !== undefined || field.minimum !== undefined || field.maximum !== undefined) {
17
+ else if (field.type === "string" || field.length) {
18
+ let stringSchema = z.string();
19
+ if (min !== undefined) {
20
+ stringSchema = stringSchema.min(min);
21
+ }
22
+ if (max !== undefined) {
23
+ stringSchema = stringSchema.max(max);
24
+ }
25
+ schema = stringSchema;
26
+ }
27
+ else if (field.type === "number" || field.type === "integer" || min !== undefined || max !== undefined) {
16
28
  let numberSchema = z.number();
17
- const min = field.min ?? field.minimum;
18
- const max = field.max ?? field.maximum;
19
29
  if (min !== undefined) {
20
30
  numberSchema = numberSchema.min(min);
21
31
  }
@@ -1 +1 @@
1
- {"version":3,"file":"schema.js","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,MAAM,UAAU,cAAc,CAAC,MAAqC,EAAE,MAA+B;IACnG,OAAO,CAAC,CAAC,MAAM,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;AACzE,CAAC;AAED,+EAA+E;AAC/E,uFAAuF;AACvF,MAAM,UAAU,iBAAiB,CAAC,MAAqC;IACrE,OAAO,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;AACvG,CAAC;AAED,SAAS,WAAW,CAAC,KAAoB;IACvC,IAAI,MAA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,KAAK,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;IAChC,CAAC;SAAM,IAAI,KAAK,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;QACnC,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;IACjC,CAAC;SAAM,CAAC;QACN,MAAM,GAAG,CAAC,CAAC,OAAO,EAAE,CAAC;IACvB,CAAC;IAED,OAAO,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;AACrD,CAAC;AAED,SAAS,UAAU,CAAC,KAAc;IAChC,OAAO,CAAC,CAAC,OAAO,CAAC,KAAc,CAAC,CAAC;AACnC,CAAC"}
package/dist/server.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
- import type { Contract, ContractField, InputRule, PricingConfig } from "./types.js";
2
+ import type { Contract, InputRule, PricingConfig } from "./types.js";
3
3
  import { RunApiClient } from "./runapi-client.js";
4
4
  export type ModelServerTool = {
5
5
  name: string;
@@ -7,7 +7,6 @@ export type ModelServerTool = {
7
7
  service: string;
8
8
  action: string;
9
9
  models: string[];
10
- inputSchema: Record<string, ContractField>;
11
10
  };
12
11
  export type CreateModelServerOptions = {
13
12
  name: string;
package/dist/server.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { z } from "zod";
2
2
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
3
- import { findModelForAction } from "./contract.js";
3
+ import { declaredFieldsForAction, findAction, findModelForAction } from "./contract.js";
4
4
  import { priceForModel } from "./pricing.js";
5
5
  import { validateInputRules } from "./input-rules.js";
6
6
  import { validateParams, zodShapeForFields } from "./schema.js";
@@ -23,7 +23,9 @@ export function createModelServer(options) {
23
23
  }
24
24
  });
25
25
  for (const tool of tools) {
26
- server.tool(tool.name, tool.description, toolShape(tool), async (args, extra) => {
26
+ const action = findAction(tool.service, tool.action, contract);
27
+ const declaredFields = action ? declaredFieldsForAction(action) : {};
28
+ server.tool(tool.name, tool.description, toolShape(declaredFields, tool.models), async (args, extra) => {
27
29
  const { wait = true, timeout_ms, poll_interval_ms, model, ...params } = args;
28
30
  try {
29
31
  const info = findModelForAction(tool.service, tool.action, model, contract);
@@ -33,9 +35,15 @@ export function createModelServer(options) {
33
35
  hint: "This model server was generated for a specific model line; verify the requested model."
34
36
  });
35
37
  }
36
- const body = validateParams(tool.inputSchema, {
38
+ // Validate against the resolved model's own field roster so divergent
39
+ // per-model required fields are enforced correctly (the advertised tool
40
+ // schema declares the union with required relaxed to the intersection).
41
+ // Send the resolved model (explicit arg or the line's default) so
42
+ // model-optional create calls still satisfy endpoints that require it.
43
+ // No-model endpoints (models: []) resolve without a model — omit it.
44
+ const body = validateParams(info.fields, {
37
45
  ...params,
38
- ...(model ? { model } : {})
46
+ ...(info.model ? { model: info.model } : {})
39
47
  });
40
48
  const ruleError = validateInputRules(inputRules[tool.action] ?? [], body);
41
49
  if (ruleError) {
@@ -87,15 +95,15 @@ export function createModelServer(options) {
87
95
  }
88
96
  return server;
89
97
  }
90
- function toolShape(tool) {
98
+ function toolShape(fields, models) {
91
99
  const shape = {
92
- ...zodShapeForFields(tool.inputSchema),
100
+ ...zodShapeForFields(fields),
93
101
  wait: z.boolean().default(true).describe("Poll until the task reaches a terminal status."),
94
102
  timeout_ms: z.number().int().positive().optional(),
95
103
  poll_interval_ms: z.number().int().positive().optional()
96
104
  };
97
- if (tool.models.length > 0) {
98
- shape.model = z.enum(tool.models).optional().describe("RunAPI model slug for this model line.");
105
+ if (models.length > 0) {
106
+ shape.model = z.enum(models).optional().describe("RunAPI model slug for this model line.");
99
107
  }
100
108
  return shape;
101
109
  }
@@ -1 +1 @@
1
- {"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;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AO,CAAC;IACjB,CAAC;IACD,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC;QACzF,OAAO,OAAO,CAAC;IACjB,CAAC;IACD,IAAI,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;QAC7B,OAAO,OAAO,CAAC;IACjB,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAS,mBAAmB,CAAC,QAAgB;IAC3C,OAAO;QACL,6BAA6B,QAAQ,cAAc;QACnD,EAAE;QACF,8EAA8E;QAC9E,WAAW;QACX,4CAA4C;QAC5C,+DAA+D;QAC/D,qFAAqF;QACrF,4DAA4D;QAC5D,qGAAqG;KACtG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC"}
package/dist/types.d.ts CHANGED
@@ -6,47 +6,44 @@ export type ContractField = {
6
6
  max?: number;
7
7
  minimum?: number;
8
8
  maximum?: number;
9
+ length?: boolean;
9
10
  type?: string;
10
11
  description?: string;
11
12
  };
12
13
  export type ContractAction = {
13
- provider: string;
14
14
  model: string;
15
15
  endpoint: string;
16
16
  models: string[];
17
+ rules?: InputRule[];
17
18
  fields_by_model: Record<string, Record<string, ContractField>>;
18
19
  };
19
20
  export type Contract = {
20
- generated_by: string;
21
21
  catalog_models: string[];
22
22
  actions: Record<string, ContractAction>;
23
- unresolved_actions: string[];
24
23
  };
25
24
  export type PricingConfig = {
26
- markup_rate?: number;
27
- provider_markup?: Record<string, number>;
28
- endpoint_markup?: Record<string, number>;
29
25
  endpoints?: Record<string, PricingEndpoint>;
30
26
  };
31
27
  export type PricingEndpoint = {
32
- cost_unit_price_cents?: number;
33
- cost_input_price_per_1m_cents?: number;
34
- cost_output_price_per_1m_cents?: number;
35
- cost_cache_read_price_per_1m_cents?: number;
36
- cost_cache_write_5m_price_per_1m_cents?: number;
37
- cost_cache_write_1h_price_per_1m_cents?: number;
38
- cost_billing_config?: {
28
+ unit_price_cents?: number;
29
+ input_price_per_1m_cents?: number;
30
+ output_price_per_1m_cents?: number;
31
+ cache_read_price_per_1m_cents?: number;
32
+ cache_write_5m_price_per_1m_cents?: number;
33
+ cache_write_1h_price_per_1m_cents?: number;
34
+ billing_config?: {
39
35
  key?: string;
36
+ keys?: string[];
40
37
  overrides?: Record<string, number>;
38
+ matrix?: Record<string, unknown>;
41
39
  };
42
40
  };
43
41
  export type ModelInfo = {
44
42
  service: string;
45
43
  action: string;
46
44
  route_action: string;
47
- provider: string;
48
45
  model_line: string;
49
- model: string;
46
+ model?: string;
50
47
  fields: Record<string, ContractField>;
51
48
  };
52
49
  export type RunApiTaskResponse = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@runapi.ai/mcp-core",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Reusable core for building RunAPI MCP servers: client, contract/pricing/schema queries, input-rule engine, and a createModelServer factory.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",