context.dev-mcp 0.3.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/docs-search-tool.d.mts +2 -0
- package/docs-search-tool.d.mts.map +1 -1
- package/docs-search-tool.d.ts +2 -0
- package/docs-search-tool.d.ts.map +1 -1
- package/docs-search-tool.js +35 -4
- package/docs-search-tool.js.map +1 -1
- package/docs-search-tool.mjs +34 -4
- package/docs-search-tool.mjs.map +1 -1
- package/http.d.mts.map +1 -1
- package/http.d.ts.map +1 -1
- package/http.js +2 -1
- package/http.js.map +1 -1
- package/http.mjs +2 -1
- package/http.mjs.map +1 -1
- package/instructions.d.mts +4 -1
- package/instructions.d.mts.map +1 -1
- package/instructions.d.ts +4 -1
- package/instructions.d.ts.map +1 -1
- package/instructions.js +23 -4
- package/instructions.js.map +1 -1
- package/instructions.mjs +20 -4
- package/instructions.mjs.map +1 -1
- package/local-docs-search.d.mts +28 -0
- package/local-docs-search.d.mts.map +1 -0
- package/local-docs-search.d.ts +28 -0
- package/local-docs-search.d.ts.map +1 -0
- package/local-docs-search.js +544 -0
- package/local-docs-search.js.map +1 -0
- package/local-docs-search.mjs +504 -0
- package/local-docs-search.mjs.map +1 -0
- package/options.d.mts +3 -0
- package/options.d.mts.map +1 -1
- package/options.d.ts +3 -0
- package/options.d.ts.map +1 -1
- package/options.js +19 -0
- package/options.js.map +1 -1
- package/options.mjs +19 -0
- package/options.mjs.map +1 -1
- package/package.json +15 -4
- package/server.d.mts +4 -1
- package/server.d.mts.map +1 -1
- package/server.d.ts +4 -1
- package/server.d.ts.map +1 -1
- package/server.js +10 -3
- package/server.js.map +1 -1
- package/server.mjs +10 -3
- package/server.mjs.map +1 -1
- package/src/docs-search-tool.ts +56 -10
- package/src/http.ts +2 -1
- package/src/instructions.ts +27 -4
- package/src/local-docs-search.ts +614 -0
- package/src/options.ts +24 -0
- package/src/server.ts +17 -3
- package/src/stdio.ts +4 -1
- package/stdio.d.mts.map +1 -1
- package/stdio.d.ts.map +1 -1
- package/stdio.js +4 -1
- package/stdio.js.map +1 -1
- package/stdio.mjs +4 -1
- package/stdio.mjs.map +1 -1
package/src/options.ts
CHANGED
|
@@ -18,10 +18,13 @@ export type McpOptions = {
|
|
|
18
18
|
includeCodeTool?: boolean | undefined;
|
|
19
19
|
includeDocsTools?: boolean | undefined;
|
|
20
20
|
stainlessApiKey?: string | undefined;
|
|
21
|
+
docsSearchMode?: 'stainless-api' | 'local' | undefined;
|
|
22
|
+
docsDir?: string | undefined;
|
|
21
23
|
codeAllowHttpGets?: boolean | undefined;
|
|
22
24
|
codeAllowedMethods?: string[] | undefined;
|
|
23
25
|
codeBlockedMethods?: string[] | undefined;
|
|
24
26
|
codeExecutionMode: McpCodeExecutionMode;
|
|
27
|
+
customInstructionsPath?: string | undefined;
|
|
25
28
|
};
|
|
26
29
|
|
|
27
30
|
export type McpCodeExecutionMode = 'stainless-sandbox' | 'local';
|
|
@@ -52,7 +55,23 @@ export function parseCLIOptions(): CLIOptions {
|
|
|
52
55
|
description:
|
|
53
56
|
"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.",
|
|
54
57
|
})
|
|
58
|
+
.option('custom-instructions-path', {
|
|
59
|
+
type: 'string',
|
|
60
|
+
description: 'Path to custom instructions for the MCP server',
|
|
61
|
+
})
|
|
55
62
|
.option('debug', { type: 'boolean', description: 'Enable debug logging' })
|
|
63
|
+
.option('docs-dir', {
|
|
64
|
+
type: 'string',
|
|
65
|
+
description:
|
|
66
|
+
'Path to a directory of local documentation files (markdown/JSON) to include in local docs search.',
|
|
67
|
+
})
|
|
68
|
+
.option('docs-search-mode', {
|
|
69
|
+
type: 'string',
|
|
70
|
+
choices: ['stainless-api', 'local'],
|
|
71
|
+
default: 'stainless-api',
|
|
72
|
+
description:
|
|
73
|
+
"Where to search documentation; 'stainless-api' uses the Stainless-hosted search API whereas 'local' uses an in-memory search index built from embedded SDK method data and optional local docs files.",
|
|
74
|
+
})
|
|
56
75
|
.option('log-format', {
|
|
57
76
|
type: 'string',
|
|
58
77
|
choices: ['json', 'pretty'],
|
|
@@ -113,10 +132,13 @@ export function parseCLIOptions(): CLIOptions {
|
|
|
113
132
|
...(includeDocsTools !== undefined && { includeDocsTools }),
|
|
114
133
|
debug: !!argv.debug,
|
|
115
134
|
stainlessApiKey: argv.stainlessApiKey,
|
|
135
|
+
docsSearchMode: argv.docsSearchMode as 'stainless-api' | 'local' | undefined,
|
|
136
|
+
docsDir: argv.docsDir,
|
|
116
137
|
codeAllowHttpGets: argv.codeAllowHttpGets,
|
|
117
138
|
codeAllowedMethods: argv.codeAllowedMethods,
|
|
118
139
|
codeBlockedMethods: argv.codeBlockedMethods,
|
|
119
140
|
codeExecutionMode: argv.codeExecutionMode as McpCodeExecutionMode,
|
|
141
|
+
customInstructionsPath: argv.customInstructionsPath,
|
|
120
142
|
transport,
|
|
121
143
|
logFormat,
|
|
122
144
|
port: argv.port,
|
|
@@ -157,5 +179,7 @@ export function parseQueryOptions(defaultOptions: McpOptions, query: unknown): M
|
|
|
157
179
|
...(codeTool !== undefined && { includeCodeTool: codeTool }),
|
|
158
180
|
...(docsTools !== undefined && { includeDocsTools: docsTools }),
|
|
159
181
|
codeExecutionMode: defaultOptions.codeExecutionMode,
|
|
182
|
+
docsSearchMode: defaultOptions.docsSearchMode,
|
|
183
|
+
docsDir: defaultOptions.docsDir,
|
|
160
184
|
};
|
|
161
185
|
}
|
package/src/server.ts
CHANGED
|
@@ -11,19 +11,27 @@ import { ClientOptions } from 'context.dev';
|
|
|
11
11
|
import ContextDev from 'context.dev';
|
|
12
12
|
import { codeTool } from './code-tool';
|
|
13
13
|
import docsSearchTool from './docs-search-tool';
|
|
14
|
+
import { setLocalSearch } from './docs-search-tool';
|
|
15
|
+
import { LocalDocsSearch } from './local-docs-search';
|
|
14
16
|
import { getInstructions } from './instructions';
|
|
15
17
|
import { McpOptions } from './options';
|
|
16
18
|
import { blockedMethodsForCodeTool } from './methods';
|
|
17
19
|
import { HandlerFunction, McpRequestContext, ToolCallResult, McpTool } from './types';
|
|
18
20
|
|
|
19
|
-
export const newMcpServer = async (
|
|
21
|
+
export const newMcpServer = async ({
|
|
22
|
+
stainlessApiKey,
|
|
23
|
+
customInstructionsPath,
|
|
24
|
+
}: {
|
|
25
|
+
stainlessApiKey?: string | undefined;
|
|
26
|
+
customInstructionsPath?: string | undefined;
|
|
27
|
+
}) =>
|
|
20
28
|
new McpServer(
|
|
21
29
|
{
|
|
22
30
|
name: 'context_dev_api',
|
|
23
|
-
version: '
|
|
31
|
+
version: '1.1.0',
|
|
24
32
|
},
|
|
25
33
|
{
|
|
26
|
-
instructions: await getInstructions(stainlessApiKey),
|
|
34
|
+
instructions: await getInstructions({ stainlessApiKey, customInstructionsPath }),
|
|
27
35
|
capabilities: { tools: {}, logging: {} },
|
|
28
36
|
},
|
|
29
37
|
);
|
|
@@ -56,6 +64,12 @@ export async function initMcpServer(params: {
|
|
|
56
64
|
error: logAtLevel('error'),
|
|
57
65
|
};
|
|
58
66
|
|
|
67
|
+
if (params.mcpOptions?.docsSearchMode === 'local') {
|
|
68
|
+
const docsDir = params.mcpOptions?.docsDir;
|
|
69
|
+
const localSearch = await LocalDocsSearch.create(docsDir ? { docsDir } : undefined);
|
|
70
|
+
setLocalSearch(localSearch);
|
|
71
|
+
}
|
|
72
|
+
|
|
59
73
|
let _client: ContextDev | undefined;
|
|
60
74
|
let _clientError: Error | undefined;
|
|
61
75
|
let _logLevel: 'debug' | 'info' | 'warn' | 'error' | 'off' | undefined;
|
package/src/stdio.ts
CHANGED
|
@@ -4,7 +4,10 @@ import { initMcpServer, newMcpServer } from './server';
|
|
|
4
4
|
import { getLogger } from './logger';
|
|
5
5
|
|
|
6
6
|
export const launchStdioServer = async (mcpOptions: McpOptions) => {
|
|
7
|
-
const server = await newMcpServer(
|
|
7
|
+
const server = await newMcpServer({
|
|
8
|
+
stainlessApiKey: mcpOptions.stainlessApiKey,
|
|
9
|
+
customInstructionsPath: mcpOptions.customInstructionsPath,
|
|
10
|
+
});
|
|
8
11
|
|
|
9
12
|
await initMcpServer({ server, mcpOptions, stainlessApiKey: mcpOptions.stainlessApiKey });
|
|
10
13
|
|
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;AAIrB,eAAO,MAAM,iBAAiB,GAAU,YAAY,UAAU,
|
|
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,kBAW7D,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;AAIrB,eAAO,MAAM,iBAAiB,GAAU,YAAY,UAAU,
|
|
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,kBAW7D,CAAC"}
|
package/stdio.js
CHANGED
|
@@ -5,7 +5,10 @@ const stdio_js_1 = require("@modelcontextprotocol/sdk/server/stdio.js");
|
|
|
5
5
|
const server_1 = require("./server.js");
|
|
6
6
|
const logger_1 = require("./logger.js");
|
|
7
7
|
const launchStdioServer = async (mcpOptions) => {
|
|
8
|
-
const server = await (0, server_1.newMcpServer)(
|
|
8
|
+
const server = await (0, server_1.newMcpServer)({
|
|
9
|
+
stainlessApiKey: mcpOptions.stainlessApiKey,
|
|
10
|
+
customInstructionsPath: mcpOptions.customInstructionsPath,
|
|
11
|
+
});
|
|
9
12
|
await (0, server_1.initMcpServer)({ server, mcpOptions, stainlessApiKey: mcpOptions.stainlessApiKey });
|
|
10
13
|
const transport = new stdio_js_1.StdioServerTransport();
|
|
11
14
|
await server.connect(transport);
|
package/stdio.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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;
|
|
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;QAChC,eAAe,EAAE,UAAU,CAAC,eAAe;QAC3C,sBAAsB,EAAE,UAAU,CAAC,sBAAsB;KAC1D,CAAC,CAAC;IAEH,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;AAXW,QAAA,iBAAiB,qBAW5B"}
|
package/stdio.mjs
CHANGED
|
@@ -2,7 +2,10 @@ import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'
|
|
|
2
2
|
import { initMcpServer, newMcpServer } from "./server.mjs";
|
|
3
3
|
import { getLogger } from "./logger.mjs";
|
|
4
4
|
export const launchStdioServer = async (mcpOptions) => {
|
|
5
|
-
const server = await newMcpServer(
|
|
5
|
+
const server = await newMcpServer({
|
|
6
|
+
stainlessApiKey: mcpOptions.stainlessApiKey,
|
|
7
|
+
customInstructionsPath: mcpOptions.customInstructionsPath,
|
|
8
|
+
});
|
|
6
9
|
await initMcpServer({ server, mcpOptions, stainlessApiKey: mcpOptions.stainlessApiKey });
|
|
7
10
|
const transport = new StdioServerTransport();
|
|
8
11
|
await server.connect(transport);
|
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;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;
|
|
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;QAChC,eAAe,EAAE,UAAU,CAAC,eAAe;QAC3C,sBAAsB,EAAE,UAAU,CAAC,sBAAsB;KAC1D,CAAC,CAAC;IAEH,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"}
|