@anyproto/anytype-mcp 1.2.3 → 1.2.4
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/bin/cli.mjs +48 -48
- package/package.json +9 -9
- package/scripts/start-server.ts +5 -5
- package/src/auth/get-key.ts +10 -10
package/package.json
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
"mcp",
|
|
8
8
|
"server"
|
|
9
9
|
],
|
|
10
|
-
"version": "1.2.
|
|
10
|
+
"version": "1.2.4",
|
|
11
11
|
"license": "MIT",
|
|
12
12
|
"type": "module",
|
|
13
13
|
"scripts": {
|
|
@@ -25,29 +25,29 @@
|
|
|
25
25
|
"anytype-mcp": "bin/cli.mjs"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@modelcontextprotocol/sdk": "1.
|
|
29
|
-
"axios": "1.13.
|
|
28
|
+
"@modelcontextprotocol/sdk": "1.27.1",
|
|
29
|
+
"axios": "1.13.6",
|
|
30
30
|
"form-data": "4.0.5",
|
|
31
31
|
"mustache": "4.2.0",
|
|
32
32
|
"node-fetch": "3.3.2",
|
|
33
|
-
"openapi-client-axios": "7.
|
|
33
|
+
"openapi-client-axios": "7.9.0",
|
|
34
34
|
"openapi-schema-validator": "12.1.3",
|
|
35
35
|
"openapi-types": "12.1.3",
|
|
36
36
|
"zod": "4.3.6"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@anthropic-ai/sdk": "0.
|
|
39
|
+
"@anthropic-ai/sdk": "0.78.0",
|
|
40
40
|
"@eslint/js": "9.39.2",
|
|
41
41
|
"@types/json-schema": "7.0.15",
|
|
42
42
|
"@types/mustache": "4.2.6",
|
|
43
|
-
"@types/node": "25.
|
|
43
|
+
"@types/node": "25.3.3",
|
|
44
44
|
"@types/which": "3.0.4",
|
|
45
45
|
"@vitest/coverage-v8": "4.0.18",
|
|
46
|
-
"@typescript-eslint/eslint-plugin": "8.56.
|
|
47
|
-
"@typescript-eslint/parser": "8.56.
|
|
46
|
+
"@typescript-eslint/eslint-plugin": "8.56.1",
|
|
47
|
+
"@typescript-eslint/parser": "8.56.1",
|
|
48
48
|
"eslint": "9.39.2",
|
|
49
49
|
"esbuild": "0.27.3",
|
|
50
|
-
"openai": "6.
|
|
50
|
+
"openai": "6.25.0",
|
|
51
51
|
"prettier": "3.8.1",
|
|
52
52
|
"prettier-plugin-organize-imports": "4.3.0",
|
|
53
53
|
"tsx": "4.21.0",
|
package/scripts/start-server.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ApiKeyGenerator } from "../src/auth/get-key";
|
|
2
2
|
import { initProxy, loadOpenApiSpec, ValidationError } from "../src/init-server";
|
|
3
3
|
import { determineBaseUrl } from "../src/utils/base-url";
|
|
4
4
|
|
|
5
|
-
async function
|
|
5
|
+
async function generateApiKey(specPath?: string) {
|
|
6
6
|
const openApiSpec = await loadOpenApiSpec(specPath);
|
|
7
7
|
const baseUrl = determineBaseUrl(openApiSpec);
|
|
8
|
-
const generator = new
|
|
9
|
-
await generator.
|
|
8
|
+
const generator = new ApiKeyGenerator(baseUrl);
|
|
9
|
+
await generator.generateApiKey();
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
export async function main(args: string[] = process.argv.slice(2)) {
|
|
@@ -14,7 +14,7 @@ export async function main(args: string[] = process.argv.slice(2)) {
|
|
|
14
14
|
if (!command || command === "run") {
|
|
15
15
|
await initProxy(specPath);
|
|
16
16
|
} else if (command === "get-key") {
|
|
17
|
-
await
|
|
17
|
+
await generateApiKey(specPath);
|
|
18
18
|
} else {
|
|
19
19
|
console.error(`Error: Unknown command "${command}"`);
|
|
20
20
|
process.exit(1);
|
package/src/auth/get-key.ts
CHANGED
|
@@ -5,7 +5,7 @@ interface AuthToken {
|
|
|
5
5
|
api_key: string;
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
-
export class
|
|
8
|
+
export class ApiKeyGenerator {
|
|
9
9
|
private readonly rl: readline.Interface;
|
|
10
10
|
private readonly appName: string = "anytype_mcp_server";
|
|
11
11
|
private readonly basePath: string;
|
|
@@ -24,8 +24,8 @@ export class AppKeyGenerator {
|
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
private displaySuccessMessage(
|
|
28
|
-
console.log(`\nYour
|
|
27
|
+
private displaySuccessMessage(apiKey: string, anytypeVersion: string): void {
|
|
28
|
+
console.log(`\nYour API KEY: ${apiKey}`);
|
|
29
29
|
console.log("\nAdd this to your MCP settings file as:");
|
|
30
30
|
console.log(`
|
|
31
31
|
{
|
|
@@ -37,7 +37,7 @@ export class AppKeyGenerator {
|
|
|
37
37
|
"@anyproto/anytype-mcp",
|
|
38
38
|
],
|
|
39
39
|
"env": {
|
|
40
|
-
"OPENAPI_MCP_HEADERS": "{\\"Authorization\\":\\"Bearer ${
|
|
40
|
+
"OPENAPI_MCP_HEADERS": "{\\"Authorization\\":\\"Bearer ${apiKey}\\", \\"Anytype-Version\\":\\"${anytypeVersion}\\"}"
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
}
|
|
@@ -73,7 +73,7 @@ export class AppKeyGenerator {
|
|
|
73
73
|
private async completeAuthentication(
|
|
74
74
|
challengeId: string,
|
|
75
75
|
code: string,
|
|
76
|
-
): Promise<{
|
|
76
|
+
): Promise<{ apiKey: string; anytypeVersion: string }> {
|
|
77
77
|
try {
|
|
78
78
|
const response = await axios.post<AuthToken>(`${this.basePath}/v1/auth/api_keys`, {
|
|
79
79
|
challenge_id: challengeId,
|
|
@@ -84,24 +84,24 @@ export class AppKeyGenerator {
|
|
|
84
84
|
throw new Error("Authentication failed: No api key received");
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
-
return {
|
|
87
|
+
return { apiKey: response.data.api_key, anytypeVersion: response.headers["anytype-version"] };
|
|
88
88
|
} catch (error) {
|
|
89
89
|
console.error("Authentication error:", error instanceof Error ? error.message : error);
|
|
90
90
|
throw new Error("Failed to complete authentication");
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
-
public async
|
|
94
|
+
public async generateApiKey(): Promise<void> {
|
|
95
95
|
try {
|
|
96
|
-
console.log("Starting authentication to get
|
|
96
|
+
console.log("Starting authentication to get API key...");
|
|
97
97
|
|
|
98
98
|
const challengeId = await this.startAuthentication();
|
|
99
99
|
console.log("Please check Anytype Desktop for the 4-digit code");
|
|
100
100
|
const code = await this.prompt("Enter the 4-digit code shown in Anytype Desktop: ");
|
|
101
101
|
|
|
102
|
-
const {
|
|
102
|
+
const { apiKey, anytypeVersion } = await this.completeAuthentication(challengeId, code);
|
|
103
103
|
console.log("Authenticated successfully!");
|
|
104
|
-
this.displaySuccessMessage(
|
|
104
|
+
this.displaySuccessMessage(apiKey, anytypeVersion);
|
|
105
105
|
} catch (error) {
|
|
106
106
|
console.error("Error:", error instanceof Error ? error.message : error);
|
|
107
107
|
process.exit(1);
|