profound-mcp 0.26.0 → 0.26.2
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/auth.d.mts +3 -1
- package/auth.d.mts.map +1 -1
- package/auth.d.ts +3 -1
- package/auth.d.ts.map +1 -1
- package/auth.js +15 -3
- package/auth.js.map +1 -1
- package/auth.mjs +12 -1
- package/auth.mjs.map +1 -1
- package/code-tool.d.mts +1 -1
- package/code-tool.d.mts.map +1 -1
- package/code-tool.d.ts +1 -1
- package/code-tool.d.ts.map +1 -1
- package/code-tool.js +7 -8
- package/code-tool.js.map +1 -1
- package/code-tool.mjs +8 -9
- package/code-tool.mjs.map +1 -1
- package/docs-search-tool.d.mts +9 -3
- package/docs-search-tool.d.mts.map +1 -1
- package/docs-search-tool.d.ts +9 -3
- package/docs-search-tool.d.ts.map +1 -1
- package/docs-search-tool.js +2 -4
- package/docs-search-tool.js.map +1 -1
- package/docs-search-tool.mjs +2 -4
- package/docs-search-tool.mjs.map +1 -1
- package/http.d.mts +1 -1
- package/http.d.mts.map +1 -1
- package/http.d.ts +1 -1
- package/http.d.ts.map +1 -1
- package/http.js +8 -6
- package/http.js.map +1 -1
- package/http.mjs +9 -7
- package/http.mjs.map +1 -1
- package/instructions.d.mts +2 -0
- package/instructions.d.mts.map +1 -0
- package/instructions.d.ts +2 -0
- package/instructions.d.ts.map +1 -0
- package/instructions.js +55 -0
- package/instructions.js.map +1 -0
- package/instructions.mjs +52 -0
- package/instructions.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 +7 -0
- package/options.js.map +1 -1
- package/options.mjs +7 -0
- package/options.mjs.map +1 -1
- package/package.json +12 -2
- package/server.d.mts +8 -4
- package/server.d.mts.map +1 -1
- package/server.d.ts +8 -4
- package/server.d.ts.map +1 -1
- package/server.js +14 -33
- package/server.js.map +1 -1
- package/server.mjs +14 -33
- package/server.mjs.map +1 -1
- package/src/auth.ts +16 -1
- package/src/code-tool.ts +21 -12
- package/src/docs-search-tool.ts +9 -6
- package/src/http.ts +14 -7
- package/src/instructions.ts +74 -0
- package/src/options.ts +9 -0
- package/src/server.ts +24 -48
- package/src/stdio.ts +2 -2
- package/src/types.ts +12 -4
- package/stdio.js +2 -2
- package/stdio.js.map +1 -1
- package/stdio.mjs +2 -2
- package/stdio.mjs.map +1 -1
- package/types.d.mts +8 -1
- package/types.d.mts.map +1 -1
- package/types.d.ts +8 -1
- package/types.d.ts.map +1 -1
- package/types.js.map +1 -1
- package/types.mjs.map +1 -1
package/instructions.js
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.getInstructions = getInstructions;
|
|
5
|
+
const util_1 = require("./util.js");
|
|
6
|
+
const INSTRUCTIONS_CACHE_TTL_MS = 15 * 60 * 1000; // 15 minutes
|
|
7
|
+
const instructionsCache = new Map();
|
|
8
|
+
// Periodically evict stale entries so the cache doesn't grow unboundedly.
|
|
9
|
+
const _cacheCleanupInterval = setInterval(() => {
|
|
10
|
+
const now = Date.now();
|
|
11
|
+
for (const [key, entry] of instructionsCache) {
|
|
12
|
+
if (now - entry.fetchedAt > INSTRUCTIONS_CACHE_TTL_MS) {
|
|
13
|
+
instructionsCache.delete(key);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}, INSTRUCTIONS_CACHE_TTL_MS);
|
|
17
|
+
// Don't keep the process alive just for cleanup.
|
|
18
|
+
_cacheCleanupInterval.unref();
|
|
19
|
+
async function getInstructions(stainlessApiKey) {
|
|
20
|
+
const cacheKey = stainlessApiKey ?? '';
|
|
21
|
+
const cached = instructionsCache.get(cacheKey);
|
|
22
|
+
if (cached && Date.now() - cached.fetchedAt <= INSTRUCTIONS_CACHE_TTL_MS) {
|
|
23
|
+
return cached.fetchedInstructions;
|
|
24
|
+
}
|
|
25
|
+
const fetchedInstructions = await fetchLatestInstructions(stainlessApiKey);
|
|
26
|
+
instructionsCache.set(cacheKey, { fetchedInstructions, fetchedAt: Date.now() });
|
|
27
|
+
return fetchedInstructions;
|
|
28
|
+
}
|
|
29
|
+
async function fetchLatestInstructions(stainlessApiKey) {
|
|
30
|
+
// Setting the stainless API key is optional, but may be required
|
|
31
|
+
// to authenticate requests to the Stainless API.
|
|
32
|
+
const response = await fetch((0, util_1.readEnv)('CODE_MODE_INSTRUCTIONS_URL') ?? 'https://api.stainless.com/api/ai/instructions/profound', {
|
|
33
|
+
method: 'GET',
|
|
34
|
+
headers: { ...(stainlessApiKey && { Authorization: stainlessApiKey }) },
|
|
35
|
+
});
|
|
36
|
+
let instructions;
|
|
37
|
+
if (!response.ok) {
|
|
38
|
+
console.warn('Warning: failed to retrieve MCP server instructions. Proceeding with default instructions...');
|
|
39
|
+
instructions = `
|
|
40
|
+
This is the profound MCP server. You will use Code Mode to help the user perform
|
|
41
|
+
actions. You can use search_docs tool to learn about how to take action with this server. Then,
|
|
42
|
+
you will write TypeScript code using the execute tool take action. It is CRITICAL that you be
|
|
43
|
+
thoughtful and deliberate when executing code. Always try to entirely solve the problem in code
|
|
44
|
+
block: it can be as long as you need to get the job done!
|
|
45
|
+
`;
|
|
46
|
+
}
|
|
47
|
+
instructions ??= (await response.json()).instructions;
|
|
48
|
+
instructions = `
|
|
49
|
+
If needed, you can get the current time by executing Date.now().
|
|
50
|
+
|
|
51
|
+
${instructions}
|
|
52
|
+
`;
|
|
53
|
+
return instructions;
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=instructions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instructions.js","sourceRoot":"","sources":["src/instructions.ts"],"names":[],"mappings":";AAAA,sFAAsF;;AA0BtF,0CAWC;AAnCD,oCAAiC;AAEjC,MAAM,yBAAyB,GAAG,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ACE,MAAM,EAAE,KAAK;QACb,OAAO,EAAE,EAAE,GAAG,CAAC,eAAe,IAAI,EAAE,aAAa,EAAE,eAAe,EAAE,CAAC,EAAE;KACxE,CACF,CAAC;IAEF,IAAI,YAAgC,CAAC;IACrC,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;QACjB,OAAO,CAAC,IAAI,CACV,8FAA8F,CAC/F,CAAC;QAEF,YAAY,GAAG;;;;;;KAMd,CAAC;IACJ,CAAC;IAED,YAAY,KAAM,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAA8B,CAAC,YAAY,CAAC;IACpF,YAAY,GAAG;;;MAGX,YAAY;GACf,CAAC;IAEF,OAAO,YAAY,CAAC;AACtB,CAAC"}
|
package/instructions.mjs
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
import { readEnv } from "./util.mjs";
|
|
3
|
+
const INSTRUCTIONS_CACHE_TTL_MS = 15 * 60 * 1000; // 15 minutes
|
|
4
|
+
const instructionsCache = new Map();
|
|
5
|
+
// Periodically evict stale entries so the cache doesn't grow unboundedly.
|
|
6
|
+
const _cacheCleanupInterval = setInterval(() => {
|
|
7
|
+
const now = Date.now();
|
|
8
|
+
for (const [key, entry] of instructionsCache) {
|
|
9
|
+
if (now - entry.fetchedAt > INSTRUCTIONS_CACHE_TTL_MS) {
|
|
10
|
+
instructionsCache.delete(key);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
}, INSTRUCTIONS_CACHE_TTL_MS);
|
|
14
|
+
// Don't keep the process alive just for cleanup.
|
|
15
|
+
_cacheCleanupInterval.unref();
|
|
16
|
+
export async function getInstructions(stainlessApiKey) {
|
|
17
|
+
const cacheKey = stainlessApiKey ?? '';
|
|
18
|
+
const cached = instructionsCache.get(cacheKey);
|
|
19
|
+
if (cached && Date.now() - cached.fetchedAt <= INSTRUCTIONS_CACHE_TTL_MS) {
|
|
20
|
+
return cached.fetchedInstructions;
|
|
21
|
+
}
|
|
22
|
+
const fetchedInstructions = await fetchLatestInstructions(stainlessApiKey);
|
|
23
|
+
instructionsCache.set(cacheKey, { fetchedInstructions, fetchedAt: Date.now() });
|
|
24
|
+
return fetchedInstructions;
|
|
25
|
+
}
|
|
26
|
+
async function fetchLatestInstructions(stainlessApiKey) {
|
|
27
|
+
// Setting the stainless API key is optional, but may be required
|
|
28
|
+
// to authenticate requests to the Stainless API.
|
|
29
|
+
const response = await fetch(readEnv('CODE_MODE_INSTRUCTIONS_URL') ?? 'https://api.stainless.com/api/ai/instructions/profound', {
|
|
30
|
+
method: 'GET',
|
|
31
|
+
headers: { ...(stainlessApiKey && { Authorization: stainlessApiKey }) },
|
|
32
|
+
});
|
|
33
|
+
let instructions;
|
|
34
|
+
if (!response.ok) {
|
|
35
|
+
console.warn('Warning: failed to retrieve MCP server instructions. Proceeding with default instructions...');
|
|
36
|
+
instructions = `
|
|
37
|
+
This is the profound MCP server. You will use Code Mode to help the user perform
|
|
38
|
+
actions. You can use search_docs tool to learn about how to take action with this server. Then,
|
|
39
|
+
you will write TypeScript code using the execute tool take action. It is CRITICAL that you be
|
|
40
|
+
thoughtful and deliberate when executing code. Always try to entirely solve the problem in code
|
|
41
|
+
block: it can be as long as you need to get the job done!
|
|
42
|
+
`;
|
|
43
|
+
}
|
|
44
|
+
instructions ??= (await response.json()).instructions;
|
|
45
|
+
instructions = `
|
|
46
|
+
If needed, you can get the current time by executing Date.now().
|
|
47
|
+
|
|
48
|
+
${instructions}
|
|
49
|
+
`;
|
|
50
|
+
return instructions;
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=instructions.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instructions.mjs","sourceRoot":"","sources":["src/instructions.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAE/E,EAAE,OAAO,EAAE;AAElB,MAAM,yBAAyB,GAAG,EAAE,GAAG,EAAE,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AE,KAAK;QACb,OAAO,EAAE,EAAE,GAAG,CAAC,eAAe,IAAI,EAAE,aAAa,EAAE,eAAe,EAAE,CAAC,EAAE;KACxE,CACF,CAAC;IAEF,IAAI,YAAgC,CAAC;IACrC,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;QACjB,OAAO,CAAC,IAAI,CACV,8FAA8F,CAC/F,CAAC;QAEF,YAAY,GAAG;;;;;;KAMd,CAAC;IACJ,CAAC;IAED,YAAY,KAAM,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAA8B,CAAC,YAAY,CAAC;IACpF,YAAY,GAAG;;;MAGX,YAAY;GACf,CAAC;IAEF,OAAO,YAAY,CAAC;AACtB,CAAC"}
|
package/options.d.mts
CHANGED
|
@@ -6,6 +6,7 @@ export type CLIOptions = McpOptions & {
|
|
|
6
6
|
};
|
|
7
7
|
export type McpOptions = {
|
|
8
8
|
includeDocsTools?: boolean | undefined;
|
|
9
|
+
stainlessApiKey?: string | undefined;
|
|
9
10
|
codeAllowHttpGets?: boolean | undefined;
|
|
10
11
|
codeAllowedMethods?: string[] | undefined;
|
|
11
12
|
codeBlockedMethods?: string[] | undefined;
|
package/options.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options.d.mts","sourceRoot":"","sources":["src/options.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"options.d.mts","sourceRoot":"","sources":["src/options.ts"],"names":[],"mappings":"AAQA,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;IACvC,eAAe,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACrC,iBAAiB,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IACxC,kBAAkB,CAAC,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;IAC1C,kBAAkB,CAAC,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;CAC3C,CAAC;AAEF,wBAAgB,eAAe,IAAI,UAAU,CA4E5C;AAiBD,wBAAgB,iBAAiB,CAAC,cAAc,EAAE,UAAU,EAAE,KAAK,EAAE,OAAO,GAAG,UAAU,CAYxF"}
|
package/options.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export type CLIOptions = McpOptions & {
|
|
|
6
6
|
};
|
|
7
7
|
export type McpOptions = {
|
|
8
8
|
includeDocsTools?: boolean | undefined;
|
|
9
|
+
stainlessApiKey?: string | undefined;
|
|
9
10
|
codeAllowHttpGets?: boolean | undefined;
|
|
10
11
|
codeAllowedMethods?: string[] | undefined;
|
|
11
12
|
codeBlockedMethods?: string[] | undefined;
|
package/options.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options.d.ts","sourceRoot":"","sources":["src/options.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"options.d.ts","sourceRoot":"","sources":["src/options.ts"],"names":[],"mappings":"AAQA,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;IACvC,eAAe,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACrC,iBAAiB,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IACxC,kBAAkB,CAAC,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;IAC1C,kBAAkB,CAAC,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;CAC3C,CAAC;AAEF,wBAAgB,eAAe,IAAI,UAAU,CA4E5C;AAiBD,wBAAgB,iBAAiB,CAAC,cAAc,EAAE,UAAU,EAAE,KAAK,EAAE,OAAO,GAAG,UAAU,CAYxF"}
|
package/options.js
CHANGED
|
@@ -10,6 +10,7 @@ const qs_1 = __importDefault(require("qs"));
|
|
|
10
10
|
const yargs_1 = __importDefault(require("yargs"));
|
|
11
11
|
const helpers_1 = require("yargs/helpers");
|
|
12
12
|
const zod_1 = __importDefault(require("zod"));
|
|
13
|
+
const util_1 = require("./util.js");
|
|
13
14
|
function parseCLIOptions() {
|
|
14
15
|
const opts = (0, yargs_1.default)((0, helpers_1.hideBin)(process.argv))
|
|
15
16
|
.option('code-allow-http-gets', {
|
|
@@ -39,6 +40,11 @@ function parseCLIOptions() {
|
|
|
39
40
|
description: 'Port to serve on if using http transport',
|
|
40
41
|
})
|
|
41
42
|
.option('socket', { type: 'string', description: 'Unix socket to serve on if using http transport' })
|
|
43
|
+
.option('stainless-api-key', {
|
|
44
|
+
type: 'string',
|
|
45
|
+
default: (0, util_1.readEnv)('STAINLESS_API_KEY'),
|
|
46
|
+
description: 'API key for Stainless. Used to authenticate requests to Stainless-hosted tools endpoints.',
|
|
47
|
+
})
|
|
42
48
|
.option('tools', {
|
|
43
49
|
type: 'string',
|
|
44
50
|
array: true,
|
|
@@ -63,6 +69,7 @@ function parseCLIOptions() {
|
|
|
63
69
|
return {
|
|
64
70
|
...(includeDocsTools !== undefined && { includeDocsTools }),
|
|
65
71
|
debug: !!argv.debug,
|
|
72
|
+
stainlessApiKey: argv.stainlessApiKey,
|
|
66
73
|
codeAllowHttpGets: argv.codeAllowHttpGets,
|
|
67
74
|
codeAllowedMethods: argv.codeAllowedMethods,
|
|
68
75
|
codeBlockedMethods: argv.codeBlockedMethods,
|
package/options.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options.js","sourceRoot":"","sources":["src/options.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;;;
|
|
1
|
+
{"version":3,"file":"options.js","sourceRoot":"","sources":["src/options.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;;;AAuBtF,0CA4EC;AAiBD,8CAYC;AA9HD,4CAAoB;AACpB,kDAA0B;AAC1B,2CAAwC;AACxC,8CAAoB;AACpB,oCAAiC;AAiBjC,SAAgB,eAAe;IAC7B,MAAM,IAAI,GAAG,IAAA,eAAK,EAAC,IAAA,iBAAO,EAAC,OAAO,CAAC,IAAI,CAAC,CAAC;SACtC,MAAM,CAAC,sBAAsB,EAAE;QAC9B,IAAI,EAAE,SAAS;QACf,WAAW,EACT,+HAA+H;KAClI,CAAC;SACD,MAAM,CAAC,sBAAsB,EAAE;QAC9B,IAAI,EAAE,QAAQ;QACd,KAAK,EAAE,IAAI;QACX,WAAW,EACT,oLAAoL;KACvL,CAAC;SACD,MAAM,CAAC,sBAAsB,EAAE;QAC9B,IAAI,EAAE,QAAQ;QACd,KAAK,EAAE,IAAI;QACX,WAAW,EACT,oLAAoL;KACvL,CAAC;SACD,MAAM,CAAC,OAAO,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE,sBAAsB,EAAE,CAAC;SACzE,MAAM,CAAC,UAAU,EAAE;QAClB,IAAI,EAAE,QAAQ;QACd,KAAK,EAAE,IAAI;QACX,OAAO,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC;QACzB,WAAW,EAAE,6BAA6B;KAC3C,CAAC;SACD,MAAM,CAAC,MAAM,EAAE;QACd,IAAI,EAAE,QAAQ;QACd,OAAO,EAAE,IAAI;QACb,WAAW,EAAE,0CAA0C;KACxD,CAAC;SACD,MAAM,CAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,iDAAiD,EAAE,CAAC;SACpG,MAAM,CAAC,mBAAmB,EAAE;QAC3B,IAA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AC,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
|
@@ -3,6 +3,7 @@ import qs from 'qs';
|
|
|
3
3
|
import yargs from 'yargs';
|
|
4
4
|
import { hideBin } from 'yargs/helpers';
|
|
5
5
|
import z from 'zod';
|
|
6
|
+
import { readEnv } from "./util.mjs";
|
|
6
7
|
export function parseCLIOptions() {
|
|
7
8
|
const opts = yargs(hideBin(process.argv))
|
|
8
9
|
.option('code-allow-http-gets', {
|
|
@@ -32,6 +33,11 @@ export function parseCLIOptions() {
|
|
|
32
33
|
description: 'Port to serve on if using http transport',
|
|
33
34
|
})
|
|
34
35
|
.option('socket', { type: 'string', description: 'Unix socket to serve on if using http transport' })
|
|
36
|
+
.option('stainless-api-key', {
|
|
37
|
+
type: 'string',
|
|
38
|
+
default: readEnv('STAINLESS_API_KEY'),
|
|
39
|
+
description: 'API key for Stainless. Used to authenticate requests to Stainless-hosted tools endpoints.',
|
|
40
|
+
})
|
|
35
41
|
.option('tools', {
|
|
36
42
|
type: 'string',
|
|
37
43
|
array: true,
|
|
@@ -56,6 +62,7 @@ export function parseCLIOptions() {
|
|
|
56
62
|
return {
|
|
57
63
|
...(includeDocsTools !== undefined && { includeDocsTools }),
|
|
58
64
|
debug: !!argv.debug,
|
|
65
|
+
stainlessApiKey: argv.stainlessApiKey,
|
|
59
66
|
codeAllowHttpGets: argv.codeAllowHttpGets,
|
|
60
67
|
codeAllowedMethods: argv.codeAllowedMethods,
|
|
61
68
|
codeBlockedMethods: argv.codeBlockedMethods,
|
package/options.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options.mjs","sourceRoot":"","sources":["src/options.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAE/E,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":"AAAA,sFAAsF;OAE/E,EAAE,MAAM,IAAI;OACZ,KAAK,MAAM,OAAO;OAClB,EAAE,OAAO,EAAE,MAAM,eAAe;OAChC,CAAC,MAAM,KAAK;OACZ,EAAE,OAAO,EAAE;AAiBlB,MAAM,UAAU,eAAe;IAC7B,MAAM,IAAI,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;SACtC,MAAM,CAAC,sBAAsB,EAAE;QAC9B,IAAI,EAAE,SAAS;QACf,WAAW,EACT,+HAA+H;KAClI,CAAC;SACD,MAAM,CAAC,sBAAsB,EAAE;QAC9B,IAAI,EAAE,QAAQ;QACd,KAAK,EAAE,IAAI;QACX,WAAW,EACT,oLAAoL;KACvL,CAAC;SACD,MAAM,CAAC,sBAAsB,EAAE;QAC9B,IAAI,EAAE,QAAQ;QACd,KAAK,EAAE,IAAI;QACX,WAAW,EACT,oLAAoL;KACvL,CAAC;SACD,MAAM,CAAC,OAAO,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE,sBAAsB,EAAE,CAAC;SACzE,MAAM,CAAC,UAAU,EAAE;QAClB,IAAI,EAAE,QAAQ;QACd,KAAK,EAAE,IAAI;QACX,OAAO,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC;QACzB,WAAW,EAAE,6BAA6B;KAC3C,CAAC;SACD,MAAM,CAAC,MAAM,EAAE;QACd,IAAI,EAAE,QAAQ;QACd,OAAO,EAAE,IAAI;QACb,WAAW,EAAE,0CAA0C;KACxD,CAAC;SACD,MAAM,CAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,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AAY,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": "profound-mcp",
|
|
3
|
-
"version": "0.26.
|
|
3
|
+
"version": "0.26.2",
|
|
4
4
|
"description": "The official MCP Server for the Profound API",
|
|
5
5
|
"author": "Profound <support@tryprofound.com>",
|
|
6
6
|
"types": "./index.d.ts",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"fix": "eslint --fix --ext ts,js ."
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"profoundai": "^0.26.
|
|
30
|
+
"profoundai": "^0.26.2",
|
|
31
31
|
"@cloudflare/cabidela": "^0.2.4",
|
|
32
32
|
"@modelcontextprotocol/sdk": "^1.25.2",
|
|
33
33
|
"@valtown/deno-http-worker": "^0.0.21",
|
|
@@ -121,6 +121,16 @@
|
|
|
121
121
|
"./index.mjs": {
|
|
122
122
|
"default": "./index.mjs"
|
|
123
123
|
},
|
|
124
|
+
"./instructions": {
|
|
125
|
+
"import": "./instructions.mjs",
|
|
126
|
+
"require": "./instructions.js"
|
|
127
|
+
},
|
|
128
|
+
"./instructions.js": {
|
|
129
|
+
"default": "./instructions.js"
|
|
130
|
+
},
|
|
131
|
+
"./instructions.mjs": {
|
|
132
|
+
"default": "./instructions.mjs"
|
|
133
|
+
},
|
|
124
134
|
"./methods": {
|
|
125
135
|
"import": "./methods.mjs",
|
|
126
136
|
"require": "./methods.js"
|
package/server.d.mts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
2
2
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
3
3
|
import { ClientOptions } from 'profoundai';
|
|
4
|
-
import Profound from 'profoundai';
|
|
5
4
|
import { McpOptions } from "./options.mjs";
|
|
6
|
-
import { HandlerFunction, McpTool } from "./types.mjs";
|
|
7
|
-
export declare const newMcpServer: () => Promise<McpServer>;
|
|
5
|
+
import { HandlerFunction, McpRequestContext, ToolCallResult, McpTool } from "./types.mjs";
|
|
6
|
+
export declare const newMcpServer: (stainlessApiKey: string | undefined) => Promise<McpServer>;
|
|
8
7
|
/**
|
|
9
8
|
* Initializes the provided MCP Server with the given tools and handlers.
|
|
10
9
|
* If not provided, the default client, tools and handlers will be used.
|
|
@@ -13,6 +12,7 @@ export declare function initMcpServer(params: {
|
|
|
13
12
|
server: Server | McpServer;
|
|
14
13
|
clientOptions?: ClientOptions;
|
|
15
14
|
mcpOptions?: McpOptions;
|
|
15
|
+
stainlessApiKey?: string | undefined;
|
|
16
16
|
}): Promise<void>;
|
|
17
17
|
/**
|
|
18
18
|
* Selects the tools to include in the MCP Server based on the provided options.
|
|
@@ -21,5 +21,9 @@ export declare function selectTools(options?: McpOptions): McpTool[];
|
|
|
21
21
|
/**
|
|
22
22
|
* Runs the provided handler with the given client and arguments.
|
|
23
23
|
*/
|
|
24
|
-
export declare function executeHandler(handler
|
|
24
|
+
export declare function executeHandler({ handler, reqContext, args, }: {
|
|
25
|
+
handler: HandlerFunction;
|
|
26
|
+
reqContext: McpRequestContext;
|
|
27
|
+
args: Record<string, unknown> | undefined;
|
|
28
|
+
}): Promise<ToolCallResult>;
|
|
25
29
|
//# sourceMappingURL=server.d.mts.map
|
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,YAAY;
|
|
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,YAAY;OAKnC,EAAE,UAAU,EAAE;OAEd,EAAE,eAAe,EAAE,iBAAiB,EAAE,cAAc,EAAE,OAAO,EAAE;AAEtE,eAAO,MAAM,YAAY,GAAU,iBAAiB,MAAM,GAAG,SAAS,uBAUnE,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;IACxB,eAAe,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACtC,iBA2EA;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,OAAO,CAAC,EAAE,UAAU,GAAG,OAAO,EAAE,CAU3D;AAED;;GAEG;AACH,wBAAsB,cAAc,CAAC,EACnC,OAAO,EACP,UAAU,EACV,IAAI,GACL,EAAE;IACD,OAAO,EAAE,eAAe,CAAC;IACzB,UAAU,EAAE,iBAAiB,CAAC;IAC9B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC;CAC3C,GAAG,OAAO,CAAC,cAAc,CAAC,CAE1B"}
|
package/server.d.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
2
2
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
3
3
|
import { ClientOptions } from 'profoundai';
|
|
4
|
-
import Profound from 'profoundai';
|
|
5
4
|
import { McpOptions } from "./options.js";
|
|
6
|
-
import { HandlerFunction, McpTool } from "./types.js";
|
|
7
|
-
export declare const newMcpServer: () => Promise<McpServer>;
|
|
5
|
+
import { HandlerFunction, McpRequestContext, ToolCallResult, McpTool } from "./types.js";
|
|
6
|
+
export declare const newMcpServer: (stainlessApiKey: string | undefined) => Promise<McpServer>;
|
|
8
7
|
/**
|
|
9
8
|
* Initializes the provided MCP Server with the given tools and handlers.
|
|
10
9
|
* If not provided, the default client, tools and handlers will be used.
|
|
@@ -13,6 +12,7 @@ export declare function initMcpServer(params: {
|
|
|
13
12
|
server: Server | McpServer;
|
|
14
13
|
clientOptions?: ClientOptions;
|
|
15
14
|
mcpOptions?: McpOptions;
|
|
15
|
+
stainlessApiKey?: string | undefined;
|
|
16
16
|
}): Promise<void>;
|
|
17
17
|
/**
|
|
18
18
|
* Selects the tools to include in the MCP Server based on the provided options.
|
|
@@ -21,5 +21,9 @@ export declare function selectTools(options?: McpOptions): McpTool[];
|
|
|
21
21
|
/**
|
|
22
22
|
* Runs the provided handler with the given client and arguments.
|
|
23
23
|
*/
|
|
24
|
-
export declare function executeHandler(handler
|
|
24
|
+
export declare function executeHandler({ handler, reqContext, args, }: {
|
|
25
|
+
handler: HandlerFunction;
|
|
26
|
+
reqContext: McpRequestContext;
|
|
27
|
+
args: Record<string, unknown> | undefined;
|
|
28
|
+
}): Promise<ToolCallResult>;
|
|
25
29
|
//# sourceMappingURL=server.d.ts.map
|
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,YAAY;
|
|
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,YAAY;OAKnC,EAAE,UAAU,EAAE;OAEd,EAAE,eAAe,EAAE,iBAAiB,EAAE,cAAc,EAAE,OAAO,EAAE;AAEtE,eAAO,MAAM,YAAY,GAAU,iBAAiB,MAAM,GAAG,SAAS,uBAUnE,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;IACxB,eAAe,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACtC,iBA2EA;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,OAAO,CAAC,EAAE,UAAU,GAAG,OAAO,EAAE,CAU3D;AAED;;GAEG;AACH,wBAAsB,cAAc,CAAC,EACnC,OAAO,EACP,UAAU,EACV,IAAI,GACL,EAAE;IACD,OAAO,EAAE,eAAe,CAAC;IACzB,UAAU,EAAE,iBAAiB,CAAC;IAC9B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC;CAC3C,GAAG,OAAO,CAAC,cAAc,CAAC,CAE1B"}
|
package/server.js
CHANGED
|
@@ -13,39 +13,13 @@ const types_js_1 = require("@modelcontextprotocol/sdk/types.js");
|
|
|
13
13
|
const profoundai_1 = __importDefault(require("profoundai"));
|
|
14
14
|
const code_tool_1 = require("./code-tool.js");
|
|
15
15
|
const docs_search_tool_1 = __importDefault(require("./docs-search-tool.js"));
|
|
16
|
+
const instructions_1 = require("./instructions.js");
|
|
16
17
|
const methods_1 = require("./methods.js");
|
|
17
|
-
const
|
|
18
|
-
async function getInstructions() {
|
|
19
|
-
// This API key is optional; providing it allows the server to fetch instructions for unreleased versions.
|
|
20
|
-
const stainlessAPIKey = (0, util_1.readEnv)('STAINLESS_API_KEY');
|
|
21
|
-
const response = await fetch((0, util_1.readEnv)('CODE_MODE_INSTRUCTIONS_URL') ?? 'https://api.stainless.com/api/ai/instructions/profound', {
|
|
22
|
-
method: 'GET',
|
|
23
|
-
headers: { ...(stainlessAPIKey && { Authorization: stainlessAPIKey }) },
|
|
24
|
-
});
|
|
25
|
-
let instructions;
|
|
26
|
-
if (!response.ok) {
|
|
27
|
-
console.warn('Warning: failed to retrieve MCP server instructions. Proceeding with default instructions...');
|
|
28
|
-
instructions = `
|
|
29
|
-
This is the profound MCP server. You will use Code Mode to help the user perform
|
|
30
|
-
actions. You can use search_docs tool to learn about how to take action with this server. Then,
|
|
31
|
-
you will write TypeScript code using the execute tool take action. It is CRITICAL that you be
|
|
32
|
-
thoughtful and deliberate when executing code. Always try to entirely solve the problem in code
|
|
33
|
-
block: it can be as long as you need to get the job done!
|
|
34
|
-
`;
|
|
35
|
-
}
|
|
36
|
-
instructions ??= (await response.json()).instructions;
|
|
37
|
-
instructions = `
|
|
38
|
-
The current time in Unix timestamps is ${Date.now()}.
|
|
39
|
-
|
|
40
|
-
${instructions}
|
|
41
|
-
`;
|
|
42
|
-
return instructions;
|
|
43
|
-
}
|
|
44
|
-
const newMcpServer = async () => new mcp_js_1.McpServer({
|
|
18
|
+
const newMcpServer = async (stainlessApiKey) => new mcp_js_1.McpServer({
|
|
45
19
|
name: 'profoundai_api',
|
|
46
|
-
version: '0.26.
|
|
20
|
+
version: '0.26.2',
|
|
47
21
|
}, {
|
|
48
|
-
instructions: await getInstructions(),
|
|
22
|
+
instructions: await (0, instructions_1.getInstructions)(stainlessApiKey),
|
|
49
23
|
capabilities: { tools: {}, logging: {} },
|
|
50
24
|
});
|
|
51
25
|
exports.newMcpServer = newMcpServer;
|
|
@@ -88,7 +62,14 @@ async function initMcpServer(params) {
|
|
|
88
62
|
if (!mcpTool) {
|
|
89
63
|
throw new Error(`Unknown tool: ${name}`);
|
|
90
64
|
}
|
|
91
|
-
return executeHandler(
|
|
65
|
+
return executeHandler({
|
|
66
|
+
handler: mcpTool.handler,
|
|
67
|
+
reqContext: {
|
|
68
|
+
client,
|
|
69
|
+
stainlessApiKey: params.stainlessApiKey ?? params.mcpOptions?.stainlessApiKey,
|
|
70
|
+
},
|
|
71
|
+
args,
|
|
72
|
+
});
|
|
92
73
|
});
|
|
93
74
|
server.setRequestHandler(types_js_1.SetLevelRequestSchema, async (request) => {
|
|
94
75
|
const { level } = request.params;
|
|
@@ -130,7 +111,7 @@ function selectTools(options) {
|
|
|
130
111
|
/**
|
|
131
112
|
* Runs the provided handler with the given client and arguments.
|
|
132
113
|
*/
|
|
133
|
-
async function executeHandler(handler,
|
|
134
|
-
return await handler(
|
|
114
|
+
async function executeHandler({ handler, reqContext, args, }) {
|
|
115
|
+
return await handler({ reqContext, args: args || {} });
|
|
135
116
|
}
|
|
136
117
|
//# sourceMappingURL=server.js.map
|
package/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["src/server.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;;;;
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["src/server.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;;;;AAkCtF,sCAgFC;AAKD,kCAUC;AAKD,wCAUC;AA7ID,oEAAoE;AACpE,iEAI4C;AAE5C,4DAAkC;AAClC,8CAAuC;AACvC,6EAAgD;AAChD,oDAAiD;AAEjD,0CAAsD;AAG/C,MAAM,YAAY,GAAG,KAAK,EAAE,eAAmC,EAAE,EAAE,CACxE,IAAI,kBAAS,CACX;IACE,IAAI,EAAE,gBAAgB;IACtB,OAAO,EAAE,QAAQ;CAClB,EACD;IACE,YAAY,EAAE,MAAM,IAAA,8BAAe,EAAC,eAAe,CAAC;IACpD,YAAY,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;CACzC,CACF,CA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AQ,EAAE,OAAO,EAAE,CAAC,CAAC;gBACnD,MAAM;YACR;gBACE,MAAM,GAAG,MAAM,CAAC,WAAW,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC;gBACjD,MAAM;QACV,CAAC;QACD,OAAO,EAAE,CAAC;IACZ,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;GAEG;AACH,SAAgB,WAAW,CAAC,OAAoB;IAC9C,MAAM,aAAa,GAAG;QACpB,IAAA,oBAAQ,EAAC;YACP,cAAc,EAAE,IAAA,mCAAyB,EAAC,OAAO,CAAC;SACnD,CAAC;KACH,CAAC;IACF,IAAI,OAAO,EAAE,gBAAgB,IAAI,IAAI,EAAE,CAAC;QACtC,aAAa,CAAC,IAAI,CAAC,0BAAc,CAAC,CAAC;IACrC,CAAC;IACD,OAAO,aAAa,CAAC;AACvB,CAAC;AAED;;GAEG;AACI,KAAK,UAAU,cAAc,CAAC,EACnC,OAAO,EACP,UAAU,EACV,IAAI,GAKL;IACC,OAAO,MAAM,OAAO,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,IAAI,IAAI,EAAE,EAAE,CAAC,CAAC;AACzD,CAAC"}
|
package/server.mjs
CHANGED
|
@@ -4,39 +4,13 @@ import { CallToolRequestSchema, ListToolsRequestSchema, SetLevelRequestSchema, }
|
|
|
4
4
|
import Profound from 'profoundai';
|
|
5
5
|
import { codeTool } from "./code-tool.mjs";
|
|
6
6
|
import docsSearchTool from "./docs-search-tool.mjs";
|
|
7
|
+
import { getInstructions } from "./instructions.mjs";
|
|
7
8
|
import { blockedMethodsForCodeTool } from "./methods.mjs";
|
|
8
|
-
|
|
9
|
-
async function getInstructions() {
|
|
10
|
-
// This API key is optional; providing it allows the server to fetch instructions for unreleased versions.
|
|
11
|
-
const stainlessAPIKey = readEnv('STAINLESS_API_KEY');
|
|
12
|
-
const response = await fetch(readEnv('CODE_MODE_INSTRUCTIONS_URL') ?? 'https://api.stainless.com/api/ai/instructions/profound', {
|
|
13
|
-
method: 'GET',
|
|
14
|
-
headers: { ...(stainlessAPIKey && { Authorization: stainlessAPIKey }) },
|
|
15
|
-
});
|
|
16
|
-
let instructions;
|
|
17
|
-
if (!response.ok) {
|
|
18
|
-
console.warn('Warning: failed to retrieve MCP server instructions. Proceeding with default instructions...');
|
|
19
|
-
instructions = `
|
|
20
|
-
This is the profound MCP server. You will use Code Mode to help the user perform
|
|
21
|
-
actions. You can use search_docs tool to learn about how to take action with this server. Then,
|
|
22
|
-
you will write TypeScript code using the execute tool take action. It is CRITICAL that you be
|
|
23
|
-
thoughtful and deliberate when executing code. Always try to entirely solve the problem in code
|
|
24
|
-
block: it can be as long as you need to get the job done!
|
|
25
|
-
`;
|
|
26
|
-
}
|
|
27
|
-
instructions ??= (await response.json()).instructions;
|
|
28
|
-
instructions = `
|
|
29
|
-
The current time in Unix timestamps is ${Date.now()}.
|
|
30
|
-
|
|
31
|
-
${instructions}
|
|
32
|
-
`;
|
|
33
|
-
return instructions;
|
|
34
|
-
}
|
|
35
|
-
export const newMcpServer = async () => new McpServer({
|
|
9
|
+
export const newMcpServer = async (stainlessApiKey) => new McpServer({
|
|
36
10
|
name: 'profoundai_api',
|
|
37
|
-
version: '0.26.
|
|
11
|
+
version: '0.26.2',
|
|
38
12
|
}, {
|
|
39
|
-
instructions: await getInstructions(),
|
|
13
|
+
instructions: await getInstructions(stainlessApiKey),
|
|
40
14
|
capabilities: { tools: {}, logging: {} },
|
|
41
15
|
});
|
|
42
16
|
/**
|
|
@@ -78,7 +52,14 @@ export async function initMcpServer(params) {
|
|
|
78
52
|
if (!mcpTool) {
|
|
79
53
|
throw new Error(`Unknown tool: ${name}`);
|
|
80
54
|
}
|
|
81
|
-
return executeHandler(
|
|
55
|
+
return executeHandler({
|
|
56
|
+
handler: mcpTool.handler,
|
|
57
|
+
reqContext: {
|
|
58
|
+
client,
|
|
59
|
+
stainlessApiKey: params.stainlessApiKey ?? params.mcpOptions?.stainlessApiKey,
|
|
60
|
+
},
|
|
61
|
+
args,
|
|
62
|
+
});
|
|
82
63
|
});
|
|
83
64
|
server.setRequestHandler(SetLevelRequestSchema, async (request) => {
|
|
84
65
|
const { level } = request.params;
|
|
@@ -120,7 +101,7 @@ export function selectTools(options) {
|
|
|
120
101
|
/**
|
|
121
102
|
* Runs the provided handler with the given client and arguments.
|
|
122
103
|
*/
|
|
123
|
-
export async function executeHandler(handler,
|
|
124
|
-
return await handler(
|
|
104
|
+
export async function executeHandler({ handler, reqContext, args, }) {
|
|
105
|
+
return await handler({ reqContext, args: args || {} });
|
|
125
106
|
}
|
|
126
107
|
//# sourceMappingURL=server.mjs.map
|
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,QAAQ,MAAM,YAAY;OAC1B,EAAE,QAAQ,EAAE;OACZ,cAAc;
|
|
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,QAAQ,MAAM,YAAY;OAC1B,EAAE,QAAQ,EAAE;OACZ,cAAc;OACd,EAAE,eAAe,EAAE;OAEnB,EAAE,yBAAyB,EAAE;AAGpC,MAAM,CAAC,MAAM,YAAY,GAAG,KAAK,EAAE,eAAmC,EAAE,EAAE,CACxE,IAAI,SAAS,CACX;IACE,IAAI,EAAE,gBAAgB;IACtB,OAAO,EAAE,QAAQ;CAClB,EACD;IACE,YAAY,EAAE,MAAM,eAAe,CAAC,eAAe,CAAC;IACpD,YAAY,EAAE,EAAE,KAAK,EA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AG,MAAM,CAAC,WAAW,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,CAAC;gBACnD,MAAM;YACR;gBACE,MAAM,GAAG,MAAM,CAAC,WAAW,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC;gBACjD,MAAM;QACV,CAAC;QACD,OAAO,EAAE,CAAC;IACZ,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,WAAW,CAAC,OAAoB;IAC9C,MAAM,aAAa,GAAG;QACpB,QAAQ,CAAC;YACP,cAAc,EAAE,yBAAyB,CAAC,OAAO,CAAC;SACnD,CAAC;KACH,CAAC;IACF,IAAI,OAAO,EAAE,gBAAgB,IAAI,IAAI,EAAE,CAAC;QACtC,aAAa,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;IACrC,CAAC;IACD,OAAO,aAAa,CAAC;AACvB,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,EACnC,OAAO,EACP,UAAU,EACV,IAAI,GAKL;IACC,OAAO,MAAM,OAAO,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,IAAI,IAAI,EAAE,EAAE,CAAC,CAAC;AACzD,CAAC"}
|
package/src/auth.ts
CHANGED
|
@@ -2,9 +2,24 @@
|
|
|
2
2
|
|
|
3
3
|
import { IncomingMessage } from 'node:http';
|
|
4
4
|
import { ClientOptions } from 'profoundai';
|
|
5
|
+
import { McpOptions } from './options';
|
|
5
6
|
|
|
6
|
-
export const
|
|
7
|
+
export const parseClientAuthHeaders = (req: IncomingMessage, required?: boolean): Partial<ClientOptions> => {
|
|
7
8
|
const apiKey =
|
|
8
9
|
Array.isArray(req.headers['x-api-key']) ? req.headers['x-api-key'][0] : req.headers['x-api-key'];
|
|
9
10
|
return { apiKey };
|
|
10
11
|
};
|
|
12
|
+
|
|
13
|
+
export const getStainlessApiKey = (req: IncomingMessage, mcpOptions: McpOptions): string | undefined => {
|
|
14
|
+
// Try to get the key from the x-stainless-api-key header
|
|
15
|
+
const headerKey =
|
|
16
|
+
Array.isArray(req.headers['x-stainless-api-key']) ?
|
|
17
|
+
req.headers['x-stainless-api-key'][0]
|
|
18
|
+
: req.headers['x-stainless-api-key'];
|
|
19
|
+
if (headerKey && typeof headerKey === 'string') {
|
|
20
|
+
return headerKey;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// Fall back to value set in the mcpOptions (e.g. from environment variable), if provided
|
|
24
|
+
return mcpOptions.stainlessApiKey;
|
|
25
|
+
};
|