@runapi.ai/hailuo-mcp 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.
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.
package/README.md ADDED
@@ -0,0 +1,50 @@
1
+ # @runapi.ai/hailuo-mcp
2
+
3
+ RunAPI MCP server for the **Hailuo** model line. Create tasks,
4
+ poll their status, and check pricing through a single RunAPI API key.
5
+
6
+ ## Tools
7
+
8
+ - `image_to_video` — create a Hailuo task (image to video) and (optionally) poll until it reaches a terminal status. Returns the task id, status, output URLs, and a price snapshot. Models: `hailuo-02-image-to-video-pro`, `hailuo-02-image-to-video-standard`, `hailuo-2.3-image-to-video-pro`, `hailuo-2.3-image-to-video-standard`, `hailuo-02-text-to-video-pro`, `hailuo-02-text-to-video-standard`.
9
+ - `text_to_video` — create a Hailuo task (text to video) and (optionally) poll until it reaches a terminal status. Returns the task id, status, output URLs, and a price snapshot. Models: `hailuo-02-image-to-video-pro`, `hailuo-02-image-to-video-standard`, `hailuo-2.3-image-to-video-pro`, `hailuo-2.3-image-to-video-standard`, `hailuo-02-text-to-video-pro`, `hailuo-02-text-to-video-standard`.
10
+ - `get_task` — fetch the current status and latest payload for a task.
11
+ - `check_pricing` — look up pricing for a model in this line.
12
+
13
+ ## Configuration
14
+
15
+ Set a RunAPI API key via the `RUNAPI_API_KEY` environment variable, or write
16
+ it to `~/.config/runapi/config.json`:
17
+
18
+ ```bash
19
+ mkdir -p ~/.config/runapi
20
+ echo '{"api_key":"YOUR_KEY"}' > ~/.config/runapi/config.json
21
+ ```
22
+
23
+ Get an API key at https://runapi.ai. Pricing is listed at
24
+ https://runapi.ai/pricing.
25
+
26
+ ## Usage
27
+
28
+ Run the server over stdio:
29
+
30
+ ```bash
31
+ npx -y @runapi.ai/hailuo-mcp
32
+ ```
33
+
34
+ Add it to an MCP client (see `examples/` for per-client configs):
35
+
36
+ ```json
37
+ {
38
+ "mcpServers": {
39
+ "hailuo": {
40
+ "command": "npx",
41
+ "args": ["-y", "@runapi.ai/hailuo-mcp"],
42
+ "env": { "RUNAPI_API_KEY": "${RUNAPI_API_KEY}" }
43
+ }
44
+ }
45
+ }
46
+ ```
47
+
48
+ ## License
49
+
50
+ Apache-2.0
@@ -0,0 +1,101 @@
1
+ {
2
+ "catalog_models": [
3
+ "hailuo-02-image-to-video-pro",
4
+ "hailuo-02-image-to-video-standard",
5
+ "hailuo-2.3-image-to-video-pro",
6
+ "hailuo-2.3-image-to-video-standard",
7
+ "hailuo-02-text-to-video-pro",
8
+ "hailuo-02-text-to-video-standard"
9
+ ],
10
+ "actions": {
11
+ "hailuo/image-to-video": {
12
+ "model": "Hailuo",
13
+ "endpoint": "image_to_video",
14
+ "models": [
15
+ "hailuo-02-image-to-video-pro",
16
+ "hailuo-02-image-to-video-standard",
17
+ "hailuo-2.3-image-to-video-pro",
18
+ "hailuo-2.3-image-to-video-standard"
19
+ ],
20
+ "fields_by_model": {
21
+ "hailuo-02-image-to-video-pro": {
22
+ "last_frame_image_url": {},
23
+ "first_frame_image_url": {
24
+ "required": true
25
+ }
26
+ },
27
+ "hailuo-02-image-to-video-standard": {
28
+ "duration_seconds": {
29
+ "enum": [
30
+ 6,
31
+ 10
32
+ ]
33
+ },
34
+ "output_resolution": {
35
+ "enum": [
36
+ "512p",
37
+ "768p"
38
+ ]
39
+ },
40
+ "last_frame_image_url": {},
41
+ "first_frame_image_url": {
42
+ "required": true
43
+ }
44
+ },
45
+ "hailuo-2.3-image-to-video-pro": {
46
+ "duration_seconds": {
47
+ "enum": [
48
+ 6,
49
+ 10
50
+ ]
51
+ },
52
+ "output_resolution": {
53
+ "enum": [
54
+ "768p",
55
+ "1080p"
56
+ ]
57
+ },
58
+ "first_frame_image_url": {
59
+ "required": true
60
+ }
61
+ },
62
+ "hailuo-2.3-image-to-video-standard": {
63
+ "duration_seconds": {
64
+ "enum": [
65
+ 6,
66
+ 10
67
+ ]
68
+ },
69
+ "output_resolution": {
70
+ "enum": [
71
+ "768p",
72
+ "1080p"
73
+ ]
74
+ },
75
+ "first_frame_image_url": {
76
+ "required": true
77
+ }
78
+ }
79
+ }
80
+ },
81
+ "hailuo/text-to-video": {
82
+ "model": "Hailuo",
83
+ "endpoint": "text_to_video",
84
+ "models": [
85
+ "hailuo-02-text-to-video-pro",
86
+ "hailuo-02-text-to-video-standard"
87
+ ],
88
+ "fields_by_model": {
89
+ "hailuo-02-text-to-video-pro": {},
90
+ "hailuo-02-text-to-video-standard": {
91
+ "duration_seconds": {
92
+ "enum": [
93
+ 6,
94
+ 10
95
+ ]
96
+ }
97
+ }
98
+ }
99
+ }
100
+ }
101
+ }
@@ -0,0 +1,75 @@
1
+ {
2
+ "endpoints": {
3
+ "hailuo-02-image-to-video-pro/image_to_video": {
4
+ "unit_price_cents": 57
5
+ },
6
+ "hailuo-02-image-to-video-standard/image_to_video": {
7
+ "unit_price_cents": 30,
8
+ "billing_config": {
9
+ "keys": [
10
+ "duration_seconds",
11
+ "output_resolution"
12
+ ],
13
+ "matrix": {
14
+ "6": {
15
+ "512p": 12,
16
+ "768p": 30
17
+ },
18
+ "10": {
19
+ "512p": 20,
20
+ "768p": 50
21
+ }
22
+ }
23
+ }
24
+ },
25
+ "hailuo-2.3-image-to-video-pro/image_to_video": {
26
+ "unit_price_cents": 90,
27
+ "billing_config": {
28
+ "keys": [
29
+ "duration_seconds",
30
+ "output_resolution"
31
+ ],
32
+ "matrix": {
33
+ "6": {
34
+ "768p": 45,
35
+ "1080p": 80
36
+ },
37
+ "10": {
38
+ "768p": 90
39
+ }
40
+ }
41
+ }
42
+ },
43
+ "hailuo-2.3-image-to-video-standard/image_to_video": {
44
+ "unit_price_cents": 50,
45
+ "billing_config": {
46
+ "keys": [
47
+ "duration_seconds",
48
+ "output_resolution"
49
+ ],
50
+ "matrix": {
51
+ "6": {
52
+ "768p": 30,
53
+ "1080p": 50
54
+ },
55
+ "10": {
56
+ "768p": 50
57
+ }
58
+ }
59
+ }
60
+ },
61
+ "hailuo-02-text-to-video-pro/text_to_video": {
62
+ "unit_price_cents": 57
63
+ },
64
+ "hailuo-02-text-to-video-standard/text_to_video": {
65
+ "unit_price_cents": 50,
66
+ "billing_config": {
67
+ "key": "duration_seconds",
68
+ "overrides": {
69
+ "6": 30,
70
+ "10": 50
71
+ }
72
+ }
73
+ }
74
+ }
75
+ }
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import "../src/index.js";
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ import "../src/index.js";
3
+ //# sourceMappingURL=hailuo-mcp.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hailuo-mcp.js","sourceRoot":"","sources":["../../bin/hailuo-mcp.ts"],"names":[],"mappings":";AACA,OAAO,iBAAiB,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { Contract, PricingConfig } from "@runapi.ai/mcp-core";
2
+ export declare function readContract(): Contract;
3
+ export declare function readPricing(): PricingConfig;
@@ -0,0 +1,22 @@
1
+ import { existsSync, readFileSync } from "node:fs";
2
+ import { fileURLToPath } from "node:url";
3
+ import path from "node:path";
4
+ function dataRoot() {
5
+ const current = path.dirname(fileURLToPath(import.meta.url));
6
+ const candidates = [
7
+ path.resolve(current, "..", "..", "data"),
8
+ path.resolve(current, "..", "data")
9
+ ];
10
+ const root = candidates.find((candidate) => existsSync(path.join(candidate, "contract.json")));
11
+ if (!root) {
12
+ throw new Error("Unable to locate the embedded RunAPI data directory.");
13
+ }
14
+ return root;
15
+ }
16
+ export function readContract() {
17
+ return JSON.parse(readFileSync(path.join(dataRoot(), "contract.json"), "utf8"));
18
+ }
19
+ export function readPricing() {
20
+ return JSON.parse(readFileSync(path.join(dataRoot(), "pricing.json"), "utf8"));
21
+ }
22
+ //# sourceMappingURL=data.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"data.js","sourceRoot":"","sources":["../../src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/server/stdio.js";
3
+ import { createServer } from "./server.js";
4
+ const server = createServer();
5
+ await server.connect(new StdioServerTransport());
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,MAAM,MAAM,GAAG,YAAY,EAAE,CAAC;AAC9B,MAAM,MAAM,CAAC,OAAO,CAAC,IAAI,oBAAoB,EAAE,CAAC,CAAC"}
@@ -0,0 +1,5 @@
1
+ export declare const META: {
2
+ readonly name: "@runapi.ai/hailuo-mcp";
3
+ readonly version: "0.1.0";
4
+ readonly lineSlug: "hailuo";
5
+ };
@@ -0,0 +1,6 @@
1
+ export const META = {
2
+ name: "@runapi.ai/hailuo-mcp",
3
+ version: "0.1.0",
4
+ lineSlug: "hailuo"
5
+ };
6
+ //# sourceMappingURL=meta.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"meta.js","sourceRoot":"","sources":["../../src/meta.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,IAAI,GAAG;IAClB,IAAI,EAAE,uBAAuB;IAC7B,OAAO,EAAE,OAAO;IAChB,QAAQ,EAAE,QAAQ;CACV,CAAC"}
@@ -0,0 +1,2 @@
1
+ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ export declare function createServer(): McpServer;
@@ -0,0 +1,123 @@
1
+ import { z } from "zod";
2
+ import { createModelServer, findModelForAction, findModels, friendlyError, jsonText, priceForModel, RunApiClient, taskStatus } from "@runapi.ai/mcp-core";
3
+ import { readContract, readPricing } from "./data.js";
4
+ import { META } from "./meta.js";
5
+ function lineService(contract) {
6
+ return Object.keys(contract.actions)[0]?.split("/")[0] ?? META.lineSlug;
7
+ }
8
+ function lineEndpoints(contract) {
9
+ const seen = new Set();
10
+ for (const action of Object.values(contract.actions)) {
11
+ seen.add(action.endpoint);
12
+ }
13
+ return [...seen];
14
+ }
15
+ function lineModels(contract) {
16
+ const seen = new Set();
17
+ for (const action of Object.values(contract.actions)) {
18
+ for (const model of action.models) {
19
+ seen.add(model);
20
+ }
21
+ }
22
+ return [...seen];
23
+ }
24
+ function rulesForAction(action) {
25
+ return action.rules ?? [];
26
+ }
27
+ function buildTools(contract) {
28
+ const tools = [];
29
+ const inputRules = {};
30
+ for (const [key, action] of Object.entries(contract.actions)) {
31
+ const service = key.split("/")[0];
32
+ const endpoint = action.endpoint;
33
+ tools.push({
34
+ name: endpoint,
35
+ description: `Create a ${action.model} task on RunAPI (${endpoint.replace(/_/g, " ")}). Returns a task id, status, and output URLs.`,
36
+ service,
37
+ action: endpoint,
38
+ models: action.models
39
+ });
40
+ inputRules[endpoint] = rulesForAction(action);
41
+ }
42
+ return { tools, inputRules };
43
+ }
44
+ function registerLineTools(server, contract, pricing, client) {
45
+ const service = lineService(contract);
46
+ const endpoints = lineEndpoints(contract);
47
+ const models = lineModels(contract);
48
+ const endpointEnum = endpoints.length > 0 ? z.enum(endpoints) : z.string();
49
+ const modelEnum = models.length > 0 ? z.enum(models) : z.string();
50
+ // With one endpoint, action defaults safely. With several, a wrong default
51
+ // would query the wrong task route, so the caller must name the endpoint.
52
+ const getTaskAction = endpoints.length > 1
53
+ ? endpointEnum.describe("Endpoint the task was created on.")
54
+ : endpointEnum.optional().describe("Endpoint the task was created on. Defaults to the line's only endpoint.");
55
+ server.tool("get_task", `Fetch the current status and latest result payload for a ${META.lineSlug} task.`, {
56
+ task_id: z.string().describe("Task id returned when the task was created."),
57
+ action: getTaskAction
58
+ }, async ({ task_id, action }) => {
59
+ try {
60
+ const task = await client.getTask(service, task_id, action ?? endpoints[0]);
61
+ return jsonText({ task_id, status: taskStatus(task), task });
62
+ }
63
+ catch (error) {
64
+ return jsonText({ error: friendlyError(error) });
65
+ }
66
+ });
67
+ server.tool("check_pricing", `Look up RunAPI pricing for the ${META.lineSlug} model line.`, {
68
+ model: modelEnum.optional().describe("Model slug. Defaults to the line's primary model."),
69
+ action: endpointEnum.optional().describe("Endpoint name. Defaults to the endpoint that offers the model.")
70
+ }, async ({ model, action }) => {
71
+ const noMatch = { supported: false, message: "No matching model/endpoint in this model line." };
72
+ // Explicit endpoint: price exactly that model on that endpoint.
73
+ if (action) {
74
+ const info = findModelForAction(service, action, model, contract);
75
+ return info
76
+ ? jsonText({ supported: true, model: info.model, service: info.service, action: info.action, price: priceForModel(info, pricing) })
77
+ : jsonText(noMatch);
78
+ }
79
+ // No endpoint and no model: price the line's primary model/endpoint.
80
+ if (!model) {
81
+ const info = findModelForAction(service, endpoints[0], undefined, contract);
82
+ return info
83
+ ? jsonText({ supported: true, model: info.model, service: info.service, action: info.action, price: priceForModel(info, pricing) })
84
+ : jsonText(noMatch);
85
+ }
86
+ // No endpoint named: a model may be offered on several endpoints at
87
+ // different prices, so report every endpoint that offers it rather than
88
+ // silently pricing only the first one found.
89
+ const matches = findModels(model, contract);
90
+ if (matches.length === 0) {
91
+ return jsonText(noMatch);
92
+ }
93
+ if (matches.length === 1) {
94
+ const info = matches[0];
95
+ return jsonText({ supported: true, model: info.model, service: info.service, action: info.action, price: priceForModel(info, pricing) });
96
+ }
97
+ return jsonText({
98
+ supported: true,
99
+ model: matches[0].model,
100
+ service: matches[0].service,
101
+ endpoints: matches.map((info) => ({ action: info.action, price: priceForModel(info, pricing) }))
102
+ });
103
+ });
104
+ }
105
+ export function createServer() {
106
+ const contract = readContract();
107
+ const pricing = readPricing();
108
+ const { tools, inputRules } = buildTools(contract);
109
+ const client = new RunApiClient();
110
+ const server = createModelServer({
111
+ name: META.name,
112
+ version: META.version,
113
+ lineSlug: META.lineSlug,
114
+ contract,
115
+ pricing,
116
+ inputRules,
117
+ tools,
118
+ client
119
+ });
120
+ registerLineTools(server, contract, pricing, client);
121
+ return server;
122
+ }
123
+ //# sourceMappingURL=server.js.map
@@ -0,0 +1 @@
1
+ {"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QAAQ;QACR,OAAO;QACP,UAAU;QACV,KAAK;QACL,MAAM;KACP,CAAC,CAAC;IAEH,iBAAiB,CAAC,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;IACrD,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,14 @@
1
+ {
2
+ "mcpServers": {
3
+ "hailuo": {
4
+ "command": "npx",
5
+ "args": [
6
+ "-y",
7
+ "@runapi.ai/hailuo-mcp"
8
+ ],
9
+ "env": {
10
+ "RUNAPI_API_KEY": "${RUNAPI_API_KEY}"
11
+ }
12
+ }
13
+ }
14
+ }
@@ -0,0 +1,14 @@
1
+ {
2
+ "mcpServers": {
3
+ "hailuo": {
4
+ "command": "npx",
5
+ "args": [
6
+ "-y",
7
+ "@runapi.ai/hailuo-mcp"
8
+ ],
9
+ "env": {
10
+ "RUNAPI_API_KEY": "${RUNAPI_API_KEY}"
11
+ }
12
+ }
13
+ }
14
+ }
@@ -0,0 +1,14 @@
1
+ {
2
+ "mcpServers": {
3
+ "hailuo": {
4
+ "command": "npx",
5
+ "args": [
6
+ "-y",
7
+ "@runapi.ai/hailuo-mcp"
8
+ ],
9
+ "env": {
10
+ "RUNAPI_API_KEY": "${RUNAPI_API_KEY}"
11
+ }
12
+ }
13
+ }
14
+ }
@@ -0,0 +1,15 @@
1
+ {
2
+ "servers": {
3
+ "hailuo": {
4
+ "type": "stdio",
5
+ "command": "npx",
6
+ "args": [
7
+ "-y",
8
+ "@runapi.ai/hailuo-mcp"
9
+ ],
10
+ "env": {
11
+ "RUNAPI_API_KEY": "${RUNAPI_API_KEY}"
12
+ }
13
+ }
14
+ }
15
+ }
@@ -0,0 +1,14 @@
1
+ {
2
+ "mcpServers": {
3
+ "hailuo": {
4
+ "command": "npx",
5
+ "args": [
6
+ "-y",
7
+ "@runapi.ai/hailuo-mcp"
8
+ ],
9
+ "env": {
10
+ "RUNAPI_API_KEY": "${RUNAPI_API_KEY}"
11
+ }
12
+ }
13
+ }
14
+ }
package/package.json ADDED
@@ -0,0 +1,60 @@
1
+ {
2
+ "name": "@runapi.ai/hailuo-mcp",
3
+ "version": "0.1.0",
4
+ "description": "RunAPI MCP server for one model line: create tasks, poll status, and check pricing with one API key.",
5
+ "type": "module",
6
+ "main": "dist/src/index.js",
7
+ "bin": {
8
+ "hailuo-mcp": "dist/bin/hailuo-mcp.js"
9
+ },
10
+ "files": [
11
+ "dist",
12
+ "data/contract.json",
13
+ "data/pricing.json",
14
+ "examples",
15
+ "server.json",
16
+ "README.md",
17
+ "LICENSE"
18
+ ],
19
+ "scripts": {
20
+ "build": "tsc -p tsconfig.json",
21
+ "dev": "tsx src/index.ts",
22
+ "prepack": "npm run build",
23
+ "typecheck": "tsc --noEmit",
24
+ "test": "vitest run"
25
+ },
26
+ "keywords": [
27
+ "runapi",
28
+ "mcp",
29
+ "model-context-protocol",
30
+ "ai"
31
+ ],
32
+ "author": "RunAPI",
33
+ "license": "Apache-2.0",
34
+ "homepage": "https://runapi.ai",
35
+ "repository": {
36
+ "type": "git",
37
+ "url": "git+https://github.com/runapi-ai/hailuo-mcp.git"
38
+ },
39
+ "bugs": {
40
+ "url": "https://github.com/runapi-ai/hailuo-mcp/issues"
41
+ },
42
+ "engines": {
43
+ "node": ">=22.0.0"
44
+ },
45
+ "dependencies": {
46
+ "@modelcontextprotocol/sdk": "^1.29.0",
47
+ "@runapi.ai/mcp-core": "0.1.2",
48
+ "zod": "^3.25.76"
49
+ },
50
+ "devDependencies": {
51
+ "@types/node": "^24.10.1",
52
+ "tsx": "^4.20.6",
53
+ "typescript": "^5.9.3",
54
+ "vitest": "^4.0.14"
55
+ },
56
+ "publishConfig": {
57
+ "access": "public"
58
+ },
59
+ "mcpName": "io.github.runapi-builder/hailuo-mcp"
60
+ }
package/server.json ADDED
@@ -0,0 +1,29 @@
1
+ {
2
+ "$schema": "https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json",
3
+ "name": "io.github.runapi-builder/hailuo-mcp",
4
+ "description": "RunAPI MCP server for Hailuo: create tasks, poll status, and check pricing.",
5
+ "repository": {
6
+ "url": "https://github.com/runapi-ai/hailuo-mcp",
7
+ "source": "github"
8
+ },
9
+ "version": "0.1.0",
10
+ "packages": [
11
+ {
12
+ "registryType": "npm",
13
+ "identifier": "@runapi.ai/hailuo-mcp",
14
+ "version": "0.1.0",
15
+ "transport": {
16
+ "type": "stdio"
17
+ },
18
+ "environmentVariables": [
19
+ {
20
+ "description": "RunAPI API key. Get one at https://runapi.ai",
21
+ "isRequired": true,
22
+ "format": "string",
23
+ "isSecret": true,
24
+ "name": "RUNAPI_API_KEY"
25
+ }
26
+ ]
27
+ }
28
+ ]
29
+ }