@anyproto/anytype-mcp 1.0.2 → 1.0.3
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/.github/workflows/ci.yml +64 -0
- package/.github/workflows/release.yml +40 -0
- package/.prettierrc +5 -0
- package/bin/cli.mjs +53 -87
- package/cli/__tests__/openapi-client.test.ts +119 -0
- package/cli/openapi-client.ts +91 -0
- package/eslint.config.js +49 -0
- package/package.json +12 -26
- package/scripts/__tests__/parse-openapi.test.ts +189 -0
- package/scripts/__tests__/start-server.test.ts +205 -0
- package/scripts/build-cli.js +30 -0
- package/scripts/build.ts +24 -0
- package/scripts/openapi.json +5888 -0
- package/scripts/parse-openapi.ts +30 -0
- package/scripts/start-server.ts +31 -0
- package/scripts/tools.json +5657 -0
- package/src/init-server.ts +51 -0
- package/test_cases/ebay-api.json +2555 -0
- package/test_cases/ebay-api.json.tools +3710 -0
- package/tsconfig.json +26 -0
- package/vitest.config.ts +19 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { readFileSync, writeFileSync } from "fs";
|
|
4
|
+
import { OpenAPIV3 } from "openapi-types";
|
|
5
|
+
import { OpenAPIToMCPConverter } from "../src/openapi/parser";
|
|
6
|
+
|
|
7
|
+
function main() {
|
|
8
|
+
const args = process.argv.slice(2);
|
|
9
|
+
const inputFile = args[0] || "./scripts/openapi.json";
|
|
10
|
+
const outputFile = args[1] || "./scripts/tools.json";
|
|
11
|
+
|
|
12
|
+
try {
|
|
13
|
+
// Read and parse the OpenAPI spec
|
|
14
|
+
const specContent = readFileSync(inputFile, "utf-8");
|
|
15
|
+
const spec = JSON.parse(specContent) as OpenAPIV3.Document;
|
|
16
|
+
|
|
17
|
+
// Convert to MCP Tools
|
|
18
|
+
const converter = new OpenAPIToMCPConverter(spec);
|
|
19
|
+
const { tools } = converter.convertToMCPTools();
|
|
20
|
+
|
|
21
|
+
// Write the output
|
|
22
|
+
writeFileSync(outputFile, JSON.stringify({ tools }, null, 2));
|
|
23
|
+
console.log(`Successfully wrote parsed tools to ${outputFile}`);
|
|
24
|
+
} catch (error) {
|
|
25
|
+
console.error("Error:", error instanceof Error ? error.message : String(error));
|
|
26
|
+
process.exit(1);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
main();
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { AppKeyGenerator } from "../src/auth/get-key";
|
|
2
|
+
import { initProxy, loadOpenApiSpec, ValidationError } from "../src/init-server";
|
|
3
|
+
|
|
4
|
+
async function generateAppKey(specPath?: string) {
|
|
5
|
+
const openApiSpec = await loadOpenApiSpec(specPath);
|
|
6
|
+
const baseUrl = openApiSpec.servers?.[0]?.url || "http://localhost:31009";
|
|
7
|
+
const generator = new AppKeyGenerator(baseUrl);
|
|
8
|
+
await generator.generateAppKey();
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export async function main(args: string[] = process.argv.slice(2)) {
|
|
12
|
+
const [command, specPath] = args;
|
|
13
|
+
if (!command || command === "run") {
|
|
14
|
+
await initProxy(specPath);
|
|
15
|
+
} else if (command === "get-key") {
|
|
16
|
+
await generateAppKey(specPath);
|
|
17
|
+
} else {
|
|
18
|
+
console.error(`Error: Unknown command "${command}"`);
|
|
19
|
+
process.exit(1);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
main().catch((error) => {
|
|
24
|
+
if (error instanceof ValidationError) {
|
|
25
|
+
console.error("Invalid OpenAPI 3.1 specification:");
|
|
26
|
+
error.errors.forEach((err) => console.error(err));
|
|
27
|
+
} else {
|
|
28
|
+
console.error("Error:", error.message);
|
|
29
|
+
}
|
|
30
|
+
process.exit(1);
|
|
31
|
+
});
|