@cjavdev/believe-mcp 0.14.0 → 0.15.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/code-tool.d.mts.map +1 -1
- package/code-tool.d.ts.map +1 -1
- package/code-tool.js +23 -5
- package/code-tool.js.map +1 -1
- package/code-tool.mjs +23 -5
- package/code-tool.mjs.map +1 -1
- package/docs-search-tool.d.mts +1 -1
- package/docs-search-tool.d.mts.map +1 -1
- package/docs-search-tool.d.ts +1 -1
- package/docs-search-tool.d.ts.map +1 -1
- package/docs-search-tool.js +21 -2
- package/docs-search-tool.js.map +1 -1
- package/docs-search-tool.mjs +21 -2
- package/docs-search-tool.mjs.map +1 -1
- package/http.d.mts +2 -4
- package/http.d.mts.map +1 -1
- package/http.d.ts +2 -4
- package/http.d.ts.map +1 -1
- package/http.js +52 -19
- package/http.js.map +1 -1
- package/http.mjs +52 -19
- package/http.mjs.map +1 -1
- package/index.js +12 -11
- package/index.js.map +1 -1
- package/index.mjs +12 -11
- package/index.mjs.map +1 -1
- package/instructions.d.mts.map +1 -1
- package/instructions.d.ts.map +1 -1
- package/instructions.js +2 -1
- package/instructions.js.map +1 -1
- package/instructions.mjs +2 -1
- package/instructions.mjs.map +1 -1
- package/logger.d.mts +7 -0
- package/logger.d.mts.map +1 -0
- package/logger.d.ts +7 -0
- package/logger.d.ts.map +1 -0
- package/logger.js +29 -0
- package/logger.js.map +1 -0
- package/logger.mjs +22 -0
- package/logger.mjs.map +1 -0
- 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 +9 -0
- package/options.js.map +1 -1
- package/options.mjs +9 -0
- package/options.mjs.map +1 -1
- package/package.json +15 -4
- package/server.js +1 -1
- package/server.mjs +1 -1
- package/src/code-tool.ts +31 -5
- package/src/docs-search-tool.ts +34 -3
- package/src/http.ts +53 -21
- package/src/index.ts +14 -12
- package/src/instructions.ts +2 -1
- package/src/logger.ts +28 -0
- package/src/options.ts +11 -0
- package/src/server.ts +1 -1
- package/src/stdio.ts +2 -1
- package/stdio.d.mts.map +1 -1
- package/stdio.d.ts.map +1 -1
- package/stdio.js +2 -1
- package/stdio.js.map +1 -1
- package/stdio.mjs +2 -1
- package/stdio.mjs.map +1 -1
package/server.mjs
CHANGED
|
@@ -8,7 +8,7 @@ import { getInstructions } from "./instructions.mjs";
|
|
|
8
8
|
import { blockedMethodsForCodeTool } from "./methods.mjs";
|
|
9
9
|
export const newMcpServer = async (stainlessApiKey) => new McpServer({
|
|
10
10
|
name: 'cjavdev_believe_api',
|
|
11
|
-
version: '0.
|
|
11
|
+
version: '0.15.0',
|
|
12
12
|
}, {
|
|
13
13
|
instructions: await getInstructions(stainlessApiKey),
|
|
14
14
|
capabilities: { tools: {}, logging: {} },
|
package/src/code-tool.ts
CHANGED
|
@@ -17,13 +17,14 @@ import {
|
|
|
17
17
|
import { Tool } from '@modelcontextprotocol/sdk/types.js';
|
|
18
18
|
import { readEnv, requireValue } from './util';
|
|
19
19
|
import { WorkerInput, WorkerOutput } from './code-tool-types';
|
|
20
|
+
import { getLogger } from './logger';
|
|
20
21
|
import { SdkMethod } from './methods';
|
|
21
22
|
import { McpCodeExecutionMode } from './options';
|
|
22
23
|
import { ClientOptions } from '@cjavdev/believe';
|
|
23
24
|
|
|
24
25
|
const prompt = `Runs JavaScript code to interact with the Believe API.
|
|
25
26
|
|
|
26
|
-
You are a skilled programmer writing code to interface with the service.
|
|
27
|
+
You are a skilled TypeScript programmer writing code to interface with the service.
|
|
27
28
|
Define an async function named "run" that takes a single parameter of an initialized SDK client and it will be run.
|
|
28
29
|
For example:
|
|
29
30
|
|
|
@@ -40,7 +41,9 @@ You will be returned anything that your function returns, plus the results of an
|
|
|
40
41
|
Do not add try-catch blocks for single API calls. The tool will handle errors for you.
|
|
41
42
|
Do not add comments unless necessary for generating better code.
|
|
42
43
|
Code will run in a container, and cannot interact with the network outside of the given SDK client.
|
|
43
|
-
Variables will not persist between calls, so make sure to return or log any data you might need later
|
|
44
|
+
Variables will not persist between calls, so make sure to return or log any data you might need later.
|
|
45
|
+
Remember that you are writing TypeScript code, so you need to be careful with your types.
|
|
46
|
+
Always type dynamic key-value stores explicitly as Record<string, YourValueType> instead of {}.`;
|
|
44
47
|
|
|
45
48
|
/**
|
|
46
49
|
* A tool that runs code against a copy of the SDK.
|
|
@@ -82,6 +85,8 @@ export function codeTool({
|
|
|
82
85
|
},
|
|
83
86
|
};
|
|
84
87
|
|
|
88
|
+
const logger = getLogger();
|
|
89
|
+
|
|
85
90
|
const handler = async ({
|
|
86
91
|
reqContext,
|
|
87
92
|
args,
|
|
@@ -106,11 +111,27 @@ export function codeTool({
|
|
|
106
111
|
}
|
|
107
112
|
}
|
|
108
113
|
|
|
114
|
+
let result: ToolCallResult;
|
|
115
|
+
const startTime = Date.now();
|
|
116
|
+
|
|
109
117
|
if (codeExecutionMode === 'local') {
|
|
110
|
-
|
|
118
|
+
logger.debug('Executing code in local Deno environment');
|
|
119
|
+
result = await localDenoHandler({ reqContext, args });
|
|
111
120
|
} else {
|
|
112
|
-
|
|
121
|
+
logger.debug('Executing code in remote Stainless environment');
|
|
122
|
+
result = await remoteStainlessHandler({ reqContext, args });
|
|
113
123
|
}
|
|
124
|
+
|
|
125
|
+
logger.info(
|
|
126
|
+
{
|
|
127
|
+
codeExecutionMode,
|
|
128
|
+
durationMs: Date.now() - startTime,
|
|
129
|
+
isError: result.isError,
|
|
130
|
+
contentRows: result.content?.length ?? 0,
|
|
131
|
+
},
|
|
132
|
+
'Got code tool execution result',
|
|
133
|
+
);
|
|
134
|
+
return result;
|
|
114
135
|
};
|
|
115
136
|
|
|
116
137
|
return { metadata, tool, handler };
|
|
@@ -135,7 +156,7 @@ const remoteStainlessHandler = async ({
|
|
|
135
156
|
headers: {
|
|
136
157
|
...(reqContext.stainlessApiKey && { Authorization: reqContext.stainlessApiKey }),
|
|
137
158
|
'Content-Type': 'application/json',
|
|
138
|
-
|
|
159
|
+
'x-stainless-mcp-client-envs': JSON.stringify({
|
|
139
160
|
BELIEVE_API_KEY: requireValue(
|
|
140
161
|
readEnv('BELIEVE_API_KEY') ?? client.apiKey,
|
|
141
162
|
'set BELIEVE_API_KEY environment variable or provide apiKey client option',
|
|
@@ -152,6 +173,11 @@ const remoteStainlessHandler = async ({
|
|
|
152
173
|
});
|
|
153
174
|
|
|
154
175
|
if (!res.ok) {
|
|
176
|
+
if (res.status === 404 && !reqContext.stainlessApiKey) {
|
|
177
|
+
throw new Error(
|
|
178
|
+
'Could not access code tool for this project. You may need to provide a Stainless API key via the STAINLESS_API_KEY environment variable, the --stainless-api-key flag, or the x-stainless-api-key HTTP header.',
|
|
179
|
+
);
|
|
180
|
+
}
|
|
155
181
|
throw new Error(
|
|
156
182
|
`${res.status}: ${
|
|
157
183
|
res.statusText
|
package/src/docs-search-tool.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
2
|
|
|
3
|
-
import { Metadata, McpRequestContext, asTextContentResult } from './types';
|
|
4
3
|
import { Tool } from '@modelcontextprotocol/sdk/types.js';
|
|
4
|
+
import { Metadata, McpRequestContext, asTextContentResult } from './types';
|
|
5
|
+
import { getLogger } from './logger';
|
|
5
6
|
|
|
6
7
|
export const metadata: Metadata = {
|
|
7
8
|
resource: 'all',
|
|
@@ -50,19 +51,49 @@ export const handler = async ({
|
|
|
50
51
|
}) => {
|
|
51
52
|
const body = args as any;
|
|
52
53
|
const query = new URLSearchParams(body).toString();
|
|
54
|
+
|
|
55
|
+
const startTime = Date.now();
|
|
53
56
|
const result = await fetch(`${docsSearchURL}?${query}`, {
|
|
54
57
|
headers: {
|
|
55
58
|
...(reqContext.stainlessApiKey && { Authorization: reqContext.stainlessApiKey }),
|
|
56
59
|
},
|
|
57
60
|
});
|
|
58
61
|
|
|
62
|
+
const logger = getLogger();
|
|
63
|
+
|
|
59
64
|
if (!result.ok) {
|
|
65
|
+
const errorText = await result.text();
|
|
66
|
+
logger.warn(
|
|
67
|
+
{
|
|
68
|
+
durationMs: Date.now() - startTime,
|
|
69
|
+
query: body.query,
|
|
70
|
+
status: result.status,
|
|
71
|
+
statusText: result.statusText,
|
|
72
|
+
errorText,
|
|
73
|
+
},
|
|
74
|
+
'Got error response from docs search tool',
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
if (result.status === 404 && !reqContext.stainlessApiKey) {
|
|
78
|
+
throw new Error(
|
|
79
|
+
'Could not find docs for this project. You may need to provide a Stainless API key via the STAINLESS_API_KEY environment variable, the --stainless-api-key flag, or the x-stainless-api-key HTTP header.',
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
|
|
60
83
|
throw new Error(
|
|
61
|
-
`${result.status}: ${result.statusText} when using doc search tool. Details: ${
|
|
84
|
+
`${result.status}: ${result.statusText} when using doc search tool. Details: ${errorText}`,
|
|
62
85
|
);
|
|
63
86
|
}
|
|
64
87
|
|
|
65
|
-
|
|
88
|
+
const resultBody = await result.json();
|
|
89
|
+
logger.info(
|
|
90
|
+
{
|
|
91
|
+
durationMs: Date.now() - startTime,
|
|
92
|
+
query: body.query,
|
|
93
|
+
},
|
|
94
|
+
'Got docs search result',
|
|
95
|
+
);
|
|
96
|
+
return asTextContentResult(resultBody);
|
|
66
97
|
};
|
|
67
98
|
|
|
68
99
|
export default { metadata, tool, handler };
|
package/src/http.ts
CHANGED
|
@@ -4,9 +4,10 @@ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp';
|
|
|
4
4
|
import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';
|
|
5
5
|
import { ClientOptions } from '@cjavdev/believe';
|
|
6
6
|
import express from 'express';
|
|
7
|
-
import
|
|
8
|
-
import
|
|
7
|
+
import pino from 'pino';
|
|
8
|
+
import pinoHttp from 'pino-http';
|
|
9
9
|
import { getStainlessApiKey, parseClientAuthHeaders } from './auth';
|
|
10
|
+
import { getLogger } from './logger';
|
|
10
11
|
import { McpOptions } from './options';
|
|
11
12
|
import { initMcpServer, newMcpServer } from './server';
|
|
12
13
|
|
|
@@ -70,29 +71,60 @@ const del = async (req: express.Request, res: express.Response) => {
|
|
|
70
71
|
});
|
|
71
72
|
};
|
|
72
73
|
|
|
74
|
+
const redactHeaders = (headers: Record<string, any>) => {
|
|
75
|
+
const hiddenHeaders = /auth|cookie|key|token/i;
|
|
76
|
+
const filtered = { ...headers };
|
|
77
|
+
Object.keys(filtered).forEach((key) => {
|
|
78
|
+
if (hiddenHeaders.test(key)) {
|
|
79
|
+
filtered[key] = '[REDACTED]';
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
return filtered;
|
|
83
|
+
};
|
|
84
|
+
|
|
73
85
|
export const streamableHTTPApp = ({
|
|
74
86
|
clientOptions = {},
|
|
75
87
|
mcpOptions,
|
|
76
|
-
debug,
|
|
77
88
|
}: {
|
|
78
89
|
clientOptions?: ClientOptions;
|
|
79
90
|
mcpOptions: McpOptions;
|
|
80
|
-
debug: boolean;
|
|
81
91
|
}): express.Express => {
|
|
82
92
|
const app = express();
|
|
83
93
|
app.set('query parser', 'extended');
|
|
84
94
|
app.use(express.json());
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
95
|
+
app.use(
|
|
96
|
+
pinoHttp({
|
|
97
|
+
logger: getLogger(),
|
|
98
|
+
customLogLevel: (req, res) => {
|
|
99
|
+
if (res.statusCode >= 500) {
|
|
100
|
+
return 'error';
|
|
101
|
+
} else if (res.statusCode >= 400) {
|
|
102
|
+
return 'warn';
|
|
103
|
+
}
|
|
104
|
+
return 'info';
|
|
105
|
+
},
|
|
106
|
+
customSuccessMessage: function (req, res) {
|
|
107
|
+
return `Request ${req.method} to ${req.url} completed with status ${res.statusCode}`;
|
|
108
|
+
},
|
|
109
|
+
customErrorMessage: function (req, res, err) {
|
|
110
|
+
return `Request ${req.method} to ${req.url} errored with status ${res.statusCode}`;
|
|
111
|
+
},
|
|
112
|
+
serializers: {
|
|
113
|
+
req: pino.stdSerializers.wrapRequestSerializer((req) => {
|
|
114
|
+
return {
|
|
115
|
+
...req,
|
|
116
|
+
headers: redactHeaders(req.raw.headers),
|
|
117
|
+
};
|
|
118
|
+
}),
|
|
119
|
+
res: pino.stdSerializers.wrapResponseSerializer((res) => {
|
|
120
|
+
return {
|
|
121
|
+
...res,
|
|
122
|
+
headers: redactHeaders(res.headers),
|
|
123
|
+
};
|
|
124
|
+
}),
|
|
125
|
+
},
|
|
126
|
+
}),
|
|
127
|
+
);
|
|
96
128
|
|
|
97
129
|
app.get('/health', async (req: express.Request, res: express.Response) => {
|
|
98
130
|
res.status(200).send('OK');
|
|
@@ -106,22 +138,22 @@ export const streamableHTTPApp = ({
|
|
|
106
138
|
|
|
107
139
|
export const launchStreamableHTTPServer = async ({
|
|
108
140
|
mcpOptions,
|
|
109
|
-
debug,
|
|
110
141
|
port,
|
|
111
142
|
}: {
|
|
112
143
|
mcpOptions: McpOptions;
|
|
113
|
-
debug: boolean;
|
|
114
144
|
port: number | string | undefined;
|
|
115
145
|
}) => {
|
|
116
|
-
const app = streamableHTTPApp({ mcpOptions
|
|
146
|
+
const app = streamableHTTPApp({ mcpOptions });
|
|
117
147
|
const server = app.listen(port);
|
|
118
148
|
const address = server.address();
|
|
119
149
|
|
|
150
|
+
const logger = getLogger();
|
|
151
|
+
|
|
120
152
|
if (typeof address === 'string') {
|
|
121
|
-
|
|
153
|
+
logger.info(`MCP Server running on streamable HTTP at ${address}`);
|
|
122
154
|
} else if (address !== null) {
|
|
123
|
-
|
|
155
|
+
logger.info(`MCP Server running on streamable HTTP on port ${address.port}`);
|
|
124
156
|
} else {
|
|
125
|
-
|
|
157
|
+
logger.info(`MCP Server running on streamable HTTP on port ${port}`);
|
|
126
158
|
}
|
|
127
159
|
};
|
package/src/index.ts
CHANGED
|
@@ -5,15 +5,20 @@ import { McpOptions, parseCLIOptions } from './options';
|
|
|
5
5
|
import { launchStdioServer } from './stdio';
|
|
6
6
|
import { launchStreamableHTTPServer } from './http';
|
|
7
7
|
import type { McpTool } from './types';
|
|
8
|
+
import { configureLogger, getLogger } from './logger';
|
|
8
9
|
|
|
9
10
|
async function main() {
|
|
10
11
|
const options = parseOptionsOrError();
|
|
12
|
+
configureLogger({
|
|
13
|
+
level: options.debug ? 'debug' : 'info',
|
|
14
|
+
pretty: options.logFormat === 'pretty',
|
|
15
|
+
});
|
|
11
16
|
|
|
12
17
|
const selectedTools = await selectToolsOrError(options);
|
|
13
18
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
selectedTools.
|
|
19
|
+
getLogger().info(
|
|
20
|
+
{ tools: selectedTools.map((e) => e.tool.name) },
|
|
21
|
+
`MCP Server starting with ${selectedTools.length} tools`,
|
|
17
22
|
);
|
|
18
23
|
|
|
19
24
|
switch (options.transport) {
|
|
@@ -23,7 +28,6 @@ async function main() {
|
|
|
23
28
|
case 'http':
|
|
24
29
|
await launchStreamableHTTPServer({
|
|
25
30
|
mcpOptions: options,
|
|
26
|
-
debug: options.debug,
|
|
27
31
|
port: options.socket ?? options.port,
|
|
28
32
|
});
|
|
29
33
|
break;
|
|
@@ -32,7 +36,8 @@ async function main() {
|
|
|
32
36
|
|
|
33
37
|
if (require.main === module) {
|
|
34
38
|
main().catch((error) => {
|
|
35
|
-
|
|
39
|
+
// Logger might not be initialized yet
|
|
40
|
+
console.error('Fatal error in main()', error);
|
|
36
41
|
process.exit(1);
|
|
37
42
|
});
|
|
38
43
|
}
|
|
@@ -41,7 +46,8 @@ function parseOptionsOrError() {
|
|
|
41
46
|
try {
|
|
42
47
|
return parseCLIOptions();
|
|
43
48
|
} catch (error) {
|
|
44
|
-
|
|
49
|
+
// Logger is initialized after options, so use console.error here
|
|
50
|
+
console.error('Error parsing options', error);
|
|
45
51
|
process.exit(1);
|
|
46
52
|
}
|
|
47
53
|
}
|
|
@@ -50,16 +56,12 @@ async function selectToolsOrError(options: McpOptions): Promise<McpTool[]> {
|
|
|
50
56
|
try {
|
|
51
57
|
const includedTools = selectTools(options);
|
|
52
58
|
if (includedTools.length === 0) {
|
|
53
|
-
|
|
59
|
+
getLogger().error('No tools match the provided filters');
|
|
54
60
|
process.exit(1);
|
|
55
61
|
}
|
|
56
62
|
return includedTools;
|
|
57
63
|
} catch (error) {
|
|
58
|
-
|
|
59
|
-
console.error('Error filtering tools:', error.message);
|
|
60
|
-
} else {
|
|
61
|
-
console.error('Error filtering tools:', error);
|
|
62
|
-
}
|
|
64
|
+
getLogger().error({ error }, 'Error filtering tools');
|
|
63
65
|
process.exit(1);
|
|
64
66
|
}
|
|
65
67
|
}
|
package/src/instructions.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
2
|
|
|
3
3
|
import { readEnv } from './util';
|
|
4
|
+
import { getLogger } from './logger';
|
|
4
5
|
|
|
5
6
|
const INSTRUCTIONS_CACHE_TTL_MS = 15 * 60 * 1000; // 15 minutes
|
|
6
7
|
|
|
@@ -50,7 +51,7 @@ async function fetchLatestInstructions(stainlessApiKey: string | undefined): Pro
|
|
|
50
51
|
|
|
51
52
|
let instructions: string | undefined;
|
|
52
53
|
if (!response.ok) {
|
|
53
|
-
|
|
54
|
+
getLogger().warn(
|
|
54
55
|
'Warning: failed to retrieve MCP server instructions. Proceeding with default instructions...',
|
|
55
56
|
);
|
|
56
57
|
|
package/src/logger.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
import { pino, type Level, type Logger } from 'pino';
|
|
4
|
+
import pretty from 'pino-pretty';
|
|
5
|
+
|
|
6
|
+
let _logger: Logger | undefined;
|
|
7
|
+
|
|
8
|
+
export function configureLogger({ level, pretty: usePretty }: { level: Level; pretty: boolean }): void {
|
|
9
|
+
_logger = pino(
|
|
10
|
+
{
|
|
11
|
+
level,
|
|
12
|
+
timestamp: pino.stdTimeFunctions.isoTime,
|
|
13
|
+
formatters: {
|
|
14
|
+
level(label) {
|
|
15
|
+
return { level: label };
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
usePretty ? pretty({ colorize: true, levelFirst: true, destination: 2 }) : process.stderr,
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function getLogger(): Logger {
|
|
24
|
+
if (!_logger) {
|
|
25
|
+
throw new Error('Logger has not been configured. Call configureLogger() before using the logger.');
|
|
26
|
+
}
|
|
27
|
+
return _logger;
|
|
28
|
+
}
|
package/src/options.ts
CHANGED
|
@@ -8,6 +8,7 @@ import { readEnv } from './util';
|
|
|
8
8
|
|
|
9
9
|
export type CLIOptions = McpOptions & {
|
|
10
10
|
debug: boolean;
|
|
11
|
+
logFormat: 'json' | 'pretty';
|
|
11
12
|
transport: 'stdio' | 'http';
|
|
12
13
|
port: number | undefined;
|
|
13
14
|
socket: string | undefined;
|
|
@@ -52,6 +53,11 @@ export function parseCLIOptions(): CLIOptions {
|
|
|
52
53
|
"Where to run code execution in code tool; 'stainless-sandbox' will execute code in Stainless-hosted sandboxes whereas 'local' will execute code locally on the MCP server machine.",
|
|
53
54
|
})
|
|
54
55
|
.option('debug', { type: 'boolean', description: 'Enable debug logging' })
|
|
56
|
+
.option('log-format', {
|
|
57
|
+
type: 'string',
|
|
58
|
+
choices: ['json', 'pretty'],
|
|
59
|
+
description: 'Format for log output; defaults to json unless tty is detected',
|
|
60
|
+
})
|
|
55
61
|
.option('no-tools', {
|
|
56
62
|
type: 'string',
|
|
57
63
|
array: true,
|
|
@@ -97,6 +103,10 @@ export function parseCLIOptions(): CLIOptions {
|
|
|
97
103
|
const includeDocsTools = shouldIncludeToolType('docs');
|
|
98
104
|
|
|
99
105
|
const transport = argv.transport as 'stdio' | 'http';
|
|
106
|
+
const logFormat =
|
|
107
|
+
argv.logFormat ? (argv.logFormat as 'json' | 'pretty')
|
|
108
|
+
: process.stderr.isTTY ? 'pretty'
|
|
109
|
+
: 'json';
|
|
100
110
|
|
|
101
111
|
return {
|
|
102
112
|
...(includeCodeTool !== undefined && { includeCodeTool }),
|
|
@@ -108,6 +118,7 @@ export function parseCLIOptions(): CLIOptions {
|
|
|
108
118
|
codeBlockedMethods: argv.codeBlockedMethods,
|
|
109
119
|
codeExecutionMode: argv.codeExecutionMode as McpCodeExecutionMode,
|
|
110
120
|
transport,
|
|
121
|
+
logFormat,
|
|
111
122
|
port: argv.port,
|
|
112
123
|
socket: argv.socket,
|
|
113
124
|
};
|
package/src/server.ts
CHANGED
package/src/stdio.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
2
2
|
import { McpOptions } from './options';
|
|
3
3
|
import { initMcpServer, newMcpServer } from './server';
|
|
4
|
+
import { getLogger } from './logger';
|
|
4
5
|
|
|
5
6
|
export const launchStdioServer = async (mcpOptions: McpOptions) => {
|
|
6
7
|
const server = await newMcpServer(mcpOptions.stainlessApiKey);
|
|
@@ -9,5 +10,5 @@ export const launchStdioServer = async (mcpOptions: McpOptions) => {
|
|
|
9
10
|
|
|
10
11
|
const transport = new StdioServerTransport();
|
|
11
12
|
await server.connect(transport);
|
|
12
|
-
|
|
13
|
+
getLogger().info('MCP Server running on stdio');
|
|
13
14
|
};
|
package/stdio.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stdio.d.mts","sourceRoot":"","sources":["src/stdio.ts"],"names":[],"mappings":"OACO,EAAE,UAAU,EAAE;
|
|
1
|
+
{"version":3,"file":"stdio.d.mts","sourceRoot":"","sources":["src/stdio.ts"],"names":[],"mappings":"OACO,EAAE,UAAU,EAAE;AAIrB,eAAO,MAAM,iBAAiB,GAAU,YAAY,UAAU,kBAQ7D,CAAC"}
|
package/stdio.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stdio.d.ts","sourceRoot":"","sources":["src/stdio.ts"],"names":[],"mappings":"OACO,EAAE,UAAU,EAAE;
|
|
1
|
+
{"version":3,"file":"stdio.d.ts","sourceRoot":"","sources":["src/stdio.ts"],"names":[],"mappings":"OACO,EAAE,UAAU,EAAE;AAIrB,eAAO,MAAM,iBAAiB,GAAU,YAAY,UAAU,kBAQ7D,CAAC"}
|
package/stdio.js
CHANGED
|
@@ -3,12 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
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
|
+
const logger_1 = require("./logger.js");
|
|
6
7
|
const launchStdioServer = async (mcpOptions) => {
|
|
7
8
|
const server = await (0, server_1.newMcpServer)(mcpOptions.stainlessApiKey);
|
|
8
9
|
await (0, server_1.initMcpServer)({ server, mcpOptions, stainlessApiKey: mcpOptions.stainlessApiKey });
|
|
9
10
|
const transport = new stdio_js_1.StdioServerTransport();
|
|
10
11
|
await server.connect(transport);
|
|
11
|
-
|
|
12
|
+
(0, logger_1.getLogger)().info('MCP Server running on stdio');
|
|
12
13
|
};
|
|
13
14
|
exports.launchStdioServer = launchStdioServer;
|
|
14
15
|
//# sourceMappingURL=stdio.js.map
|
package/stdio.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stdio.js","sourceRoot":"","sources":["src/stdio.ts"],"names":[],"mappings":";;;AAAA,wEAAiF;AAEjF,wCAAuD;
|
|
1
|
+
{"version":3,"file":"stdio.js","sourceRoot":"","sources":["src/stdio.ts"],"names":[],"mappings":";;;AAAA,wEAAiF;AAEjF,wCAAuD;AACvD,wCAAqC;AAE9B,MAAM,iBAAiB,GAAG,KAAK,EAAE,UAAsB,EAAE,EAAE;IAChE,MAAM,MAAM,GAAG,MAAM,IAAA,qBAAY,EAAC,UAAU,CAAC,eAAe,CAAC,CAAC;IAE9D,MAAM,IAAA,sBAAa,EAAC,EAAE,MAAM,EAAE,UAAU,EAAE,eAAe,EAAE,UAAU,CAAC,eAAe,EAAE,CAAC,CAAC;IAEzF,MAAM,SAAS,GAAG,IAAI,+BAAoB,EAAE,CAAC;IAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAChC,IAAA,kBAAS,GAAE,CAAC,IAAI,CAAC,6BAA6B,CAAC,CAAC;AAClD,CAAC,CAAC;AARW,QAAA,iBAAiB,qBAQ5B"}
|
package/stdio.mjs
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
2
2
|
import { initMcpServer, newMcpServer } from "./server.mjs";
|
|
3
|
+
import { getLogger } from "./logger.mjs";
|
|
3
4
|
export const launchStdioServer = async (mcpOptions) => {
|
|
4
5
|
const server = await newMcpServer(mcpOptions.stainlessApiKey);
|
|
5
6
|
await initMcpServer({ server, mcpOptions, stainlessApiKey: mcpOptions.stainlessApiKey });
|
|
6
7
|
const transport = new StdioServerTransport();
|
|
7
8
|
await server.connect(transport);
|
|
8
|
-
|
|
9
|
+
getLogger().info('MCP Server running on stdio');
|
|
9
10
|
};
|
|
10
11
|
//# sourceMappingURL=stdio.mjs.map
|
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;OAEzE,EAAE,aAAa,EAAE,YAAY,EAAE;
|
|
1
|
+
{"version":3,"file":"stdio.mjs","sourceRoot":"","sources":["src/stdio.ts"],"names":[],"mappings":"OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C;OAEzE,EAAE,aAAa,EAAE,YAAY,EAAE;OAC/B,EAAE,SAAS,EAAE;AAEpB,MAAM,CAAC,MAAM,iBAAiB,GAAG,KAAK,EAAE,UAAsB,EAAE,EAAE;IAChE,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,UAAU,CAAC,eAAe,CAAC,CAAC;IAE9D,MAAM,aAAa,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,eAAe,EAAE,UAAU,CAAC,eAAe,EAAE,CAAC,CAAC;IAEzF,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;IAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAChC,SAAS,EAAE,CAAC,IAAI,CAAC,6BAA6B,CAAC,CAAC;AAClD,CAAC,CAAC"}
|