@cjavdev/believe-mcp 0.5.1 → 0.6.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/README.md +3 -3
- package/http.d.mts +7 -2
- package/http.d.mts.map +1 -1
- package/http.d.ts +7 -2
- package/http.d.ts.map +1 -1
- package/http.js +21 -10
- package/http.js.map +1 -1
- package/http.mjs +21 -10
- package/http.mjs.map +1 -1
- package/index.js +5 -1
- package/index.js.map +1 -1
- package/index.mjs +5 -1
- package/index.mjs.map +1 -1
- package/options.d.mts +1 -0
- package/options.d.mts.map +1 -1
- package/options.d.ts +1 -0
- package/options.d.ts.map +1 -1
- package/options.js +14 -13
- package/options.js.map +1 -1
- package/options.mjs +14 -13
- package/options.mjs.map +1 -1
- package/package.json +3 -2
- package/server.d.mts +2 -3
- package/server.d.mts.map +1 -1
- package/server.d.ts +2 -3
- package/server.d.ts.map +1 -1
- package/server.js +34 -7
- package/server.js.map +1 -1
- package/server.mjs +33 -6
- package/server.mjs.map +1 -1
- package/src/http.ts +27 -10
- package/src/index.ts +5 -1
- package/src/options.ts +15 -13
- package/src/server.ts +43 -7
- package/src/stdio.ts +2 -2
- package/stdio.js +2 -2
- package/stdio.js.map +1 -1
- package/stdio.mjs +2 -2
- package/stdio.mjs.map +1 -1
package/README.md
CHANGED
|
@@ -39,14 +39,14 @@ For clients with a configuration JSON, it might look something like this:
|
|
|
39
39
|
If you use Cursor, you can install the MCP server by using the button below. You will need to set your environment variables
|
|
40
40
|
in Cursor's `mcp.json`, which can be found in Cursor Settings > Tools & MCP > New MCP Server.
|
|
41
41
|
|
|
42
|
-
[](https://cursor.com/en-US/install-mcp?name=%40cjavdev%2Fbelieve-mcp&config=
|
|
42
|
+
[](https://cursor.com/en-US/install-mcp?name=%40cjavdev%2Fbelieve-mcp&config=eyJuYW1lIjoiQGNqYXZkZXYvYmVsaWV2ZS1tY3AiLCJ0cmFuc3BvcnQiOiJodHRwIiwidXJsIjoiaHR0cHM6Ly9iZWxpZXZlLnN0bG1jcC5jb20iLCJoZWFkZXJzIjp7IngtYmVsaWV2ZS1hcGkta2V5IjoiTXkgQVBJIEtleSJ9fQ)
|
|
43
43
|
|
|
44
44
|
### VS Code
|
|
45
45
|
|
|
46
46
|
If you use MCP, you can install the MCP server by clicking the link below. You will need to set your environment variables
|
|
47
47
|
in VS Code's `mcp.json`, which can be found via Command Palette > MCP: Open User Configuration.
|
|
48
48
|
|
|
49
|
-
[Open VS Code](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40cjavdev%2Fbelieve-mcp%22%2C%
|
|
49
|
+
[Open VS Code](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40cjavdev%2Fbelieve-mcp%22%2C%22type%22%3A%22http%22%2C%22url%22%3A%22https%3A%2F%2Fbelieve.stlmcp.com%22%2C%22headers%22%3A%7B%22x-believe-api-key%22%3A%22My%20API%20Key%22%7D%7D)
|
|
50
50
|
|
|
51
51
|
### Claude Code
|
|
52
52
|
|
|
@@ -54,7 +54,7 @@ If you use Claude Code, you can install the MCP server by running the command be
|
|
|
54
54
|
environment variables in Claude Code's `.claude.json`, which can be found in your home directory.
|
|
55
55
|
|
|
56
56
|
```
|
|
57
|
-
claude mcp add cjavdev_believe_mcp_api --
|
|
57
|
+
claude mcp add cjavdev_believe_mcp_api --header "x-believe-api-key: My API Key" --transport http https://believe.stlmcp.com
|
|
58
58
|
```
|
|
59
59
|
|
|
60
60
|
## Code Mode
|
package/http.d.mts
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import express from 'express';
|
|
2
2
|
import { McpOptions } from "./options.mjs";
|
|
3
3
|
import { ClientOptions } from "./server.mjs";
|
|
4
|
-
export declare const streamableHTTPApp: ({ clientOptions, mcpOptions, }: {
|
|
4
|
+
export declare const streamableHTTPApp: ({ clientOptions, mcpOptions, debug, }: {
|
|
5
5
|
clientOptions?: ClientOptions;
|
|
6
6
|
mcpOptions: McpOptions;
|
|
7
|
+
debug: boolean;
|
|
7
8
|
}) => express.Express;
|
|
8
|
-
export declare const launchStreamableHTTPServer: (
|
|
9
|
+
export declare const launchStreamableHTTPServer: (params: {
|
|
10
|
+
mcpOptions: McpOptions;
|
|
11
|
+
debug: boolean;
|
|
12
|
+
port: number | string | undefined;
|
|
13
|
+
}) => Promise<void>;
|
|
9
14
|
//# sourceMappingURL=http.d.mts.map
|
package/http.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.d.mts","sourceRoot":"","sources":["src/http.ts"],"names":[],"mappings":"OAIO,OAAO,MAAM,SAAS;
|
|
1
|
+
{"version":3,"file":"http.d.mts","sourceRoot":"","sources":["src/http.ts"],"names":[],"mappings":"OAIO,OAAO,MAAM,SAAS;OAGtB,EAAE,UAAU,EAAE;OACd,EAAE,aAAa,EAA+B;AAoErD,eAAO,MAAM,iBAAiB,GAAI,uCAI/B;IACD,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,UAAU,EAAE,UAAU,CAAC;IACvB,KAAK,EAAE,OAAO,CAAC;CAChB,KAAG,OAAO,CAAC,OAqBX,CAAC;AAEF,eAAO,MAAM,0BAA0B,GAAU,QAAQ;IACvD,UAAU,EAAE,UAAU,CAAC;IACvB,KAAK,EAAE,OAAO,CAAC;IACf,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;CACnC,kBAYA,CAAC"}
|
package/http.d.ts
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import express from 'express';
|
|
2
2
|
import { McpOptions } from "./options.js";
|
|
3
3
|
import { ClientOptions } from "./server.js";
|
|
4
|
-
export declare const streamableHTTPApp: ({ clientOptions, mcpOptions, }: {
|
|
4
|
+
export declare const streamableHTTPApp: ({ clientOptions, mcpOptions, debug, }: {
|
|
5
5
|
clientOptions?: ClientOptions;
|
|
6
6
|
mcpOptions: McpOptions;
|
|
7
|
+
debug: boolean;
|
|
7
8
|
}) => express.Express;
|
|
8
|
-
export declare const launchStreamableHTTPServer: (
|
|
9
|
+
export declare const launchStreamableHTTPServer: (params: {
|
|
10
|
+
mcpOptions: McpOptions;
|
|
11
|
+
debug: boolean;
|
|
12
|
+
port: number | string | undefined;
|
|
13
|
+
}) => Promise<void>;
|
|
9
14
|
//# sourceMappingURL=http.d.ts.map
|
package/http.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["src/http.ts"],"names":[],"mappings":"OAIO,OAAO,MAAM,SAAS;
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["src/http.ts"],"names":[],"mappings":"OAIO,OAAO,MAAM,SAAS;OAGtB,EAAE,UAAU,EAAE;OACd,EAAE,aAAa,EAA+B;AAoErD,eAAO,MAAM,iBAAiB,GAAI,uCAI/B;IACD,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,UAAU,EAAE,UAAU,CAAC;IACvB,KAAK,EAAE,OAAO,CAAC;CAChB,KAAG,OAAO,CAAC,OAqBX,CAAC;AAEF,eAAO,MAAM,0BAA0B,GAAU,QAAQ;IACvD,UAAU,EAAE,UAAU,CAAC;IACvB,KAAK,EAAE,OAAO,CAAC;IACf,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;CACnC,kBAYA,CAAC"}
|
package/http.js
CHANGED
|
@@ -8,13 +8,14 @@ exports.launchStreamableHTTPServer = exports.streamableHTTPApp = void 0;
|
|
|
8
8
|
const streamableHttp_js_1 = require("@modelcontextprotocol/sdk/server/streamableHttp.js");
|
|
9
9
|
const express_1 = __importDefault(require("express"));
|
|
10
10
|
const morgan_1 = __importDefault(require("morgan"));
|
|
11
|
+
const morgan_body_1 = __importDefault(require("morgan-body"));
|
|
11
12
|
const server_1 = require("./server.js");
|
|
12
13
|
const headers_1 = require("./headers.js");
|
|
13
|
-
const newServer = ({ clientOptions, req, res, }) => {
|
|
14
|
-
const server = (0, server_1.newMcpServer)();
|
|
14
|
+
const newServer = async ({ clientOptions, req, res, }) => {
|
|
15
|
+
const server = await (0, server_1.newMcpServer)();
|
|
15
16
|
try {
|
|
16
17
|
const authOptions = (0, headers_1.parseAuthHeaders)(req, false);
|
|
17
|
-
(0, server_1.initMcpServer)({
|
|
18
|
+
await (0, server_1.initMcpServer)({
|
|
18
19
|
server: server,
|
|
19
20
|
clientOptions: {
|
|
20
21
|
...clientOptions,
|
|
@@ -35,7 +36,7 @@ const newServer = ({ clientOptions, req, res, }) => {
|
|
|
35
36
|
return server;
|
|
36
37
|
};
|
|
37
38
|
const post = (options) => async (req, res) => {
|
|
38
|
-
const server = newServer({ ...options, req, res });
|
|
39
|
+
const server = await newServer({ ...options, req, res });
|
|
39
40
|
// If we return null, we already set the authorization error.
|
|
40
41
|
if (server === null)
|
|
41
42
|
return;
|
|
@@ -61,20 +62,30 @@ const del = async (req, res) => {
|
|
|
61
62
|
},
|
|
62
63
|
});
|
|
63
64
|
};
|
|
64
|
-
const streamableHTTPApp = ({ clientOptions = {}, mcpOptions, }) => {
|
|
65
|
+
const streamableHTTPApp = ({ clientOptions = {}, mcpOptions, debug, }) => {
|
|
65
66
|
const app = (0, express_1.default)();
|
|
66
67
|
app.set('query parser', 'extended');
|
|
67
68
|
app.use(express_1.default.json());
|
|
68
|
-
|
|
69
|
+
if (debug) {
|
|
70
|
+
(0, morgan_body_1.default)(app, {
|
|
71
|
+
logAllReqHeader: true,
|
|
72
|
+
logAllResHeader: true,
|
|
73
|
+
logRequestBody: true,
|
|
74
|
+
logResponseBody: true,
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
app.use((0, morgan_1.default)('combined'));
|
|
79
|
+
}
|
|
69
80
|
app.get('/', get);
|
|
70
81
|
app.post('/', post({ clientOptions, mcpOptions }));
|
|
71
82
|
app.delete('/', del);
|
|
72
83
|
return app;
|
|
73
84
|
};
|
|
74
85
|
exports.streamableHTTPApp = streamableHTTPApp;
|
|
75
|
-
const launchStreamableHTTPServer = async (
|
|
76
|
-
const app = (0, exports.streamableHTTPApp)({ mcpOptions:
|
|
77
|
-
const server = app.listen(port);
|
|
86
|
+
const launchStreamableHTTPServer = async (params) => {
|
|
87
|
+
const app = (0, exports.streamableHTTPApp)({ mcpOptions: params.mcpOptions, debug: params.debug });
|
|
88
|
+
const server = app.listen(params.port);
|
|
78
89
|
const address = server.address();
|
|
79
90
|
if (typeof address === 'string') {
|
|
80
91
|
console.error(`MCP Server running on streamable HTTP at ${address}`);
|
|
@@ -83,7 +94,7 @@ const launchStreamableHTTPServer = async (options, port) => {
|
|
|
83
94
|
console.error(`MCP Server running on streamable HTTP on port ${address.port}`);
|
|
84
95
|
}
|
|
85
96
|
else {
|
|
86
|
-
console.error(`MCP Server running on streamable HTTP on port ${port}`);
|
|
97
|
+
console.error(`MCP Server running on streamable HTTP on port ${params.port}`);
|
|
87
98
|
}
|
|
88
99
|
};
|
|
89
100
|
exports.launchStreamableHTTPServer = launchStreamableHTTPServer;
|
package/http.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.js","sourceRoot":"","sources":["src/http.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;;;;AAGtF,0FAAmG;AACnG,sDAA8B;AAC9B,oDAA4B;
|
|
1
|
+
{"version":3,"file":"http.js","sourceRoot":"","sources":["src/http.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;;;;AAGtF,0FAAmG;AACnG,sDAA8B;AAC9B,oDAA4B;AAC5B,8DAAqC;AAErC,wCAAsE;AACtE,0CAA6C;AAE7C,MAAM,SAAS,GAAG,KAAK,EAAE,EACvB,aAAa,EACb,GAAG,EACH,GAAG,GAKJ,EAA6B,EAAE;IAC9B,MAAM,MAAM,GAAG,MAAM,IAAA,qBAAY,GAAE,CAAC;IAEpC,IAAI,CAAC;QACH,MAAM,WAAW,GAAG,IAAA,0BAAgB,EAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QACjD,MAAM,IAAA,sBAAa,EAAC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AAM,CAAC,UAAU,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC;IACtF,MAAM,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACvC,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,EAAE,CAAC;IAEjC,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;QAChC,OAAO,CAAC,KAAK,CAAC,4CAA4C,OAAO,EAAE,CAAC,CAAC;IACvE,CAAC;SAAM,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;QAC5B,OAAO,CAAC,KAAK,CAAC,iDAAiD,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;IACjF,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,KAAK,CAAC,iDAAiD,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;IAChF,CAAC;AACH,CAAC,CAAC;AAhBW,QAAA,0BAA0B,8BAgBrC"}
|
package/http.mjs
CHANGED
|
@@ -2,13 +2,14 @@
|
|
|
2
2
|
import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';
|
|
3
3
|
import express from 'express';
|
|
4
4
|
import morgan from 'morgan';
|
|
5
|
+
import morganBody from 'morgan-body';
|
|
5
6
|
import { initMcpServer, newMcpServer } from "./server.mjs";
|
|
6
7
|
import { parseAuthHeaders } from "./headers.mjs";
|
|
7
|
-
const newServer = ({ clientOptions, req, res, }) => {
|
|
8
|
-
const server = newMcpServer();
|
|
8
|
+
const newServer = async ({ clientOptions, req, res, }) => {
|
|
9
|
+
const server = await newMcpServer();
|
|
9
10
|
try {
|
|
10
11
|
const authOptions = parseAuthHeaders(req, false);
|
|
11
|
-
initMcpServer({
|
|
12
|
+
await initMcpServer({
|
|
12
13
|
server: server,
|
|
13
14
|
clientOptions: {
|
|
14
15
|
...clientOptions,
|
|
@@ -29,7 +30,7 @@ const newServer = ({ clientOptions, req, res, }) => {
|
|
|
29
30
|
return server;
|
|
30
31
|
};
|
|
31
32
|
const post = (options) => async (req, res) => {
|
|
32
|
-
const server = newServer({ ...options, req, res });
|
|
33
|
+
const server = await newServer({ ...options, req, res });
|
|
33
34
|
// If we return null, we already set the authorization error.
|
|
34
35
|
if (server === null)
|
|
35
36
|
return;
|
|
@@ -55,19 +56,29 @@ const del = async (req, res) => {
|
|
|
55
56
|
},
|
|
56
57
|
});
|
|
57
58
|
};
|
|
58
|
-
export const streamableHTTPApp = ({ clientOptions = {}, mcpOptions, }) => {
|
|
59
|
+
export const streamableHTTPApp = ({ clientOptions = {}, mcpOptions, debug, }) => {
|
|
59
60
|
const app = express();
|
|
60
61
|
app.set('query parser', 'extended');
|
|
61
62
|
app.use(express.json());
|
|
62
|
-
|
|
63
|
+
if (debug) {
|
|
64
|
+
morganBody(app, {
|
|
65
|
+
logAllReqHeader: true,
|
|
66
|
+
logAllResHeader: true,
|
|
67
|
+
logRequestBody: true,
|
|
68
|
+
logResponseBody: true,
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
app.use(morgan('combined'));
|
|
73
|
+
}
|
|
63
74
|
app.get('/', get);
|
|
64
75
|
app.post('/', post({ clientOptions, mcpOptions }));
|
|
65
76
|
app.delete('/', del);
|
|
66
77
|
return app;
|
|
67
78
|
};
|
|
68
|
-
export const launchStreamableHTTPServer = async (
|
|
69
|
-
const app = streamableHTTPApp({ mcpOptions:
|
|
70
|
-
const server = app.listen(port);
|
|
79
|
+
export const launchStreamableHTTPServer = async (params) => {
|
|
80
|
+
const app = streamableHTTPApp({ mcpOptions: params.mcpOptions, debug: params.debug });
|
|
81
|
+
const server = app.listen(params.port);
|
|
71
82
|
const address = server.address();
|
|
72
83
|
if (typeof address === 'string') {
|
|
73
84
|
console.error(`MCP Server running on streamable HTTP at ${address}`);
|
|
@@ -76,7 +87,7 @@ export const launchStreamableHTTPServer = async (options, port) => {
|
|
|
76
87
|
console.error(`MCP Server running on streamable HTTP on port ${address.port}`);
|
|
77
88
|
}
|
|
78
89
|
else {
|
|
79
|
-
console.error(`MCP Server running on streamable HTTP on port ${port}`);
|
|
90
|
+
console.error(`MCP Server running on streamable HTTP on port ${params.port}`);
|
|
80
91
|
}
|
|
81
92
|
};
|
|
82
93
|
//# sourceMappingURL=http.mjs.map
|
package/http.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.mjs","sourceRoot":"","sources":["src/http.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAG/E,EAAE,6BAA6B,EAAE,MAAM,oDAAoD;OAC3F,OAAO,MAAM,SAAS;OACtB,MAAM,MAAM,QAAQ;
|
|
1
|
+
{"version":3,"file":"http.mjs","sourceRoot":"","sources":["src/http.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAG/E,EAAE,6BAA6B,EAAE,MAAM,oDAAoD;OAC3F,OAAO,MAAM,SAAS;OACtB,MAAM,MAAM,QAAQ;OACpB,UAAU,MAAM,aAAa;OAE7B,EAAiB,aAAa,EAAE,YAAY,EAAE;OAC9C,EAAE,gBAAgB,EAAE;AAE3B,MAAM,SAAS,GAAG,KAAK,EAAE,EACvB,aAAa,EACb,GAAG,EACH,GAAG,GAKJ,EAA6B,EAAE;IAC9B,MAAM,MAAM,GAAG,MAAM,YAAY,EAAE,CAAC;IAEpC,IAAI,CAAC;QACH,MAAM,WAAW,GAAG,gBAAgB,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QACjD,MAAM,aAAa,CAAC;YAClB,MAAM,EAAE,MAAM;YACd,aAAa,EAAE;gBACb,GAAG,aAAa;gBAChB,GAAG,WAAW;aACf;SACF,CAAC,CAAC;IACL,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;YACnB,OAAO,EAAE,KAAK;YACd,KAAK,EAAE;gBACL,IAAI,EAAE,CAAC,KAAK;gBACZ,OAAO,EAAE,iBAAiB,KAA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,OAAO,KAAK,IAAI,EAAE,CAAC;QAC5B,OAAO,CAAC,KAAK,CAAC,iDAAiD,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;IACjF,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,KAAK,CAAC,iDAAiD,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;IAChF,CAAC;AACH,CAAC,CAAC"}
|
package/index.js
CHANGED
|
@@ -14,7 +14,11 @@ async function main() {
|
|
|
14
14
|
await (0, stdio_1.launchStdioServer)();
|
|
15
15
|
break;
|
|
16
16
|
case 'http':
|
|
17
|
-
await (0, http_1.launchStreamableHTTPServer)(
|
|
17
|
+
await (0, http_1.launchStreamableHTTPServer)({
|
|
18
|
+
mcpOptions: options,
|
|
19
|
+
debug: options.debug,
|
|
20
|
+
port: options.port ?? options.socket,
|
|
21
|
+
});
|
|
18
22
|
break;
|
|
19
23
|
}
|
|
20
24
|
}
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":";;;AAEA,wCAAuC;AACvC,0CAAwD;AACxD,sCAA4C;AAC5C,oCAAoD;AAGpD,KAAK,UAAU,IAAI;IACjB,MAAM,OAAO,GAAG,mBAAmB,EAAE,CAAC;IAEtC,MAAM,aAAa,GAAG,MAAM,kBAAkB,CAAC,OAAO,CAAC,CAAC;IAExD,OAAO,CAAC,KAAK,CACX,4BAA4B,aAAa,CAAC,MAAM,SAAS,EACzD,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CACtC,CAAC;IAEF,QAAQ,OAAO,CAAC,SAAS,EAAE,CAAC;QAC1B,KAAK,OAAO;YACV,MAAM,IAAA,yBAAiB,GAAE,CAAC;YAC1B,MAAM;QACR,KAAK,MAAM;YACT,MAAM,IAAA,iCAA0B,EAAC,OAAO,EAAE,OAAO,CAAC,IAAI,I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,CAAC,CAAC;QAC/C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC;AAED,KAAK,UAAU,kBAAkB,CAAC,OAAmB;IACnD,IAAI,CAAC;QACH,MAAM,aAAa,GAAG,IAAA,oBAAW,EAAC,OAAO,CAAC,CAAC;QAC3C,IAAI,aAAa,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC/B,OAAO,CAAC,KAAK,CAAC,sCAAsC,CAAC,CAAC;YACtD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;QACD,OAAO,aAAa,CAAC;IACvB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;YAC3B,OAAO,CAAC,KAAK,CAAC,wBAAwB,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;QACzD,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,KAAK,CAAC,wBAAwB,EAAE,KAAK,CAAC,CAAC;QACjD,CAAC;QACD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC"}
|
package/index.mjs
CHANGED
|
@@ -12,7 +12,11 @@ async function main() {
|
|
|
12
12
|
await launchStdioServer();
|
|
13
13
|
break;
|
|
14
14
|
case 'http':
|
|
15
|
-
await launchStreamableHTTPServer(
|
|
15
|
+
await launchStreamableHTTPServer({
|
|
16
|
+
mcpOptions: options,
|
|
17
|
+
debug: options.debug,
|
|
18
|
+
port: options.port ?? options.socket,
|
|
19
|
+
});
|
|
16
20
|
break;
|
|
17
21
|
}
|
|
18
22
|
}
|
package/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":";OAEO,EAAE,WAAW,EAAE;OACf,EAAc,eAAe,EAAE;OAC/B,EAAE,iBAAiB,EAAE;OACrB,EAAE,0BAA0B,E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d.mts
CHANGED
package/options.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options.d.mts","sourceRoot":"","sources":["src/options.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,UAAU,GAAG,UAAU,GAAG;IACpC,SAAS,EAAE,OAAO,GAAG,MAAM,CAAC;IAC5B,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;CAC5B,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG;IACvB,gBAAgB,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;CACxC,CAAC;AAEF,wBAAgB,eAAe,IAAI,UAAU,
|
|
1
|
+
{"version":3,"file":"options.d.mts","sourceRoot":"","sources":["src/options.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,UAAU,GAAG,UAAU,GAAG;IACpC,KAAK,EAAE,OAAO,CAAC;IACf,SAAS,EAAE,OAAO,GAAG,MAAM,CAAC;IAC5B,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;CAC5B,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG;IACvB,gBAAgB,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;CACxC,CAAC;AAEF,wBAAgB,eAAe,IAAI,UAAU,CAiD5C;AAiBD,wBAAgB,iBAAiB,CAAC,cAAc,EAAE,UAAU,EAAE,KAAK,EAAE,OAAO,GAAG,UAAU,CAYxF"}
|
package/options.d.ts
CHANGED
package/options.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options.d.ts","sourceRoot":"","sources":["src/options.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,UAAU,GAAG,UAAU,GAAG;IACpC,SAAS,EAAE,OAAO,GAAG,MAAM,CAAC;IAC5B,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;CAC5B,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG;IACvB,gBAAgB,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;CACxC,CAAC;AAEF,wBAAgB,eAAe,IAAI,UAAU,
|
|
1
|
+
{"version":3,"file":"options.d.ts","sourceRoot":"","sources":["src/options.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,UAAU,GAAG,UAAU,GAAG;IACpC,KAAK,EAAE,OAAO,CAAC;IACf,SAAS,EAAE,OAAO,GAAG,MAAM,CAAC;IAC5B,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;CAC5B,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG;IACvB,gBAAgB,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;CACxC,CAAC;AAEF,wBAAgB,eAAe,IAAI,UAAU,CAiD5C;AAiBD,wBAAgB,iBAAiB,CAAC,cAAc,EAAE,UAAU,EAAE,KAAK,EAAE,OAAO,GAAG,UAAU,CAYxF"}
|
package/options.js
CHANGED
|
@@ -11,17 +11,24 @@ const helpers_1 = require("yargs/helpers");
|
|
|
11
11
|
const zod_1 = __importDefault(require("zod"));
|
|
12
12
|
function parseCLIOptions() {
|
|
13
13
|
const opts = (0, yargs_1.default)((0, helpers_1.hideBin)(process.argv))
|
|
14
|
-
.option('
|
|
14
|
+
.option('debug', { type: 'boolean', description: 'Enable debug logging' })
|
|
15
|
+
.option('no-tools', {
|
|
15
16
|
type: 'string',
|
|
16
17
|
array: true,
|
|
17
18
|
choices: ['code', 'docs'],
|
|
18
|
-
description: '
|
|
19
|
+
description: 'Tools to explicitly disable',
|
|
19
20
|
})
|
|
20
|
-
.option('
|
|
21
|
+
.option('port', {
|
|
22
|
+
type: 'number',
|
|
23
|
+
default: 3000,
|
|
24
|
+
description: 'Port to serve on if using http transport',
|
|
25
|
+
})
|
|
26
|
+
.option('socket', { type: 'string', description: 'Unix socket to serve on if using http transport' })
|
|
27
|
+
.option('tools', {
|
|
21
28
|
type: 'string',
|
|
22
29
|
array: true,
|
|
23
30
|
choices: ['code', 'docs'],
|
|
24
|
-
description: '
|
|
31
|
+
description: 'Tools to explicitly enable',
|
|
25
32
|
})
|
|
26
33
|
.option('transport', {
|
|
27
34
|
type: 'string',
|
|
@@ -29,15 +36,8 @@ function parseCLIOptions() {
|
|
|
29
36
|
default: 'stdio',
|
|
30
37
|
description: 'What transport to use; stdio for local servers or http for remote servers',
|
|
31
38
|
})
|
|
32
|
-
.
|
|
33
|
-
|
|
34
|
-
default: 3000,
|
|
35
|
-
description: 'Port to serve on if using http transport',
|
|
36
|
-
})
|
|
37
|
-
.option('socket', {
|
|
38
|
-
type: 'string',
|
|
39
|
-
description: 'Unix socket to serve on if using http transport',
|
|
40
|
-
})
|
|
39
|
+
.env('MCP_SERVER')
|
|
40
|
+
.version(true)
|
|
41
41
|
.help();
|
|
42
42
|
const argv = opts.parseSync();
|
|
43
43
|
const shouldIncludeToolType = (toolType) => argv.noTools?.includes(toolType) ? false
|
|
@@ -47,6 +47,7 @@ function parseCLIOptions() {
|
|
|
47
47
|
const transport = argv.transport;
|
|
48
48
|
return {
|
|
49
49
|
...(includeDocsTools !== undefined && { includeDocsTools }),
|
|
50
|
+
debug: !!argv.debug,
|
|
50
51
|
transport,
|
|
51
52
|
port: argv.port,
|
|
52
53
|
socket: argv.socket,
|
package/options.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options.js","sourceRoot":"","sources":["src/options.ts"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"options.js","sourceRoot":"","sources":["src/options.ts"],"names":[],"mappings":";;;;;AAgBA,0CAiDC;AAiBD,8CAYC;AA9FD,4CAAoB;AACpB,kDAA0B;AAC1B,2CAAwC;AACxC,8CAAoB;AAapB,SAAgB,eAAe;IAC7B,MAAM,IAAI,GAAG,IAAA,eAAK,EAAC,IAAA,iBAAO,EAAC,OAAO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AAC,CAAC,KAAK,CAAC;IACxE,MAAM,YAAY,GAAG,YAAY,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;IAErD,IAAI,SAAS,GACX,YAAY,CAAC,QAAQ,IAAI,YAAY,CAAC,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK;QACxE,CAAC,CAAC,YAAY,CAAC,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI;YAC7C,CAAC,CAAC,cAAc,CAAC,gBAAgB,CAAC;IAEpC,OAAO;QACL,GAAG,CAAC,SAAS,KAAK,SAAS,IAAI,EAAE,gBAAgB,EAAE,SAAS,EAAE,CAAC;KAChE,CAAC;AACJ,CAAC"}
|
package/options.mjs
CHANGED
|
@@ -4,17 +4,24 @@ import { hideBin } from 'yargs/helpers';
|
|
|
4
4
|
import z from 'zod';
|
|
5
5
|
export function parseCLIOptions() {
|
|
6
6
|
const opts = yargs(hideBin(process.argv))
|
|
7
|
-
.option('
|
|
7
|
+
.option('debug', { type: 'boolean', description: 'Enable debug logging' })
|
|
8
|
+
.option('no-tools', {
|
|
8
9
|
type: 'string',
|
|
9
10
|
array: true,
|
|
10
11
|
choices: ['code', 'docs'],
|
|
11
|
-
description: '
|
|
12
|
+
description: 'Tools to explicitly disable',
|
|
12
13
|
})
|
|
13
|
-
.option('
|
|
14
|
+
.option('port', {
|
|
15
|
+
type: 'number',
|
|
16
|
+
default: 3000,
|
|
17
|
+
description: 'Port to serve on if using http transport',
|
|
18
|
+
})
|
|
19
|
+
.option('socket', { type: 'string', description: 'Unix socket to serve on if using http transport' })
|
|
20
|
+
.option('tools', {
|
|
14
21
|
type: 'string',
|
|
15
22
|
array: true,
|
|
16
23
|
choices: ['code', 'docs'],
|
|
17
|
-
description: '
|
|
24
|
+
description: 'Tools to explicitly enable',
|
|
18
25
|
})
|
|
19
26
|
.option('transport', {
|
|
20
27
|
type: 'string',
|
|
@@ -22,15 +29,8 @@ export function parseCLIOptions() {
|
|
|
22
29
|
default: 'stdio',
|
|
23
30
|
description: 'What transport to use; stdio for local servers or http for remote servers',
|
|
24
31
|
})
|
|
25
|
-
.
|
|
26
|
-
|
|
27
|
-
default: 3000,
|
|
28
|
-
description: 'Port to serve on if using http transport',
|
|
29
|
-
})
|
|
30
|
-
.option('socket', {
|
|
31
|
-
type: 'string',
|
|
32
|
-
description: 'Unix socket to serve on if using http transport',
|
|
33
|
-
})
|
|
32
|
+
.env('MCP_SERVER')
|
|
33
|
+
.version(true)
|
|
34
34
|
.help();
|
|
35
35
|
const argv = opts.parseSync();
|
|
36
36
|
const shouldIncludeToolType = (toolType) => argv.noTools?.includes(toolType) ? false
|
|
@@ -40,6 +40,7 @@ export function parseCLIOptions() {
|
|
|
40
40
|
const transport = argv.transport;
|
|
41
41
|
return {
|
|
42
42
|
...(includeDocsTools !== undefined && { includeDocsTools }),
|
|
43
|
+
debug: !!argv.debug,
|
|
43
44
|
transport,
|
|
44
45
|
port: argv.port,
|
|
45
46
|
socket: argv.socket,
|
package/options.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options.mjs","sourceRoot":"","sources":["src/options.ts"],"names":[],"mappings":"OAAO,EAAE,MAAM,IAAI;OACZ,KAAK,MAAM,OAAO;OAClB,EAAE,OAAO,EAAE,MAAM,eAAe;OAChC,CAAC,MAAM,KAAK;
|
|
1
|
+
{"version":3,"file":"options.mjs","sourceRoot":"","sources":["src/options.ts"],"names":[],"mappings":"OAAO,EAAE,MAAM,IAAI;OACZ,KAAK,MAAM,OAAO;OAClB,EAAE,OAAO,EAAE,MAAM,eAAe;OAChC,CAAC,MAAM,KAAK;AAanB,MAAM,UAAU,eAAe;IAC7B,MAAM,IAAI,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;SACtC,MAAM,CAAC,OAAO,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE,sBAAsB,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SAAS,GACX,YAAY,CAAC,QAAQ,IAAI,YAAY,CAAC,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK;QACxE,CAAC,CAAC,YAAY,CAAC,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI;YAC7C,CAAC,CAAC,cAAc,CAAC,gBAAgB,CAAC;IAEpC,OAAO;QACL,GAAG,CAAC,SAAS,KAAK,SAAS,IAAI,EAAE,gBAAgB,EAAE,SAAS,EAAE,CAAC;KAChE,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cjavdev/believe-mcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "The official MCP Server for the Believe API",
|
|
5
5
|
"author": "Believe <wave@cjav.dev>",
|
|
6
6
|
"types": "./index.d.ts",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"access": "public"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@cjavdev/believe": "^0.
|
|
21
|
+
"@cjavdev/believe": "^0.6.0",
|
|
22
22
|
"@cloudflare/cabidela": "^0.2.4",
|
|
23
23
|
"@modelcontextprotocol/sdk": "^1.25.2",
|
|
24
24
|
"@valtown/deno-http-worker": "^0.0.21",
|
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
"fuse.js": "^7.1.0",
|
|
29
29
|
"jq-web": "https://github.com/stainless-api/jq-web/releases/download/v0.8.8/jq-web.tar.gz",
|
|
30
30
|
"morgan": "^1.10.0",
|
|
31
|
+
"morgan-body": "^2.6.9",
|
|
31
32
|
"qs": "^6.14.1",
|
|
32
33
|
"typescript": "5.8.3",
|
|
33
34
|
"yargs": "^17.7.2",
|
package/server.d.mts
CHANGED
|
@@ -6,8 +6,7 @@ import { McpOptions } from "./options.mjs";
|
|
|
6
6
|
import { HandlerFunction, McpTool } from "./types.mjs";
|
|
7
7
|
export { McpOptions } from "./options.mjs";
|
|
8
8
|
export { ClientOptions } from '@cjavdev/believe';
|
|
9
|
-
export declare const newMcpServer: () => McpServer
|
|
10
|
-
export declare const server: McpServer;
|
|
9
|
+
export declare const newMcpServer: () => Promise<McpServer>;
|
|
11
10
|
/**
|
|
12
11
|
* Initializes the provided MCP Server with the given tools and handlers.
|
|
13
12
|
* If not provided, the default client, tools and handlers will be used.
|
|
@@ -16,7 +15,7 @@ export declare function initMcpServer(params: {
|
|
|
16
15
|
server: Server | McpServer;
|
|
17
16
|
clientOptions?: ClientOptions;
|
|
18
17
|
mcpOptions?: McpOptions;
|
|
19
|
-
}): void
|
|
18
|
+
}): Promise<void>;
|
|
20
19
|
/**
|
|
21
20
|
* Selects the tools to include in the MCP Server based on the provided options.
|
|
22
21
|
*/
|
package/server.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.mts","sourceRoot":"","sources":["src/server.ts"],"names":[],"mappings":"OAEO,EAAE,MAAM,EAAE,MAAM,2CAA2C;OAC3D,EAAE,SAAS,EAAE,MAAM,yCAAyC;OAM5D,EAAE,aAAa,EAAE,MAAM,kBAAkB;OACzC,OAAO,MAAM,kBAAkB;OAG/B,EAAE,UAAU,EAAE;OACd,EAAE,eAAe,EAAE,OAAO,EAAE;OAE5B,EAAE,UAAU,EAAE;OACd,EAAE,aAAa,EAAE,MAAM,kBAAkB;
|
|
1
|
+
{"version":3,"file":"server.d.mts","sourceRoot":"","sources":["src/server.ts"],"names":[],"mappings":"OAEO,EAAE,MAAM,EAAE,MAAM,2CAA2C;OAC3D,EAAE,SAAS,EAAE,MAAM,yCAAyC;OAM5D,EAAE,aAAa,EAAE,MAAM,kBAAkB;OACzC,OAAO,MAAM,kBAAkB;OAG/B,EAAE,UAAU,EAAE;OACd,EAAE,eAAe,EAAE,OAAO,EAAE;OAE5B,EAAE,UAAU,EAAE;OACd,EAAE,aAAa,EAAE,MAAM,kBAAkB;AAsChD,eAAO,MAAM,YAAY,0BAUtB,CAAC;AAEJ;;;GAGG;AACH,wBAAsB,aAAa,CAAC,MAAM,EAAE;IAC1C,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,UAAU,CAAC,EAAE,UAAU,CAAC;CACzB,iBAoEA;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,OAAO,CAAC,EAAE,UAAU,GAAG,OAAO,EAAE,CAM3D;AAED;;GAEG;AACH,wBAAsB,cAAc,CAClC,OAAO,EAAE,eAAe,EACxB,MAAM,EAAE,OAAO,EACf,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,6CAG1C;AAED,eAAO,MAAM,OAAO,GAAI,KAAK,MAAM,KAAG,MAAM,GAAG,SAO9C,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,KAAK,MAAM,KAAG,MAM5C,CAAC;AAEF,eAAO,MAAM,YAAY,GAAI,CAAC,EAAE,OAAO,CAAC,GAAG,SAAS,EAAE,aAAa,MAAM,KAAG,CAK3E,CAAC"}
|
package/server.d.ts
CHANGED
|
@@ -6,8 +6,7 @@ import { McpOptions } from "./options.js";
|
|
|
6
6
|
import { HandlerFunction, McpTool } from "./types.js";
|
|
7
7
|
export { McpOptions } from "./options.js";
|
|
8
8
|
export { ClientOptions } from '@cjavdev/believe';
|
|
9
|
-
export declare const newMcpServer: () => McpServer
|
|
10
|
-
export declare const server: McpServer;
|
|
9
|
+
export declare const newMcpServer: () => Promise<McpServer>;
|
|
11
10
|
/**
|
|
12
11
|
* Initializes the provided MCP Server with the given tools and handlers.
|
|
13
12
|
* If not provided, the default client, tools and handlers will be used.
|
|
@@ -16,7 +15,7 @@ export declare function initMcpServer(params: {
|
|
|
16
15
|
server: Server | McpServer;
|
|
17
16
|
clientOptions?: ClientOptions;
|
|
18
17
|
mcpOptions?: McpOptions;
|
|
19
|
-
}): void
|
|
18
|
+
}): Promise<void>;
|
|
20
19
|
/**
|
|
21
20
|
* Selects the tools to include in the MCP Server based on the provided options.
|
|
22
21
|
*/
|
package/server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["src/server.ts"],"names":[],"mappings":"OAEO,EAAE,MAAM,EAAE,MAAM,2CAA2C;OAC3D,EAAE,SAAS,EAAE,MAAM,yCAAyC;OAM5D,EAAE,aAAa,EAAE,MAAM,kBAAkB;OACzC,OAAO,MAAM,kBAAkB;OAG/B,EAAE,UAAU,EAAE;OACd,EAAE,eAAe,EAAE,OAAO,EAAE;OAE5B,EAAE,UAAU,EAAE;OACd,EAAE,aAAa,EAAE,MAAM,kBAAkB;
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["src/server.ts"],"names":[],"mappings":"OAEO,EAAE,MAAM,EAAE,MAAM,2CAA2C;OAC3D,EAAE,SAAS,EAAE,MAAM,yCAAyC;OAM5D,EAAE,aAAa,EAAE,MAAM,kBAAkB;OACzC,OAAO,MAAM,kBAAkB;OAG/B,EAAE,UAAU,EAAE;OACd,EAAE,eAAe,EAAE,OAAO,EAAE;OAE5B,EAAE,UAAU,EAAE;OACd,EAAE,aAAa,EAAE,MAAM,kBAAkB;AAsChD,eAAO,MAAM,YAAY,0BAUtB,CAAC;AAEJ;;;GAGG;AACH,wBAAsB,aAAa,CAAC,MAAM,EAAE;IAC1C,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,UAAU,CAAC,EAAE,UAAU,CAAC;CACzB,iBAoEA;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,OAAO,CAAC,EAAE,UAAU,GAAG,OAAO,EAAE,CAM3D;AAED;;GAEG;AACH,wBAAsB,cAAc,CAClC,OAAO,EAAE,eAAe,EACxB,MAAM,EAAE,OAAO,EACf,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,6CAG1C;AAED,eAAO,MAAM,OAAO,GAAI,KAAK,MAAM,KAAG,MAAM,GAAG,SAO9C,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,KAAK,MAAM,KAAG,MAM5C,CAAC;AAEF,eAAO,MAAM,YAAY,GAAI,CAAC,EAAE,OAAO,CAAC,GAAG,SAAS,EAAE,aAAa,MAAM,KAAG,CAK3E,CAAC"}
|
package/server.js
CHANGED
|
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
5
|
};
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.requireValue = exports.readEnvOrError = exports.readEnv = exports.
|
|
7
|
+
exports.requireValue = exports.readEnvOrError = exports.readEnv = exports.newMcpServer = void 0;
|
|
8
8
|
exports.initMcpServer = initMcpServer;
|
|
9
9
|
exports.selectTools = selectTools;
|
|
10
10
|
exports.executeHandler = executeHandler;
|
|
@@ -13,18 +13,45 @@ const types_js_1 = require("@modelcontextprotocol/sdk/types.js");
|
|
|
13
13
|
const believe_1 = __importDefault(require("@cjavdev/believe"));
|
|
14
14
|
const code_tool_1 = require("./code-tool.js");
|
|
15
15
|
const docs_search_tool_1 = __importDefault(require("./docs-search-tool.js"));
|
|
16
|
-
|
|
16
|
+
async function getInstructions() {
|
|
17
|
+
// This API key is optional; providing it allows the server to fetch instructions for unreleased versions.
|
|
18
|
+
const stainlessAPIKey = (0, exports.readEnv)('STAINLESS_API_KEY');
|
|
19
|
+
const response = await fetch((0, exports.readEnv)('CODE_MODE_INSTRUCTIONS_URL') ?? 'https://api.stainless.com/api/ai/instructions/believe', {
|
|
20
|
+
method: 'GET',
|
|
21
|
+
headers: { ...(stainlessAPIKey && { Authorization: stainlessAPIKey }) },
|
|
22
|
+
});
|
|
23
|
+
let instructions;
|
|
24
|
+
if (!response.ok) {
|
|
25
|
+
console.warn('Warning: failed to retrieve MCP server instructions. Proceeding with default instructions...');
|
|
26
|
+
instructions = `
|
|
27
|
+
This is the believe MCP server. You will use Code Mode to help the user perform
|
|
28
|
+
actions. You can use search_docs tool to learn about how to take action with this server. Then,
|
|
29
|
+
you will write TypeScript code using the execute tool take action. It is CRITICAL that you be
|
|
30
|
+
thoughtful and deliberate when executing code. Always try to entirely solve the problem in code
|
|
31
|
+
block: it can be as long as you need to get the job done!
|
|
32
|
+
`;
|
|
33
|
+
}
|
|
34
|
+
instructions ??= (await response.json()).instructions;
|
|
35
|
+
instructions = `
|
|
36
|
+
The current time in Unix timestamps is ${Date.now()}.
|
|
37
|
+
|
|
38
|
+
${instructions}
|
|
39
|
+
`;
|
|
40
|
+
return instructions;
|
|
41
|
+
}
|
|
42
|
+
const newMcpServer = async () => new mcp_js_1.McpServer({
|
|
17
43
|
name: 'cjavdev_believe_api',
|
|
18
|
-
version: '0.
|
|
19
|
-
}, {
|
|
44
|
+
version: '0.6.0',
|
|
45
|
+
}, {
|
|
46
|
+
instructions: await getInstructions(),
|
|
47
|
+
capabilities: { tools: {}, logging: {} },
|
|
48
|
+
});
|
|
20
49
|
exports.newMcpServer = newMcpServer;
|
|
21
|
-
// Create server instance
|
|
22
|
-
exports.server = (0, exports.newMcpServer)();
|
|
23
50
|
/**
|
|
24
51
|
* Initializes the provided MCP Server with the given tools and handlers.
|
|
25
52
|
* If not provided, the default client, tools and handlers will be used.
|
|
26
53
|
*/
|
|
27
|
-
function initMcpServer(params) {
|
|
54
|
+
async function initMcpServer(params) {
|
|
28
55
|
const server = params.server instanceof mcp_js_1.McpServer ? params.server.server : params.server;
|
|
29
56
|
const logAtLevel = (level) => (message, ...rest) => {
|
|
30
57
|
void server.sendLoggingMessage({
|
package/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["src/server.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;;;;
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mB,EAAK,EAAE;IAC9E,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,MAAM,IAAI,KAAK,CAAC,2BAA2B,WAAW,EAAE,CAAC,CAAC;IAC5D,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AALW,QAAA,YAAY,gBAKvB"}
|
package/server.mjs
CHANGED
|
@@ -4,17 +4,44 @@ import { CallToolRequestSchema, ListToolsRequestSchema, SetLevelRequestSchema, }
|
|
|
4
4
|
import Believe from '@cjavdev/believe';
|
|
5
5
|
import { codeTool } from "./code-tool.mjs";
|
|
6
6
|
import docsSearchTool from "./docs-search-tool.mjs";
|
|
7
|
-
|
|
7
|
+
async function getInstructions() {
|
|
8
|
+
// This API key is optional; providing it allows the server to fetch instructions for unreleased versions.
|
|
9
|
+
const stainlessAPIKey = readEnv('STAINLESS_API_KEY');
|
|
10
|
+
const response = await fetch(readEnv('CODE_MODE_INSTRUCTIONS_URL') ?? 'https://api.stainless.com/api/ai/instructions/believe', {
|
|
11
|
+
method: 'GET',
|
|
12
|
+
headers: { ...(stainlessAPIKey && { Authorization: stainlessAPIKey }) },
|
|
13
|
+
});
|
|
14
|
+
let instructions;
|
|
15
|
+
if (!response.ok) {
|
|
16
|
+
console.warn('Warning: failed to retrieve MCP server instructions. Proceeding with default instructions...');
|
|
17
|
+
instructions = `
|
|
18
|
+
This is the believe MCP server. You will use Code Mode to help the user perform
|
|
19
|
+
actions. You can use search_docs tool to learn about how to take action with this server. Then,
|
|
20
|
+
you will write TypeScript code using the execute tool take action. It is CRITICAL that you be
|
|
21
|
+
thoughtful and deliberate when executing code. Always try to entirely solve the problem in code
|
|
22
|
+
block: it can be as long as you need to get the job done!
|
|
23
|
+
`;
|
|
24
|
+
}
|
|
25
|
+
instructions ??= (await response.json()).instructions;
|
|
26
|
+
instructions = `
|
|
27
|
+
The current time in Unix timestamps is ${Date.now()}.
|
|
28
|
+
|
|
29
|
+
${instructions}
|
|
30
|
+
`;
|
|
31
|
+
return instructions;
|
|
32
|
+
}
|
|
33
|
+
export const newMcpServer = async () => new McpServer({
|
|
8
34
|
name: 'cjavdev_believe_api',
|
|
9
|
-
version: '0.
|
|
10
|
-
}, {
|
|
11
|
-
|
|
12
|
-
|
|
35
|
+
version: '0.6.0',
|
|
36
|
+
}, {
|
|
37
|
+
instructions: await getInstructions(),
|
|
38
|
+
capabilities: { tools: {}, logging: {} },
|
|
39
|
+
});
|
|
13
40
|
/**
|
|
14
41
|
* Initializes the provided MCP Server with the given tools and handlers.
|
|
15
42
|
* If not provided, the default client, tools and handlers will be used.
|
|
16
43
|
*/
|
|
17
|
-
export function initMcpServer(params) {
|
|
44
|
+
export async function initMcpServer(params) {
|
|
18
45
|
const server = params.server instanceof McpServer ? params.server.server : params.server;
|
|
19
46
|
const logAtLevel = (level) => (message, ...rest) => {
|
|
20
47
|
void server.sendLoggingMessage({
|
package/server.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.mjs","sourceRoot":"","sources":["src/server.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAG/E,EAAE,SAAS,EAAE,MAAM,yCAAyC;OAC5D,EACL,qBAAqB,EACrB,sBAAsB,EACtB,qBAAqB,GACtB,MAAM,oCAAoC;OAEpC,OAAO,MAAM,kBAAkB;OAC/B,EAAE,QAAQ,EAAE;OACZ,cAAc;AAOrB,MAAM,CAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"server.mjs","sourceRoot":"","sources":["src/server.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAG/E,EAAE,SAAS,EAAE,MAAM,yCAAyC;OAC5D,EACL,qBAAqB,EACrB,sBAAsB,EACtB,qBAAqB,GACtB,MAAM,oCAAoC;OAEpC,OAAO,MAAM,kBAAkB;OAC/B,EAAE,QAAQ,EAAE;OACZ,cAAc;AAOrB,KAAK,UAAU,eAAe;IAC5B,0GAA0G;IAC1G,MAAM,eAAe,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;I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,OAAwB,EACxB,MAAe,EACf,IAAyC;IAEzC,OAAO,MAAM,OAAO,CAAC,MAAM,EAAE,IAAI,IAAI,EAAE,CAAC,CAAC;AAC3C,CAAC;AAED,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,GAAW,EAAsB,EAAE;IACzD,IAAI,OAAQ,UAAkB,CAAC,OAAO,KAAK,WAAW,EAAE,CAAC;QACvD,OAAQ,UAAkB,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,CAAC;IACxD,CAAC;SAAM,IAAI,OAAQ,UAAkB,CAAC,IAAI,KAAK,WAAW,EAAE,CAAC;QAC3D,OAAQ,UAAkB,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,CAAC;IAC1D,CAAC;IACD,OAAO;AACT,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,GAAW,EAAU,EAAE;IACpD,IAAI,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;IAC5B,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;QAC3B,MAAM,IAAI,KAAK,CAAC,wBAAwB,GAAG,aAAa,CAAC,CAAC;IAC5D,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,YAAY,GAAG,CAAI,KAAoB,EAAE,WAAmB,EAAK,EAAE;IAC9E,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,MAAM,IAAI,KAAK,CAAC,2BAA2B,WAAW,EAAE,CAAC,CAAC;IAC5D,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC,CAAC"}
|
package/src/http.ts
CHANGED
|
@@ -4,11 +4,12 @@ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp';
|
|
|
4
4
|
import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';
|
|
5
5
|
import express from 'express';
|
|
6
6
|
import morgan from 'morgan';
|
|
7
|
+
import morganBody from 'morgan-body';
|
|
7
8
|
import { McpOptions } from './options';
|
|
8
9
|
import { ClientOptions, initMcpServer, newMcpServer } from './server';
|
|
9
10
|
import { parseAuthHeaders } from './headers';
|
|
10
11
|
|
|
11
|
-
const newServer = ({
|
|
12
|
+
const newServer = async ({
|
|
12
13
|
clientOptions,
|
|
13
14
|
req,
|
|
14
15
|
res,
|
|
@@ -16,12 +17,12 @@ const newServer = ({
|
|
|
16
17
|
clientOptions: ClientOptions;
|
|
17
18
|
req: express.Request;
|
|
18
19
|
res: express.Response;
|
|
19
|
-
}): McpServer | null => {
|
|
20
|
-
const server = newMcpServer();
|
|
20
|
+
}): Promise<McpServer | null> => {
|
|
21
|
+
const server = await newMcpServer();
|
|
21
22
|
|
|
22
23
|
try {
|
|
23
24
|
const authOptions = parseAuthHeaders(req, false);
|
|
24
|
-
initMcpServer({
|
|
25
|
+
await initMcpServer({
|
|
25
26
|
server: server,
|
|
26
27
|
clientOptions: {
|
|
27
28
|
...clientOptions,
|
|
@@ -45,7 +46,7 @@ const newServer = ({
|
|
|
45
46
|
const post =
|
|
46
47
|
(options: { clientOptions: ClientOptions; mcpOptions: McpOptions }) =>
|
|
47
48
|
async (req: express.Request, res: express.Response) => {
|
|
48
|
-
const server = newServer({ ...options, req, res });
|
|
49
|
+
const server = await newServer({ ...options, req, res });
|
|
49
50
|
// If we return null, we already set the authorization error.
|
|
50
51
|
if (server === null) return;
|
|
51
52
|
const transport = new StreamableHTTPServerTransport();
|
|
@@ -76,14 +77,26 @@ const del = async (req: express.Request, res: express.Response) => {
|
|
|
76
77
|
export const streamableHTTPApp = ({
|
|
77
78
|
clientOptions = {},
|
|
78
79
|
mcpOptions,
|
|
80
|
+
debug,
|
|
79
81
|
}: {
|
|
80
82
|
clientOptions?: ClientOptions;
|
|
81
83
|
mcpOptions: McpOptions;
|
|
84
|
+
debug: boolean;
|
|
82
85
|
}): express.Express => {
|
|
83
86
|
const app = express();
|
|
84
87
|
app.set('query parser', 'extended');
|
|
85
88
|
app.use(express.json());
|
|
86
|
-
|
|
89
|
+
|
|
90
|
+
if (debug) {
|
|
91
|
+
morganBody(app, {
|
|
92
|
+
logAllReqHeader: true,
|
|
93
|
+
logAllResHeader: true,
|
|
94
|
+
logRequestBody: true,
|
|
95
|
+
logResponseBody: true,
|
|
96
|
+
});
|
|
97
|
+
} else {
|
|
98
|
+
app.use(morgan('combined'));
|
|
99
|
+
}
|
|
87
100
|
|
|
88
101
|
app.get('/', get);
|
|
89
102
|
app.post('/', post({ clientOptions, mcpOptions }));
|
|
@@ -92,9 +105,13 @@ export const streamableHTTPApp = ({
|
|
|
92
105
|
return app;
|
|
93
106
|
};
|
|
94
107
|
|
|
95
|
-
export const launchStreamableHTTPServer = async (
|
|
96
|
-
|
|
97
|
-
|
|
108
|
+
export const launchStreamableHTTPServer = async (params: {
|
|
109
|
+
mcpOptions: McpOptions;
|
|
110
|
+
debug: boolean;
|
|
111
|
+
port: number | string | undefined;
|
|
112
|
+
}) => {
|
|
113
|
+
const app = streamableHTTPApp({ mcpOptions: params.mcpOptions, debug: params.debug });
|
|
114
|
+
const server = app.listen(params.port);
|
|
98
115
|
const address = server.address();
|
|
99
116
|
|
|
100
117
|
if (typeof address === 'string') {
|
|
@@ -102,6 +119,6 @@ export const launchStreamableHTTPServer = async (options: McpOptions, port: numb
|
|
|
102
119
|
} else if (address !== null) {
|
|
103
120
|
console.error(`MCP Server running on streamable HTTP on port ${address.port}`);
|
|
104
121
|
} else {
|
|
105
|
-
console.error(`MCP Server running on streamable HTTP on port ${port}`);
|
|
122
|
+
console.error(`MCP Server running on streamable HTTP on port ${params.port}`);
|
|
106
123
|
}
|
|
107
124
|
};
|
package/src/index.ts
CHANGED
|
@@ -21,7 +21,11 @@ async function main() {
|
|
|
21
21
|
await launchStdioServer();
|
|
22
22
|
break;
|
|
23
23
|
case 'http':
|
|
24
|
-
await launchStreamableHTTPServer(
|
|
24
|
+
await launchStreamableHTTPServer({
|
|
25
|
+
mcpOptions: options,
|
|
26
|
+
debug: options.debug,
|
|
27
|
+
port: options.port ?? options.socket,
|
|
28
|
+
});
|
|
25
29
|
break;
|
|
26
30
|
}
|
|
27
31
|
}
|
package/src/options.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { hideBin } from 'yargs/helpers';
|
|
|
4
4
|
import z from 'zod';
|
|
5
5
|
|
|
6
6
|
export type CLIOptions = McpOptions & {
|
|
7
|
+
debug: boolean;
|
|
7
8
|
transport: 'stdio' | 'http';
|
|
8
9
|
port: number | undefined;
|
|
9
10
|
socket: string | undefined;
|
|
@@ -15,17 +16,24 @@ export type McpOptions = {
|
|
|
15
16
|
|
|
16
17
|
export function parseCLIOptions(): CLIOptions {
|
|
17
18
|
const opts = yargs(hideBin(process.argv))
|
|
18
|
-
.option('
|
|
19
|
+
.option('debug', { type: 'boolean', description: 'Enable debug logging' })
|
|
20
|
+
.option('no-tools', {
|
|
19
21
|
type: 'string',
|
|
20
22
|
array: true,
|
|
21
23
|
choices: ['code', 'docs'],
|
|
22
|
-
description: '
|
|
24
|
+
description: 'Tools to explicitly disable',
|
|
23
25
|
})
|
|
24
|
-
.option('
|
|
26
|
+
.option('port', {
|
|
27
|
+
type: 'number',
|
|
28
|
+
default: 3000,
|
|
29
|
+
description: 'Port to serve on if using http transport',
|
|
30
|
+
})
|
|
31
|
+
.option('socket', { type: 'string', description: 'Unix socket to serve on if using http transport' })
|
|
32
|
+
.option('tools', {
|
|
25
33
|
type: 'string',
|
|
26
34
|
array: true,
|
|
27
35
|
choices: ['code', 'docs'],
|
|
28
|
-
description: '
|
|
36
|
+
description: 'Tools to explicitly enable',
|
|
29
37
|
})
|
|
30
38
|
.option('transport', {
|
|
31
39
|
type: 'string',
|
|
@@ -33,15 +41,8 @@ export function parseCLIOptions(): CLIOptions {
|
|
|
33
41
|
default: 'stdio',
|
|
34
42
|
description: 'What transport to use; stdio for local servers or http for remote servers',
|
|
35
43
|
})
|
|
36
|
-
.
|
|
37
|
-
|
|
38
|
-
default: 3000,
|
|
39
|
-
description: 'Port to serve on if using http transport',
|
|
40
|
-
})
|
|
41
|
-
.option('socket', {
|
|
42
|
-
type: 'string',
|
|
43
|
-
description: 'Unix socket to serve on if using http transport',
|
|
44
|
-
})
|
|
44
|
+
.env('MCP_SERVER')
|
|
45
|
+
.version(true)
|
|
45
46
|
.help();
|
|
46
47
|
|
|
47
48
|
const argv = opts.parseSync();
|
|
@@ -57,6 +58,7 @@ export function parseCLIOptions(): CLIOptions {
|
|
|
57
58
|
|
|
58
59
|
return {
|
|
59
60
|
...(includeDocsTools !== undefined && { includeDocsTools }),
|
|
61
|
+
debug: !!argv.debug,
|
|
60
62
|
transport,
|
|
61
63
|
port: argv.port,
|
|
62
64
|
socket: argv.socket,
|
package/src/server.ts
CHANGED
|
@@ -17,23 +17,59 @@ import { HandlerFunction, McpTool } from './types';
|
|
|
17
17
|
export { McpOptions } from './options';
|
|
18
18
|
export { ClientOptions } from '@cjavdev/believe';
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
async function getInstructions() {
|
|
21
|
+
// This API key is optional; providing it allows the server to fetch instructions for unreleased versions.
|
|
22
|
+
const stainlessAPIKey = readEnv('STAINLESS_API_KEY');
|
|
23
|
+
const response = await fetch(
|
|
24
|
+
readEnv('CODE_MODE_INSTRUCTIONS_URL') ?? 'https://api.stainless.com/api/ai/instructions/believe',
|
|
25
|
+
{
|
|
26
|
+
method: 'GET',
|
|
27
|
+
headers: { ...(stainlessAPIKey && { Authorization: stainlessAPIKey }) },
|
|
28
|
+
},
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
let instructions: string | undefined;
|
|
32
|
+
if (!response.ok) {
|
|
33
|
+
console.warn(
|
|
34
|
+
'Warning: failed to retrieve MCP server instructions. Proceeding with default instructions...',
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
instructions = `
|
|
38
|
+
This is the believe MCP server. You will use Code Mode to help the user perform
|
|
39
|
+
actions. You can use search_docs tool to learn about how to take action with this server. Then,
|
|
40
|
+
you will write TypeScript code using the execute tool take action. It is CRITICAL that you be
|
|
41
|
+
thoughtful and deliberate when executing code. Always try to entirely solve the problem in code
|
|
42
|
+
block: it can be as long as you need to get the job done!
|
|
43
|
+
`;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
instructions ??= ((await response.json()) as { instructions: string }).instructions;
|
|
47
|
+
instructions = `
|
|
48
|
+
The current time in Unix timestamps is ${Date.now()}.
|
|
49
|
+
|
|
50
|
+
${instructions}
|
|
51
|
+
`;
|
|
52
|
+
|
|
53
|
+
return instructions;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export const newMcpServer = async () =>
|
|
21
57
|
new McpServer(
|
|
22
58
|
{
|
|
23
59
|
name: 'cjavdev_believe_api',
|
|
24
|
-
version: '0.
|
|
60
|
+
version: '0.6.0',
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
instructions: await getInstructions(),
|
|
64
|
+
capabilities: { tools: {}, logging: {} },
|
|
25
65
|
},
|
|
26
|
-
{ capabilities: { tools: {}, logging: {} } },
|
|
27
66
|
);
|
|
28
67
|
|
|
29
|
-
// Create server instance
|
|
30
|
-
export const server = newMcpServer();
|
|
31
|
-
|
|
32
68
|
/**
|
|
33
69
|
* Initializes the provided MCP Server with the given tools and handlers.
|
|
34
70
|
* If not provided, the default client, tools and handlers will be used.
|
|
35
71
|
*/
|
|
36
|
-
export function initMcpServer(params: {
|
|
72
|
+
export async function initMcpServer(params: {
|
|
37
73
|
server: Server | McpServer;
|
|
38
74
|
clientOptions?: ClientOptions;
|
|
39
75
|
mcpOptions?: McpOptions;
|
package/src/stdio.ts
CHANGED
|
@@ -2,9 +2,9 @@ import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'
|
|
|
2
2
|
import { initMcpServer, newMcpServer } from './server';
|
|
3
3
|
|
|
4
4
|
export const launchStdioServer = async () => {
|
|
5
|
-
const server = newMcpServer();
|
|
5
|
+
const server = await newMcpServer();
|
|
6
6
|
|
|
7
|
-
initMcpServer({ server });
|
|
7
|
+
await initMcpServer({ server });
|
|
8
8
|
|
|
9
9
|
const transport = new StdioServerTransport();
|
|
10
10
|
await server.connect(transport);
|
package/stdio.js
CHANGED
|
@@ -4,8 +4,8 @@ exports.launchStdioServer = void 0;
|
|
|
4
4
|
const stdio_js_1 = require("@modelcontextprotocol/sdk/server/stdio.js");
|
|
5
5
|
const server_1 = require("./server.js");
|
|
6
6
|
const launchStdioServer = async () => {
|
|
7
|
-
const server = (0, server_1.newMcpServer)();
|
|
8
|
-
(0, server_1.initMcpServer)({ server });
|
|
7
|
+
const server = await (0, server_1.newMcpServer)();
|
|
8
|
+
await (0, server_1.initMcpServer)({ server });
|
|
9
9
|
const transport = new stdio_js_1.StdioServerTransport();
|
|
10
10
|
await server.connect(transport);
|
|
11
11
|
console.error('MCP Server running on stdio');
|
package/stdio.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stdio.js","sourceRoot":"","sources":["src/stdio.ts"],"names":[],"mappings":";;;AAAA,wEAAiF;AACjF,wCAAuD;AAEhD,MAAM,iBAAiB,GAAG,KAAK,IAAI,EAAE;IAC1C,MAAM,MAAM,GAAG,IAAA,qBAAY,GAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"stdio.js","sourceRoot":"","sources":["src/stdio.ts"],"names":[],"mappings":";;;AAAA,wEAAiF;AACjF,wCAAuD;AAEhD,MAAM,iBAAiB,GAAG,KAAK,IAAI,EAAE;IAC1C,MAAM,MAAM,GAAG,MAAM,IAAA,qBAAY,GAAE,CAAC;IAEpC,MAAM,IAAA,sBAAa,EAAC,EAAE,MAAM,EAAE,CAAC,CAAC;IAEhC,MAAM,SAAS,GAAG,IAAI,+BAAoB,EAAE,CAAC;IAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAChC,OAAO,CAAC,KAAK,CAAC,6BAA6B,CAAC,CAAC;AAC/C,CAAC,CAAC;AARW,QAAA,iBAAiB,qBAQ5B"}
|
package/stdio.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
2
2
|
import { initMcpServer, newMcpServer } from "./server.mjs";
|
|
3
3
|
export const launchStdioServer = async () => {
|
|
4
|
-
const server = newMcpServer();
|
|
5
|
-
initMcpServer({ server });
|
|
4
|
+
const server = await newMcpServer();
|
|
5
|
+
await initMcpServer({ server });
|
|
6
6
|
const transport = new StdioServerTransport();
|
|
7
7
|
await server.connect(transport);
|
|
8
8
|
console.error('MCP Server running on stdio');
|
package/stdio.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stdio.mjs","sourceRoot":"","sources":["src/stdio.ts"],"names":[],"mappings":"OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C;OACzE,EAAE,aAAa,EAAE,YAAY,EAAE;AAEtC,MAAM,CAAC,MAAM,iBAAiB,GAAG,KAAK,IAAI,EAAE;IAC1C,MAAM,MAAM,GAAG,YAAY,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"stdio.mjs","sourceRoot":"","sources":["src/stdio.ts"],"names":[],"mappings":"OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C;OACzE,EAAE,aAAa,EAAE,YAAY,EAAE;AAEtC,MAAM,CAAC,MAAM,iBAAiB,GAAG,KAAK,IAAI,EAAE;IAC1C,MAAM,MAAM,GAAG,MAAM,YAAY,EAAE,CAAC;IAEpC,MAAM,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;IAEhC,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;IAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAChC,OAAO,CAAC,KAAK,CAAC,6BAA6B,CAAC,CAAC;AAC/C,CAAC,CAAC"}
|