@archbee/mcp 1.0.1 → 1.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/dist/index.js +100 -103
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +2 -7
package/dist/index.js
CHANGED
|
@@ -1,118 +1,115 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
var __importDefault =
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const zod_1 = require('zod')
|
|
12
|
-
const axios_1 = __importDefault(require('axios'))
|
|
2
|
+
"use strict";
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
const mcp_js_1 = require("@modelcontextprotocol/sdk/server/mcp.js");
|
|
8
|
+
const stdio_js_1 = require("@modelcontextprotocol/sdk/server/stdio.js");
|
|
9
|
+
const zod_1 = require("zod");
|
|
10
|
+
const axios_1 = __importDefault(require("axios"));
|
|
13
11
|
// Create an MCP server
|
|
14
12
|
const server = new mcp_js_1.McpServer({
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
})
|
|
13
|
+
name: 'Archbee MCP',
|
|
14
|
+
version: '1.0.0',
|
|
15
|
+
});
|
|
18
16
|
server.tool('get_all_docs', {}, async ({}) => {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
})
|
|
17
|
+
const params = {
|
|
18
|
+
tool: 'get-all-docs',
|
|
19
|
+
};
|
|
20
|
+
return callMcpApi(params);
|
|
21
|
+
});
|
|
24
22
|
server.tool('get_doc', { docId: zod_1.z.string() }, async ({ docId }) => {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
})
|
|
23
|
+
const params = {
|
|
24
|
+
tool: 'get-doc',
|
|
25
|
+
docId,
|
|
26
|
+
};
|
|
27
|
+
return callMcpApi(params);
|
|
28
|
+
});
|
|
31
29
|
server.tool('search_query', { query: zod_1.z.string() }, async ({ query }) => {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
})
|
|
30
|
+
const params = {
|
|
31
|
+
tool: 'search-query',
|
|
32
|
+
query,
|
|
33
|
+
};
|
|
34
|
+
return callMcpApi(params);
|
|
35
|
+
});
|
|
38
36
|
server.tool('search_title', { query: zod_1.z.string() }, async ({ query }) => {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
})
|
|
37
|
+
const params = {
|
|
38
|
+
tool: 'search-title',
|
|
39
|
+
query,
|
|
40
|
+
};
|
|
41
|
+
return callMcpApi(params);
|
|
42
|
+
});
|
|
45
43
|
const processUrl = (urlInput) => {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
44
|
+
try {
|
|
45
|
+
const url = new URL(urlInput);
|
|
46
|
+
url.pathname = url.pathname.endsWith('/')
|
|
47
|
+
? url.pathname + 'mcp'
|
|
48
|
+
: url.pathname + '/mcp';
|
|
49
|
+
return url.toString();
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
};
|
|
56
55
|
const callMcpApi = async (params) => {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
return {
|
|
64
|
-
content: [{ type: 'text', text: 'API base URL or docSpaceId not set.' }],
|
|
56
|
+
const urlInput = process.env.API_BASE || '';
|
|
57
|
+
const docSpaceIdInput = process.env.SPACE_ID || '';
|
|
58
|
+
if (!urlInput && !docSpaceIdInput) {
|
|
59
|
+
return {
|
|
60
|
+
content: [{ type: 'text', text: 'API base URL or docSpaceId not set.' }],
|
|
61
|
+
};
|
|
65
62
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
return { content: [{ type: 'text', text: 'API key not set.' }] }
|
|
69
|
-
}
|
|
70
|
-
const urlMcp = urlInput
|
|
71
|
-
? processUrl(urlInput)
|
|
72
|
-
: 'https://app.archbee.com/api/public-mcp'
|
|
73
|
-
if (urlMcp === null) {
|
|
74
|
-
return {
|
|
75
|
-
content: [{ type: 'text', text: 'Invalid API base URL format.' }],
|
|
63
|
+
if (!process.env.API_KEY && !urlInput) {
|
|
64
|
+
return { content: [{ type: 'text', text: 'API key not set.' }] };
|
|
76
65
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
if (
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
const response = await axios_1.default.post(urlMcp, params, {
|
|
85
|
-
headers: {
|
|
86
|
-
Authorization: `Bearer ${base64Auth}`,
|
|
87
|
-
'Content-Type': 'application/json',
|
|
88
|
-
},
|
|
89
|
-
})
|
|
90
|
-
dataText = JSON.stringify(response.data)
|
|
91
|
-
} else {
|
|
92
|
-
const response = await axios_1.default.get(urlMcp, {
|
|
93
|
-
params,
|
|
94
|
-
headers,
|
|
95
|
-
})
|
|
96
|
-
dataText = JSON.stringify(response.data)
|
|
66
|
+
const urlMcp = urlInput
|
|
67
|
+
? processUrl(urlInput)
|
|
68
|
+
: 'https://app.archbee.com/api/public-mcp';
|
|
69
|
+
if (urlMcp === null) {
|
|
70
|
+
return {
|
|
71
|
+
content: [{ type: 'text', text: 'Invalid API base URL format.' }],
|
|
72
|
+
};
|
|
97
73
|
}
|
|
98
|
-
|
|
99
|
-
|
|
74
|
+
try {
|
|
75
|
+
let dataText = '';
|
|
76
|
+
if (docSpaceIdInput) {
|
|
77
|
+
params.docSpaceId = docSpaceIdInput;
|
|
78
|
+
const rawAuth = `${docSpaceIdInput}~${process.env.API_KEY}`;
|
|
79
|
+
const base64Auth = Buffer.from(rawAuth).toString('base64');
|
|
80
|
+
const response = await axios_1.default.post(urlMcp, params, {
|
|
81
|
+
headers: {
|
|
82
|
+
Authorization: `Bearer ${base64Auth}`,
|
|
83
|
+
'Content-Type': 'application/json',
|
|
84
|
+
},
|
|
85
|
+
});
|
|
86
|
+
dataText = JSON.stringify(response.data);
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
const response = await axios_1.default.get(urlMcp, {
|
|
90
|
+
params,
|
|
91
|
+
});
|
|
92
|
+
dataText = JSON.stringify(response.data);
|
|
93
|
+
}
|
|
94
|
+
return {
|
|
95
|
+
content: [{ type: 'text', text: dataText }],
|
|
96
|
+
};
|
|
100
97
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
98
|
+
catch (error) {
|
|
99
|
+
return {
|
|
100
|
+
content: [
|
|
101
|
+
{
|
|
102
|
+
type: 'text',
|
|
103
|
+
text: `Error in mcp: ${error} ${urlMcp} ${params}`,
|
|
104
|
+
},
|
|
105
|
+
],
|
|
106
|
+
};
|
|
109
107
|
}
|
|
110
|
-
|
|
111
|
-
}
|
|
108
|
+
};
|
|
112
109
|
const main = async () => {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
}
|
|
117
|
-
main()
|
|
118
|
-
//# sourceMappingURL=index.js.map
|
|
110
|
+
// Start receiving messages on stdin and sending messages on stdout
|
|
111
|
+
const transport = new stdio_js_1.StdioServerTransport();
|
|
112
|
+
await server.connect(transport);
|
|
113
|
+
};
|
|
114
|
+
main();
|
|
115
|
+
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AAEA,oEAAmE;AACnE,wEAAgF;AAChF,6BAAuB;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AAEA,oEAAmE;AACnE,wEAAgF;AAChF,6BAAuB;AAGvB,kDAAyB;AAEzB,uBAAuB;AACvB,MAAM,MAAM,GAAG,IAAI,kBAAS,CAAC;IAC3B,IAAI,EAAE,aAAa;IACnB,OAAO,EAAE,OAAO;CACjB,CAAC,CAAA;AAEF,MAAM,CAAC,IAAI,CAAC,cAAc,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE;IAC3C,MAAM,MAAM,GAAG;QACb,IAAI,EAAE,cAAc;KACrB,CAAA;IACD,OAAO,UAAU,CAAC,MAAM,CAAC,CAAA;AAC3B,CAAC,CAAC,CAAA;AAEF,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,EAAE,KAAK,EAAE,OAAC,CAAC,MAAM,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE;IAChE,MAAM,MAAM,GAAG;QACb,IAAI,EAAE,SAAS;QACf,KAAK;KACN,CAAA;IACD,OAAO,UAAU,CAAC,MAAM,CAAC,CAAA;AAC3B,CAAC,CAAC,CAAA;AAEF,MAAM,CAAC,IAAI,CAAC,cAAc,EAAE,EAAE,KAAK,EAAE,OAAC,CAAC,MAAM,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE;IACrE,MAAM,MAAM,GAAG;QACb,IAAI,EAAE,cAAc;QACpB,KAAK;KACN,CAAA;IACD,OAAO,UAAU,CAAC,MAAM,CAAC,CAAA;AAC3B,CAAC,CAAC,CAAA;AAEF,MAAM,CAAC,IAAI,CAAC,cAAc,EAAE,EAAE,KAAK,EAAE,OAAC,CAAC,MAAM,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,EA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AAK,IAAI,MAAM,IAAI,MAAM,EAAE;iBACnD;aACF;SACF,CAAA;IACH,CAAC;AACH,CAAC,CAAA;AAED,MAAM,IAAI,GAAG,KAAK,IAAI,EAAE;IACtB,mEAAmE;IACnE,MAAM,SAAS,GAAG,IAAI,+BAAoB,EAAE,CAAA;IAC5C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAA;AACjC,CAAC,CAAA;AAED,IAAI,EAAE,CAAA"}
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -4,8 +4,8 @@ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'
|
|
|
4
4
|
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'
|
|
5
5
|
import { z } from 'zod'
|
|
6
6
|
|
|
7
|
-
import axios from 'axios'
|
|
8
7
|
import { CallToolResult } from '@modelcontextprotocol/sdk/types'
|
|
8
|
+
import axios from 'axios'
|
|
9
9
|
|
|
10
10
|
// Create an MCP server
|
|
11
11
|
const server = new McpServer({
|
|
@@ -61,10 +61,6 @@ const processUrl = (urlInput: string): string | null => {
|
|
|
61
61
|
const callMcpApi = async (
|
|
62
62
|
params: Record<string, any>
|
|
63
63
|
): Promise<CallToolResult> => {
|
|
64
|
-
const headers = {
|
|
65
|
-
Authorization: `Bearer ${process.env.API_KEY}`,
|
|
66
|
-
}
|
|
67
|
-
|
|
68
64
|
const urlInput = process.env.API_BASE || ''
|
|
69
65
|
const docSpaceIdInput = process.env.SPACE_ID || ''
|
|
70
66
|
|
|
@@ -74,7 +70,7 @@ const callMcpApi = async (
|
|
|
74
70
|
}
|
|
75
71
|
}
|
|
76
72
|
|
|
77
|
-
if (!process.env.API_KEY) {
|
|
73
|
+
if (!process.env.API_KEY && !urlInput) {
|
|
78
74
|
return { content: [{ type: 'text', text: 'API key not set.' }] }
|
|
79
75
|
}
|
|
80
76
|
|
|
@@ -106,7 +102,6 @@ const callMcpApi = async (
|
|
|
106
102
|
} else {
|
|
107
103
|
const response = await axios.get(urlMcp, {
|
|
108
104
|
params,
|
|
109
|
-
headers,
|
|
110
105
|
})
|
|
111
106
|
dataText = JSON.stringify(response.data)
|
|
112
107
|
}
|