@anyproto/anytype-mcp 1.2.2 → 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 +17 -18
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
|
@@ -2,10 +2,10 @@ import axios from "axios";
|
|
|
2
2
|
import * as readline from "readline";
|
|
3
3
|
|
|
4
4
|
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
|
}
|
|
@@ -51,9 +51,7 @@ export class AppKeyGenerator {
|
|
|
51
51
|
*/
|
|
52
52
|
private async startAuthentication(): Promise<string> {
|
|
53
53
|
try {
|
|
54
|
-
const response = await axios.post(`${this.basePath}/v1/auth/
|
|
55
|
-
params: { app_name: this.appName },
|
|
56
|
-
});
|
|
54
|
+
const response = await axios.post(`${this.basePath}/v1/auth/challenges`, { app_name: this.appName });
|
|
57
55
|
|
|
58
56
|
if (!response.data?.challenge_id) {
|
|
59
57
|
throw new Error("Failed to get challenge ID");
|
|
@@ -75,34 +73,35 @@ export class AppKeyGenerator {
|
|
|
75
73
|
private async completeAuthentication(
|
|
76
74
|
challengeId: string,
|
|
77
75
|
code: string,
|
|
78
|
-
): Promise<{
|
|
76
|
+
): Promise<{ apiKey: string; anytypeVersion: string }> {
|
|
79
77
|
try {
|
|
80
|
-
const response = await axios.post<AuthToken>(`${this.basePath}/v1/auth/
|
|
81
|
-
|
|
78
|
+
const response = await axios.post<AuthToken>(`${this.basePath}/v1/auth/api_keys`, {
|
|
79
|
+
challenge_id: challengeId,
|
|
80
|
+
code: code,
|
|
82
81
|
});
|
|
83
82
|
|
|
84
|
-
if (!response.data?.
|
|
85
|
-
throw new Error("Authentication failed: No
|
|
83
|
+
if (!response.data?.api_key) {
|
|
84
|
+
throw new Error("Authentication failed: No api key received");
|
|
86
85
|
}
|
|
87
86
|
|
|
88
|
-
return {
|
|
87
|
+
return { apiKey: response.data.api_key, anytypeVersion: response.headers["anytype-version"] };
|
|
89
88
|
} catch (error) {
|
|
90
89
|
console.error("Authentication error:", error instanceof Error ? error.message : error);
|
|
91
90
|
throw new Error("Failed to complete authentication");
|
|
92
91
|
}
|
|
93
92
|
}
|
|
94
93
|
|
|
95
|
-
public async
|
|
94
|
+
public async generateApiKey(): Promise<void> {
|
|
96
95
|
try {
|
|
97
|
-
console.log("Starting authentication to get
|
|
96
|
+
console.log("Starting authentication to get API key...");
|
|
98
97
|
|
|
99
98
|
const challengeId = await this.startAuthentication();
|
|
100
99
|
console.log("Please check Anytype Desktop for the 4-digit code");
|
|
101
100
|
const code = await this.prompt("Enter the 4-digit code shown in Anytype Desktop: ");
|
|
102
101
|
|
|
103
|
-
const {
|
|
102
|
+
const { apiKey, anytypeVersion } = await this.completeAuthentication(challengeId, code);
|
|
104
103
|
console.log("Authenticated successfully!");
|
|
105
|
-
this.displaySuccessMessage(
|
|
104
|
+
this.displaySuccessMessage(apiKey, anytypeVersion);
|
|
106
105
|
} catch (error) {
|
|
107
106
|
console.error("Error:", error instanceof Error ? error.message : error);
|
|
108
107
|
process.exit(1);
|