@apicity/mcp-server 0.1.0-alpha.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 +21 -0
- package/README.md +124 -0
- package/dist/endpoint-docs.tsv +345 -0
- package/dist/src/bin.d.ts +3 -0
- package/dist/src/bin.d.ts.map +1 -0
- package/dist/src/bin.js +55 -0
- package/dist/src/bin.js.map +1 -0
- package/dist/src/index.d.ts +6 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +6 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/output.d.ts +14 -0
- package/dist/src/output.d.ts.map +1 -0
- package/dist/src/output.js +133 -0
- package/dist/src/output.js.map +1 -0
- package/dist/src/providers.d.ts +10 -0
- package/dist/src/providers.d.ts.map +1 -0
- package/dist/src/providers.js +98 -0
- package/dist/src/providers.js.map +1 -0
- package/dist/src/registry.d.ts +32 -0
- package/dist/src/registry.d.ts.map +1 -0
- package/dist/src/registry.js +170 -0
- package/dist/src/registry.js.map +1 -0
- package/dist/src/schema.d.ts +26 -0
- package/dist/src/schema.d.ts.map +1 -0
- package/dist/src/schema.js +151 -0
- package/dist/src/schema.js.map +1 -0
- package/dist/src/server.d.ts +8 -0
- package/dist/src/server.d.ts.map +1 -0
- package/dist/src/server.js +140 -0
- package/dist/src/server.js.map +1 -0
- package/package.json +124 -0
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { startServer, type StartServerOptions } from "./server.js";
|
|
2
|
+
export { buildRegistry, loadTsv, makeToolName, toSnakeCase, type Endpoint, type EndpointTsvRow, type BuildRegistryOptions, } from "./registry.js";
|
|
3
|
+
export { PROVIDERS, type ProviderSpec } from "./providers.js";
|
|
4
|
+
export { zodToJsonSchema, type JsonSchema } from "./schema.js";
|
|
5
|
+
export { writeBinary, downloadUrlsInResult, guessExtension, isBinary, } from "./output.js";
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,KAAK,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACnE,OAAO,EACL,aAAa,EACb,OAAO,EACP,YAAY,EACZ,WAAW,EACX,KAAK,QAAQ,EACb,KAAK,cAAc,EACnB,KAAK,oBAAoB,GAC1B,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,SAAS,EAAE,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,KAAK,UAAU,EAAE,MAAM,aAAa,CAAC;AAC/D,OAAO,EACL,WAAW,EACX,oBAAoB,EACpB,cAAc,EACd,QAAQ,GACT,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { startServer } from "./server.js";
|
|
2
|
+
export { buildRegistry, loadTsv, makeToolName, toSnakeCase, } from "./registry.js";
|
|
3
|
+
export { PROVIDERS } from "./providers.js";
|
|
4
|
+
export { zodToJsonSchema } from "./schema.js";
|
|
5
|
+
export { writeBinary, downloadUrlsInResult, guessExtension, isBinary, } from "./output.js";
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAA2B,MAAM,aAAa,CAAC;AACnE,OAAO,EACL,aAAa,EACb,OAAO,EACP,YAAY,EACZ,WAAW,GAIZ,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,SAAS,EAAqB,MAAM,gBAAgB,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAmB,MAAM,aAAa,CAAC;AAC/D,OAAO,EACL,WAAW,EACX,oBAAoB,EACpB,cAAc,EACd,QAAQ,GACT,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare function guessExtension(dotPath: string): string;
|
|
2
|
+
export declare function writeBinary(buf: ArrayBuffer | Uint8Array | Buffer, baseName: string, outDir: string): Promise<{
|
|
3
|
+
savedTo: string;
|
|
4
|
+
bytes: number;
|
|
5
|
+
}>;
|
|
6
|
+
export declare function isBinary(value: unknown): value is ArrayBuffer | Uint8Array;
|
|
7
|
+
/**
|
|
8
|
+
* Walk a JSON-shaped result, find URL strings under known keys, and download
|
|
9
|
+
* each into outDir. Returns a deep-cloned result with sibling `_savedTo` keys
|
|
10
|
+
* inserted next to the original URL fields. Best-effort — network failures
|
|
11
|
+
* leave the URL untouched and don't throw.
|
|
12
|
+
*/
|
|
13
|
+
export declare function downloadUrlsInResult(result: unknown, outDir: string, baseHint: string): Promise<unknown>;
|
|
14
|
+
//# sourceMappingURL=output.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"output.d.ts","sourceRoot":"","sources":["../../src/output.ts"],"names":[],"mappings":"AAuBA,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAGtD;AAED,wBAAsB,WAAW,CAC/B,GAAG,EAAE,WAAW,GAAG,UAAU,GAAG,MAAM,EACtC,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,CAQ7C;AAQD,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,WAAW,GAAG,UAAU,CAE1E;AAED;;;;;GAKG;AACH,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,OAAO,EACf,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,OAAO,CAAC,CAoBlB"}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { mkdir, writeFile } from "node:fs/promises";
|
|
2
|
+
import { join, resolve } from "node:path";
|
|
3
|
+
const URL_KEYS = new Set([
|
|
4
|
+
"url",
|
|
5
|
+
"downloadUrl",
|
|
6
|
+
"download_url",
|
|
7
|
+
"audio_url",
|
|
8
|
+
"audioUrl",
|
|
9
|
+
"video_url",
|
|
10
|
+
"videoUrl",
|
|
11
|
+
"image_url",
|
|
12
|
+
"imageUrl",
|
|
13
|
+
"fileUrl",
|
|
14
|
+
"file_url",
|
|
15
|
+
]);
|
|
16
|
+
const EXT_BY_HINT = [
|
|
17
|
+
[/(speech|tts|audio|voice|sound|stt|transcrib|translat)/i, "mp3"],
|
|
18
|
+
[/video/i, "mp4"],
|
|
19
|
+
[/image/i, "png"],
|
|
20
|
+
];
|
|
21
|
+
export function guessExtension(dotPath) {
|
|
22
|
+
for (const [re, ext] of EXT_BY_HINT)
|
|
23
|
+
if (re.test(dotPath))
|
|
24
|
+
return ext;
|
|
25
|
+
return "bin";
|
|
26
|
+
}
|
|
27
|
+
export async function writeBinary(buf, baseName, outDir) {
|
|
28
|
+
const absDir = resolve(outDir);
|
|
29
|
+
await mkdir(absDir, { recursive: true });
|
|
30
|
+
const safeName = baseName.replace(/[^A-Za-z0-9._-]/g, "_");
|
|
31
|
+
const file = join(absDir, safeName);
|
|
32
|
+
const bytes = toBuffer(buf);
|
|
33
|
+
await writeFile(file, bytes);
|
|
34
|
+
return { savedTo: file, bytes: bytes.byteLength };
|
|
35
|
+
}
|
|
36
|
+
function toBuffer(buf) {
|
|
37
|
+
if (Buffer.isBuffer(buf))
|
|
38
|
+
return buf;
|
|
39
|
+
if (buf instanceof Uint8Array)
|
|
40
|
+
return Buffer.from(buf);
|
|
41
|
+
return Buffer.from(new Uint8Array(buf));
|
|
42
|
+
}
|
|
43
|
+
export function isBinary(value) {
|
|
44
|
+
return value instanceof ArrayBuffer || value instanceof Uint8Array;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Walk a JSON-shaped result, find URL strings under known keys, and download
|
|
48
|
+
* each into outDir. Returns a deep-cloned result with sibling `_savedTo` keys
|
|
49
|
+
* inserted next to the original URL fields. Best-effort — network failures
|
|
50
|
+
* leave the URL untouched and don't throw.
|
|
51
|
+
*/
|
|
52
|
+
export async function downloadUrlsInResult(result, outDir, baseHint) {
|
|
53
|
+
const cloned = deepClone(result);
|
|
54
|
+
const downloads = [];
|
|
55
|
+
walk(cloned, (parent, key, value) => {
|
|
56
|
+
if (typeof value !== "string" || !URL_KEYS.has(key))
|
|
57
|
+
return;
|
|
58
|
+
if (!/^https?:\/\//.test(value))
|
|
59
|
+
return;
|
|
60
|
+
downloads.push(downloadOne(value, baseHint, outDir)
|
|
61
|
+
.then((path) => {
|
|
62
|
+
parent[`${key}_savedTo`] = path;
|
|
63
|
+
})
|
|
64
|
+
.catch((err) => {
|
|
65
|
+
parent[`${key}_savedTo`] = `error: ${err.message}`;
|
|
66
|
+
}));
|
|
67
|
+
});
|
|
68
|
+
await Promise.all(downloads);
|
|
69
|
+
return cloned;
|
|
70
|
+
}
|
|
71
|
+
async function downloadOne(url, baseHint, outDir) {
|
|
72
|
+
const res = await fetch(url);
|
|
73
|
+
if (!res.ok)
|
|
74
|
+
throw new Error(`HTTP ${res.status} fetching ${url}`);
|
|
75
|
+
const contentType = res.headers.get("content-type") ?? "";
|
|
76
|
+
const ext = extFromContentType(contentType) ?? extFromUrl(url) ?? "bin";
|
|
77
|
+
const ts = new Date().toISOString().replace(/[:.]/g, "-");
|
|
78
|
+
const baseName = `${baseHint}__${ts}.${ext}`;
|
|
79
|
+
const buf = Buffer.from(await res.arrayBuffer());
|
|
80
|
+
const out = await writeBinary(buf, baseName, outDir);
|
|
81
|
+
return out.savedTo;
|
|
82
|
+
}
|
|
83
|
+
function extFromContentType(ct) {
|
|
84
|
+
if (ct.startsWith("image/"))
|
|
85
|
+
return ct.split("/")[1].split(";")[0];
|
|
86
|
+
if (ct.startsWith("video/"))
|
|
87
|
+
return ct.split("/")[1].split(";")[0];
|
|
88
|
+
if (ct.startsWith("audio/"))
|
|
89
|
+
return ct.split("/")[1].split(";")[0];
|
|
90
|
+
if (ct.startsWith("application/pdf"))
|
|
91
|
+
return "pdf";
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
function extFromUrl(url) {
|
|
95
|
+
try {
|
|
96
|
+
const path = new URL(url).pathname;
|
|
97
|
+
const dot = path.lastIndexOf(".");
|
|
98
|
+
if (dot < 0)
|
|
99
|
+
return null;
|
|
100
|
+
const ext = path.slice(dot + 1).toLowerCase();
|
|
101
|
+
if (/^[a-z0-9]{2,5}$/.test(ext))
|
|
102
|
+
return ext;
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
105
|
+
catch {
|
|
106
|
+
return null;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
function deepClone(value) {
|
|
110
|
+
if (value === null || typeof value !== "object")
|
|
111
|
+
return value;
|
|
112
|
+
if (Array.isArray(value))
|
|
113
|
+
return value.map((v) => deepClone(v));
|
|
114
|
+
const out = {};
|
|
115
|
+
for (const [k, v] of Object.entries(value)) {
|
|
116
|
+
out[k] = deepClone(v);
|
|
117
|
+
}
|
|
118
|
+
return out;
|
|
119
|
+
}
|
|
120
|
+
function walk(node, visit) {
|
|
121
|
+
if (node === null || typeof node !== "object")
|
|
122
|
+
return;
|
|
123
|
+
if (Array.isArray(node)) {
|
|
124
|
+
for (const item of node)
|
|
125
|
+
walk(item, visit);
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
for (const [key, value] of Object.entries(node)) {
|
|
129
|
+
visit(node, key, value);
|
|
130
|
+
walk(value, visit);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
//# sourceMappingURL=output.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"output.js","sourceRoot":"","sources":["../../src/output.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAE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I,CACX,IAAa,EACb,KAA4D;IAE5D,IAAI,IAAI,KAAK,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ;QAAE,OAAO;IACtD,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;QACxB,KAAK,MAAM,IAAI,IAAI,IAAI;YAAE,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QAC3C,OAAO;IACT,CAAC;IACD,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAA+B,CAAC,EAAE,CAAC;QAC3E,KAAK,CAAC,IAAc,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;QAClC,IAAI,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IACrB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface ProviderSpec {
|
|
2
|
+
envVar: string;
|
|
3
|
+
optionKey: "apiKey" | "accessToken";
|
|
4
|
+
importPath: string;
|
|
5
|
+
factoryName: string;
|
|
6
|
+
}
|
|
7
|
+
export declare const PROVIDERS: Record<string, ProviderSpec>;
|
|
8
|
+
export type InstantiatedProvider = Record<string, unknown>;
|
|
9
|
+
export declare function instantiateProvider(name: string, spec: ProviderSpec): Promise<InstantiatedProvider | null>;
|
|
10
|
+
//# sourceMappingURL=providers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"providers.d.ts","sourceRoot":"","sources":["../../src/providers.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,QAAQ,GAAG,aAAa,CAAC;IACpC,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,eAAO,MAAM,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CA0ElD,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAE3D,wBAAsB,mBAAmB,CACvC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,YAAY,GACjB,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC,CAgBtC"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
// Map provider name (matches column 1 of scripts/endpoint-docs.tsv) to the
|
|
2
|
+
// metadata needed to instantiate it: which env var holds the credential, what
|
|
3
|
+
// option key the factory expects, and the dynamic-import specifier.
|
|
4
|
+
//
|
|
5
|
+
// Keeping factory imports dynamic means a missing provider package doesn't
|
|
6
|
+
// crash the server — that provider just gets skipped.
|
|
7
|
+
export const PROVIDERS = {
|
|
8
|
+
openai: {
|
|
9
|
+
envVar: "OPENAI_API_KEY",
|
|
10
|
+
optionKey: "apiKey",
|
|
11
|
+
importPath: "@apicity/openai",
|
|
12
|
+
factoryName: "openai",
|
|
13
|
+
},
|
|
14
|
+
xai: {
|
|
15
|
+
envVar: "XAI_API_KEY",
|
|
16
|
+
optionKey: "apiKey",
|
|
17
|
+
importPath: "@apicity/xai",
|
|
18
|
+
factoryName: "xai",
|
|
19
|
+
},
|
|
20
|
+
anthropic: {
|
|
21
|
+
envVar: "ANTHROPIC_API_KEY",
|
|
22
|
+
optionKey: "apiKey",
|
|
23
|
+
importPath: "@apicity/anthropic",
|
|
24
|
+
factoryName: "anthropic",
|
|
25
|
+
},
|
|
26
|
+
fireworks: {
|
|
27
|
+
envVar: "FIREWORKS_API_KEY",
|
|
28
|
+
optionKey: "apiKey",
|
|
29
|
+
importPath: "@apicity/fireworks",
|
|
30
|
+
factoryName: "fireworks",
|
|
31
|
+
},
|
|
32
|
+
fal: {
|
|
33
|
+
envVar: "FAL_API_KEY",
|
|
34
|
+
optionKey: "apiKey",
|
|
35
|
+
importPath: "@apicity/fal",
|
|
36
|
+
factoryName: "fal",
|
|
37
|
+
},
|
|
38
|
+
kie: {
|
|
39
|
+
envVar: "KIE_API_KEY",
|
|
40
|
+
optionKey: "apiKey",
|
|
41
|
+
importPath: "@apicity/kie",
|
|
42
|
+
factoryName: "kie",
|
|
43
|
+
},
|
|
44
|
+
kimicoding: {
|
|
45
|
+
envVar: "KIMI_CODING_API_KEY",
|
|
46
|
+
optionKey: "apiKey",
|
|
47
|
+
importPath: "@apicity/kimicoding",
|
|
48
|
+
factoryName: "kimicoding",
|
|
49
|
+
},
|
|
50
|
+
alibaba: {
|
|
51
|
+
envVar: "DASHSCOPE_API_KEY",
|
|
52
|
+
optionKey: "apiKey",
|
|
53
|
+
importPath: "@apicity/alibaba",
|
|
54
|
+
factoryName: "alibaba",
|
|
55
|
+
},
|
|
56
|
+
elevenlabs: {
|
|
57
|
+
envVar: "ELEVENLABS_API_KEY",
|
|
58
|
+
optionKey: "apiKey",
|
|
59
|
+
importPath: "@apicity/elevenlabs",
|
|
60
|
+
factoryName: "elevenlabs",
|
|
61
|
+
},
|
|
62
|
+
x: {
|
|
63
|
+
envVar: "X_ACCESS_TOKEN",
|
|
64
|
+
optionKey: "accessToken",
|
|
65
|
+
importPath: "@apicity/x",
|
|
66
|
+
factoryName: "x",
|
|
67
|
+
},
|
|
68
|
+
meta: {
|
|
69
|
+
envVar: "IG_ACCESS_TOKEN",
|
|
70
|
+
optionKey: "accessToken",
|
|
71
|
+
importPath: "@apicity/meta",
|
|
72
|
+
factoryName: "meta",
|
|
73
|
+
},
|
|
74
|
+
// free needs no credential — handled specially in registry.ts
|
|
75
|
+
"free-media-upload": {
|
|
76
|
+
envVar: "",
|
|
77
|
+
optionKey: "apiKey",
|
|
78
|
+
importPath: "@apicity/free-media-upload",
|
|
79
|
+
factoryName: "freeMediaUpload",
|
|
80
|
+
},
|
|
81
|
+
};
|
|
82
|
+
export async function instantiateProvider(name, spec) {
|
|
83
|
+
const mod = (await import(spec.importPath));
|
|
84
|
+
const factory = mod[spec.factoryName];
|
|
85
|
+
if (typeof factory !== "function") {
|
|
86
|
+
throw new Error(`Expected ${spec.importPath} to export function "${spec.factoryName}"`);
|
|
87
|
+
}
|
|
88
|
+
if (name === "free-media-upload") {
|
|
89
|
+
return factory();
|
|
90
|
+
}
|
|
91
|
+
const credential = process.env[spec.envVar];
|
|
92
|
+
if (!credential)
|
|
93
|
+
return null;
|
|
94
|
+
return factory({
|
|
95
|
+
[spec.optionKey]: credential,
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=providers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"providers.js","sourceRoot":"","sources":["../../src/providers.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,8EAA8E;AAC9E,oEAAoE;AACpE,EAAE;AACF,2EAA2E;AAC3E,sDAAsD;AAStD,MAAM,CAAC,MAAM,SAAS,GAAiC;IACrD,MAAM,EAAE;QACN,MAAM,EAAE,gBAAgB;QACxB,SAAS,EAAE,QAAQ;QACnB,UAAU,EAAE,iBAAiB;QAC7B,WAAW,EAAE,QAAQ;KACtB;IACD,GAAG,EAAE;QACH,MAAM,EAAE,aAAa;QACrB,SAAS,EAAE,QAAQ;QACnB,UAAU,EAAE,cAAc;QAC1B,WAAW,EAAE,KAAK;KACnB;IACD,SAAS,EAAE;QACT,MAAM,EAAE,mBAAmB;QAC3B,SAAS,EAAE,QAAQ;QACnB,UAAU,EAAE,oBAAoB;QAChC,WAAW,EAAE,WAAW;KACzB;IACD,SAAS,EAAE;QACT,MAAM,EAAE,mBAAmB;QAC3B,SAAS,EAAE,QAAQ;QACnB,UAAU,EAAE,oBAAoB;QAChC,WAAW,EAAE,WAAW;KACzB;IACD,GAAG,EAAE;QACH,MAAM,EAAE,aAAa;QACrB,SAAS,EAAE,QAAQ;QACnB,UAAU,EAAE,cAAc;QAC1B,WAAW,EAAE,KAAK;KACnB;IACD,GAAG,EAAE;QACH,MAAM,EAAE,aAAa;QACrB,SAAS,EAAE,QAAQ;QACnB,UAAU,EAAE,cAAc;QAC1B,WAAW,EAAE,KAAK;KACnB;IACD,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IACD,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC5C,IAAI,CAAC,UAAU;QAAE,OAAO,IAAI,CAAC;IAC7B,OAAQ,OAAmE,CAAC;QAC1E,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,UAAU;KAC7B,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export interface EndpointTsvRow {
|
|
2
|
+
provider: string;
|
|
3
|
+
dotPath: string;
|
|
4
|
+
method: string;
|
|
5
|
+
fullUrl: string;
|
|
6
|
+
docsUrl: string;
|
|
7
|
+
}
|
|
8
|
+
export interface EndpointExample {
|
|
9
|
+
source: string;
|
|
10
|
+
payload: unknown;
|
|
11
|
+
}
|
|
12
|
+
export interface EndpointFn {
|
|
13
|
+
(...args: unknown[]): Promise<unknown> | unknown;
|
|
14
|
+
schema?: unknown;
|
|
15
|
+
example?: EndpointExample;
|
|
16
|
+
}
|
|
17
|
+
export interface Endpoint extends EndpointTsvRow {
|
|
18
|
+
toolName: string;
|
|
19
|
+
fn: EndpointFn;
|
|
20
|
+
schema: unknown;
|
|
21
|
+
example?: EndpointExample;
|
|
22
|
+
pathParams: string[];
|
|
23
|
+
}
|
|
24
|
+
export declare function loadTsv(): Promise<EndpointTsvRow[]>;
|
|
25
|
+
export interface BuildRegistryOptions {
|
|
26
|
+
/** If set, only these provider names are loaded. Defaults to all with env vars. */
|
|
27
|
+
enabledProviders?: string[];
|
|
28
|
+
}
|
|
29
|
+
export declare function buildRegistry(opts?: BuildRegistryOptions): Promise<Endpoint[]>;
|
|
30
|
+
export declare function makeToolName(provider: string, method: string, dotPath: string): string;
|
|
31
|
+
export declare function toSnakeCase(segment: string): string;
|
|
32
|
+
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/registry.ts"],"names":[],"mappings":"AASA,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,UAAU;IACzB,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;IACjD,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,eAAe,CAAC;CAC3B;AAED,MAAM,WAAW,QAAS,SAAQ,cAAc;IAC9C,QAAQ,EAAE,MAAM,CAAC;IACjB,EAAE,EAAE,UAAU,CAAC;IACf,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,CAAC,EAAE,eAAe,CAAC;IAC1B,UAAU,EAAE,MAAM,EAAE,CAAC;CACtB;AAID,wBAAsB,OAAO,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC,CAoBzD;AAoBD,MAAM,WAAW,oBAAoB;IACnC,mFAAmF;IACnF,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;CAC7B;AAED,wBAAsB,aAAa,CACjC,IAAI,GAAE,oBAAyB,GAC9B,OAAO,CAAC,QAAQ,EAAE,CAAC,CAmCrB;AAyED,wBAAgB,YAAY,CAC1B,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,GACd,MAAM,CAGR;AASD,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAKnD"}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
2
|
+
import { fileURLToPath } from "node:url";
|
|
3
|
+
import { dirname, join } from "node:path";
|
|
4
|
+
import { PROVIDERS, instantiateProvider, } from "./providers.js";
|
|
5
|
+
const PATH_PARAM_RE = /\{(\w+)\}/g;
|
|
6
|
+
export async function loadTsv() {
|
|
7
|
+
// Resolution order: cwd's monorepo (handy in dev), bundled copy in dist/
|
|
8
|
+
// (the only source for installed users), monorepo source upstream of dist/.
|
|
9
|
+
// packageDistDir() resolves to dist/src/ at runtime; the bundled tsv lives
|
|
10
|
+
// one level up at dist/endpoint-docs.tsv.
|
|
11
|
+
const here = packageDistDir();
|
|
12
|
+
const tsv = await findAndRead([
|
|
13
|
+
join(process.cwd(), "scripts/endpoint-docs.tsv"),
|
|
14
|
+
join(here, "..", "endpoint-docs.tsv"),
|
|
15
|
+
join(here, "..", "..", "..", "..", "scripts/endpoint-docs.tsv"),
|
|
16
|
+
]);
|
|
17
|
+
const lines = tsv.split("\n").filter((l) => l.trim().length > 0);
|
|
18
|
+
const [header, ...rows] = lines;
|
|
19
|
+
const cols = header.split("\t");
|
|
20
|
+
return rows.map((line) => {
|
|
21
|
+
const fields = line.split("\t");
|
|
22
|
+
const obj = {};
|
|
23
|
+
for (let i = 0; i < cols.length; i++)
|
|
24
|
+
obj[cols[i]] = fields[i] ?? "";
|
|
25
|
+
return obj;
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
function packageDistDir() {
|
|
29
|
+
const here = dirname(fileURLToPath(import.meta.url));
|
|
30
|
+
return here;
|
|
31
|
+
}
|
|
32
|
+
async function findAndRead(candidates) {
|
|
33
|
+
for (const path of candidates) {
|
|
34
|
+
try {
|
|
35
|
+
return await readFile(path, "utf8");
|
|
36
|
+
}
|
|
37
|
+
catch {
|
|
38
|
+
/* try next */
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
throw new Error(`Could not locate endpoint-docs.tsv. Tried: ${candidates.join(", ")}`);
|
|
42
|
+
}
|
|
43
|
+
export async function buildRegistry(opts = {}) {
|
|
44
|
+
const rows = await loadTsv();
|
|
45
|
+
const wanted = new Set(opts.enabledProviders ?? Object.keys(PROVIDERS));
|
|
46
|
+
const instances = new Map();
|
|
47
|
+
for (const [name, spec] of Object.entries(PROVIDERS)) {
|
|
48
|
+
if (!wanted.has(name))
|
|
49
|
+
continue;
|
|
50
|
+
try {
|
|
51
|
+
const inst = await instantiateProvider(name, spec);
|
|
52
|
+
if (inst)
|
|
53
|
+
instances.set(name, inst);
|
|
54
|
+
}
|
|
55
|
+
catch (err) {
|
|
56
|
+
console.error(`[apicity-mcp] failed to load provider "${name}":`, err.message);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
const endpoints = [];
|
|
60
|
+
for (const row of rows) {
|
|
61
|
+
const inst = instances.get(row.provider);
|
|
62
|
+
if (!inst)
|
|
63
|
+
continue;
|
|
64
|
+
const resolved = resolveEndpointFn(inst, row.method, row.dotPath);
|
|
65
|
+
if (!resolved)
|
|
66
|
+
continue;
|
|
67
|
+
const pathParams = extractPathParams(row.fullUrl);
|
|
68
|
+
endpoints.push({
|
|
69
|
+
...row,
|
|
70
|
+
toolName: makeToolName(row.provider, row.method, row.dotPath),
|
|
71
|
+
fn: resolved,
|
|
72
|
+
schema: resolved.schema,
|
|
73
|
+
example: resolved.example,
|
|
74
|
+
pathParams,
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
return endpoints;
|
|
78
|
+
}
|
|
79
|
+
// Walk a dotPath through a provider tree. Each segment must land on either an
|
|
80
|
+
// object or a callable namespace (functions can carry sub-properties via
|
|
81
|
+
// `Object.assign`). Returns the function at the end of the path, or null.
|
|
82
|
+
function walkPath(root, segments) {
|
|
83
|
+
let cur = root;
|
|
84
|
+
for (const segment of segments) {
|
|
85
|
+
if (cur === null || cur === undefined)
|
|
86
|
+
return null;
|
|
87
|
+
const t = typeof cur;
|
|
88
|
+
if (t !== "object" && t !== "function")
|
|
89
|
+
return null;
|
|
90
|
+
cur = cur[segment];
|
|
91
|
+
}
|
|
92
|
+
return typeof cur === "function" ? cur : null;
|
|
93
|
+
}
|
|
94
|
+
// Providers don't all share the same shape: most expose a `post`/`get`/...
|
|
95
|
+
// namespace at the root, but `fal` nests POSTs under `.run.*` as well, `free`
|
|
96
|
+
// has no method namespace at all, and `kie` re-exports endpoints under
|
|
97
|
+
// per-sub-provider roots (`claude`, `veo`, `suno`, `chat`).
|
|
98
|
+
function resolveEndpointFn(provider, method, dotPath) {
|
|
99
|
+
const m = method.toLowerCase();
|
|
100
|
+
const segs = dotPath.split(".");
|
|
101
|
+
const root = provider;
|
|
102
|
+
const candidates = [
|
|
103
|
+
root[m], // standard: provider.post.<dotPath>
|
|
104
|
+
root[m]?.run, // fal: provider.post.run.<dotPath>
|
|
105
|
+
root, // free: provider.<dotPath>
|
|
106
|
+
];
|
|
107
|
+
// kie style A: first segment of dotPath is a sub-provider ("claude", "veo",
|
|
108
|
+
// ...) that has its own method namespace. Try provider.<sub>.<method>.<rest>.
|
|
109
|
+
if (segs.length > 1) {
|
|
110
|
+
const sub = root[segs[0]];
|
|
111
|
+
if (sub && typeof sub === "object") {
|
|
112
|
+
const subMethod = sub[m];
|
|
113
|
+
if (subMethod) {
|
|
114
|
+
const fn = walkPath(subMethod, segs.slice(1));
|
|
115
|
+
if (fn)
|
|
116
|
+
return fn;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
for (const c of candidates) {
|
|
121
|
+
const fn = walkPath(c, segs);
|
|
122
|
+
if (fn)
|
|
123
|
+
return fn;
|
|
124
|
+
}
|
|
125
|
+
// kie style B: sub-provider key is one of the URL path segments rather than
|
|
126
|
+
// the leading segment (e.g. dotPath `api.v1.veo.generate` lives at
|
|
127
|
+
// `provider.veo.post.api.v1.veo.generate`). Try every top-level non-method
|
|
128
|
+
// key as a candidate sub-provider root.
|
|
129
|
+
const HTTP_KEYS = new Set(["post", "get", "put", "delete", "patch", "head"]);
|
|
130
|
+
for (const key of Object.keys(root)) {
|
|
131
|
+
if (HTTP_KEYS.has(key))
|
|
132
|
+
continue;
|
|
133
|
+
if (!segs.includes(key))
|
|
134
|
+
continue;
|
|
135
|
+
const sub = root[key];
|
|
136
|
+
if (!sub || typeof sub !== "object")
|
|
137
|
+
continue;
|
|
138
|
+
const subMethod = sub[m];
|
|
139
|
+
if (!subMethod)
|
|
140
|
+
continue;
|
|
141
|
+
const fn = walkPath(subMethod, segs);
|
|
142
|
+
if (fn)
|
|
143
|
+
return fn;
|
|
144
|
+
}
|
|
145
|
+
return null;
|
|
146
|
+
}
|
|
147
|
+
function extractPathParams(url) {
|
|
148
|
+
const out = [];
|
|
149
|
+
for (const match of url.matchAll(PATH_PARAM_RE))
|
|
150
|
+
out.push(match[1]);
|
|
151
|
+
return out;
|
|
152
|
+
}
|
|
153
|
+
export function makeToolName(provider, method, dotPath) {
|
|
154
|
+
const segments = dotPath.split(".").map(toSnakeCase);
|
|
155
|
+
return `${provider}_${method.toLowerCase()}_${segments.join("_")}`;
|
|
156
|
+
}
|
|
157
|
+
// Inverse of `urlToDotPath`'s camelCase conversion (scripts/lib/url-to-dotpath.mjs):
|
|
158
|
+
// the dotPath stores `apiKeys`, `imageToVideo`, `compatibleMode`, etc., but tool
|
|
159
|
+
// names are flat snake_case for ergonomics in MCP clients.
|
|
160
|
+
// apiKeys → api_keys
|
|
161
|
+
// imageToVideo → image_to_video
|
|
162
|
+
// compatibleMode → compatible_mode
|
|
163
|
+
// getHTTPRequest → get_http_request (consecutive caps held together)
|
|
164
|
+
export function toSnakeCase(segment) {
|
|
165
|
+
return segment
|
|
166
|
+
.replace(/([A-Z]+)([A-Z][a-z])/g, "$1_$2")
|
|
167
|
+
.replace(/([a-z0-9])([A-Z])/g, "$1_$2")
|
|
168
|
+
.toLowerCase();
|
|
169
|
+
}
|
|
170
|
+
//# sourceMappingURL=registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,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AI,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;AACrE,CAAC;AAED,qFAAqF;AACrF,iFAAiF;AACjF,2DAA2D;AAC3D,iCAAiC;AACjC,uCAAuC;AACvC,wCAAwC;AACxC,6EAA6E;AAC7E,MAAM,UAAU,WAAW,CAAC,OAAe;IACzC,OAAO,OAAO;SACX,OAAO,CAAC,uBAAuB,EAAE,OAAO,CAAC;SACzC,OAAO,CAAC,oBAAoB,EAAE,OAAO,CAAC;SACtC,WAAW,EAAE,CAAC;AACnB,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export type JsonSchema = Record<string, unknown>;
|
|
2
|
+
interface ZodDef {
|
|
3
|
+
typeName?: string;
|
|
4
|
+
type?: ZodSchemaLike;
|
|
5
|
+
innerType?: ZodSchemaLike;
|
|
6
|
+
shape?: () => Record<string, ZodSchemaLike>;
|
|
7
|
+
values?: readonly string[] | Record<string, string | number>;
|
|
8
|
+
options?: readonly ZodSchemaLike[];
|
|
9
|
+
value?: unknown;
|
|
10
|
+
valueType?: ZodSchemaLike;
|
|
11
|
+
keyType?: ZodSchemaLike;
|
|
12
|
+
schema?: ZodSchemaLike;
|
|
13
|
+
description?: string;
|
|
14
|
+
checks?: ReadonlyArray<{
|
|
15
|
+
kind: string;
|
|
16
|
+
value?: number;
|
|
17
|
+
regex?: RegExp;
|
|
18
|
+
}>;
|
|
19
|
+
}
|
|
20
|
+
export interface ZodSchemaLike {
|
|
21
|
+
_def?: ZodDef;
|
|
22
|
+
description?: string;
|
|
23
|
+
}
|
|
24
|
+
export declare function zodToJsonSchema(schema: unknown): JsonSchema;
|
|
25
|
+
export {};
|
|
26
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/schema.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAEjD,UAAU,MAAM;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,aAAa,CAAC;IACrB,SAAS,CAAC,EAAE,aAAa,CAAC;IAC1B,KAAK,CAAC,EAAE,MAAM,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IAC5C,MAAM,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC;IAC7D,OAAO,CAAC,EAAE,SAAS,aAAa,EAAE,CAAC;IACnC,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,SAAS,CAAC,EAAE,aAAa,CAAC;IAC1B,OAAO,CAAC,EAAE,aAAa,CAAC;IACxB,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,aAAa,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAC1E;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAUD,wBAAgB,eAAe,CAAC,MAAM,EAAE,OAAO,GAAG,UAAU,CA6H3D"}
|