@mongodb-js/mcp-tools-assistant 3.0.0-prerelease.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assistantTool.d.ts +24 -0
- package/dist/assistantTool.d.ts.map +1 -0
- package/dist/assistantTool.js +37 -0
- package/dist/assistantTool.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- package/dist/tools/read/listKnowledgeSources.d.ts +29 -0
- package/dist/tools/read/listKnowledgeSources.d.ts.map +1 -0
- package/dist/tools/read/listKnowledgeSources.js +47 -0
- package/dist/tools/read/listKnowledgeSources.js.map +1 -0
- package/dist/tools/read/searchKnowledge.d.ts +48 -0
- package/dist/tools/read/searchKnowledge.d.ts.map +1 -0
- package/dist/tools/read/searchKnowledge.js +61 -0
- package/dist/tools/read/searchKnowledge.js.map +1 -0
- package/dist/tools/tools.d.ts +3 -0
- package/dist/tools/tools.d.ts.map +1 -0
- package/dist/tools/tools.js +3 -0
- package/dist/tools/tools.js.map +1 -0
- package/package.json +37 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ToolBase } from "@mongodb-js/mcp-core";
|
|
2
|
+
import type { ToolConstructorParams } from "@mongodb-js/mcp-core";
|
|
3
|
+
import type { TelemetryToolMetadata, IToolConfig, ToolCategory, ISession } from "@mongodb-js/mcp-types";
|
|
4
|
+
export declare const DEFAULT_ASSISTANT_BASE_URL = "https://knowledge.mongodb.com/api/v1/";
|
|
5
|
+
export interface IAssistantConfig extends IToolConfig {
|
|
6
|
+
assistantBaseUrl?: string;
|
|
7
|
+
serverVersion?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface IAssistantSession extends ISession {
|
|
10
|
+
config: IAssistantConfig;
|
|
11
|
+
}
|
|
12
|
+
export declare abstract class AssistantToolBase extends ToolBase<IAssistantSession> {
|
|
13
|
+
static category: ToolCategory;
|
|
14
|
+
protected baseUrl: URL;
|
|
15
|
+
protected requiredHeaders: Headers;
|
|
16
|
+
constructor(params: ToolConstructorParams<IAssistantSession>);
|
|
17
|
+
protected resolveTelemetryMetadata(): TelemetryToolMetadata;
|
|
18
|
+
protected callAssistantApi(args: {
|
|
19
|
+
method: "GET" | "POST";
|
|
20
|
+
endpoint: string;
|
|
21
|
+
body?: unknown;
|
|
22
|
+
}): Promise<Response>;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=assistantTool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assistantTool.d.ts","sourceRoot":"","sources":["../src/assistantTool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAClE,OAAO,KAAK,EAAE,qBAAqB,EAAE,WAAW,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAGxG,eAAO,MAAM,0BAA0B,0CAA0C,CAAC;AAElF,MAAM,WAAW,gBAAiB,SAAQ,WAAW;IACjD,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,aAAa,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,iBAAkB,SAAQ,QAAQ;IAC/C,MAAM,EAAE,gBAAgB,CAAC;CAC5B;AAED,8BAAsB,iBAAkB,SAAQ,QAAQ,CAAC,iBAAiB,CAAC;IACvE,MAAM,CAAC,QAAQ,EAAE,YAAY,CAAe;IAE5C,SAAS,CAAC,OAAO,EAAE,GAAG,CAAC;IACvB,SAAS,CAAC,eAAe,EAAE,OAAO,CAAC;gBAEvB,MAAM,EAAE,qBAAqB,CAAC,iBAAiB,CAAC;IAW5D,SAAS,CAAC,wBAAwB,IAAI,qBAAqB;cAM3C,gBAAgB,CAAC,IAAI,EAAE;QACnC,MAAM,EAAE,KAAK,GAAG,MAAM,CAAC;QACvB,QAAQ,EAAE,MAAM,CAAC;QACjB,IAAI,CAAC,EAAE,OAAO,CAAC;KAClB,GAAG,OAAO,CAAC,QAAQ,CAAC;CAiBxB"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { ToolBase } from "@mongodb-js/mcp-core";
|
|
2
|
+
import { getSharedProxyFetch } from "@mongodb-js/mcp-fetch";
|
|
3
|
+
export const DEFAULT_ASSISTANT_BASE_URL = "https://knowledge.mongodb.com/api/v1/";
|
|
4
|
+
export class AssistantToolBase extends ToolBase {
|
|
5
|
+
constructor(params) {
|
|
6
|
+
super(params);
|
|
7
|
+
this.baseUrl = new URL(params.session.config.assistantBaseUrl ?? DEFAULT_ASSISTANT_BASE_URL);
|
|
8
|
+
this.requiredHeaders = new Headers({
|
|
9
|
+
"x-request-origin": "mongodb-mcp-server",
|
|
10
|
+
"user-agent": params.session.config.serverVersion
|
|
11
|
+
? `mongodb-mcp-server/v${params.session.config.serverVersion}`
|
|
12
|
+
: "mongodb-mcp-server",
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
resolveTelemetryMetadata() {
|
|
16
|
+
// Assistant tool calls are not associated with a specific Atlas project or organization
|
|
17
|
+
// Therefore, we don't have any values to add to the telemetry metadata
|
|
18
|
+
return {};
|
|
19
|
+
}
|
|
20
|
+
async callAssistantApi(args) {
|
|
21
|
+
const endpointUrl = new URL(args.endpoint, this.baseUrl);
|
|
22
|
+
const headers = new Headers(this.requiredHeaders);
|
|
23
|
+
if (args.method === "POST") {
|
|
24
|
+
headers.set("Content-Type", "application/json");
|
|
25
|
+
}
|
|
26
|
+
// Same shared, memoized fetch as the Atlas API client (proxy support
|
|
27
|
+
// without reloading the system CA per call).
|
|
28
|
+
const customFetch = getSharedProxyFetch();
|
|
29
|
+
return await customFetch(endpointUrl, {
|
|
30
|
+
method: args.method,
|
|
31
|
+
headers,
|
|
32
|
+
body: JSON.stringify(args.body),
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
AssistantToolBase.category = "assistant";
|
|
37
|
+
//# sourceMappingURL=assistantTool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assistantTool.js","sourceRoot":"","sources":["../src/assistantTool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAGhD,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D,MAAM,CAAC,MAAM,0BAA0B,GAAG,uCAAuC,CAAC;AAWlF,MAAM,OAAgB,iBAAkB,SAAQ,QAA2B;IAMvE,YAAY,MAAgD;QACxD,KAAK,CAAC,MAAM,CAAC,CAAC;QACd,IAAI,CAAC,OAAO,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,gBAAgB,IAAI,0BAA0B,CAAC,CAAC;QAC7F,IAAI,CAAC,eAAe,GAAG,IAAI,OAAO,CAAC;YAC/B,kBAAkB,EAAE,oBAAoB;YACxC,YAAY,EAAE,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,aAAa;gBAC7C,CAAC,CAAC,uBAAuB,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,aAAa,EAAE;gBAC9D,CAAC,CAAC,oBAAoB;SAC7B,CAAC,CAAC;IACP,CAAC;IAES,wBAAwB;QAC9B,wFAAwF;QACxF,uEAAuE;QACvE,OAAO,EAAE,CAAC;IACd,CAAC;IAES,KAAK,CAAC,gBAAgB,CAAC,IAIhC;QACG,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QACzD,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;QAClD,IAAI,IAAI,CAAC,MAAM,KAAK,MAAM,EAAE,CAAC;YACzB,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,kBAAkB,CAAC,CAAC;QACpD,CAAC;QAED,qEAAqE;QACrE,6CAA6C;QAC7C,MAAM,WAAW,GAAG,mBAAmB,EAAE,CAAC;QAE1C,OAAO,MAAM,WAAW,CAAC,WAAW,EAAE;YAClC,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,OAAO;YACP,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC;SAClC,CAAC,CAAC;IACP,CAAC;;AA1CM,0BAAQ,GAAiB,WAAW,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { AssistantToolBase, type IAssistantSession } from "./assistantTool.js";
|
|
2
|
+
export { SearchKnowledgeTool, SearchKnowledgeToolName, ListKnowledgeSourcesTool, ListKnowledgeSourcesToolName, } from "./tools/tools.js";
|
|
3
|
+
import type { IAssistantSession } from "./assistantTool.js";
|
|
4
|
+
import type { ToolClass } from "@mongodb-js/mcp-core";
|
|
5
|
+
export declare const AssistantTools: ToolClass<IAssistantSession>[];
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,KAAK,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC/E,OAAO,EACH,mBAAmB,EACnB,uBAAuB,EACvB,wBAAwB,EACxB,4BAA4B,GAC/B,MAAM,kBAAkB,CAAC;AAE1B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAE5D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEtD,eAAO,MAAM,cAAc,EAAE,SAAS,CAAC,iBAAiB,CAAC,EAAoD,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { AssistantToolBase } from "./assistantTool.js";
|
|
2
|
+
export { SearchKnowledgeTool, SearchKnowledgeToolName, ListKnowledgeSourcesTool, ListKnowledgeSourcesToolName, } from "./tools/tools.js";
|
|
3
|
+
import { SearchKnowledgeTool, ListKnowledgeSourcesTool } from "./tools/tools.js";
|
|
4
|
+
export const AssistantTools = [SearchKnowledgeTool, ListKnowledgeSourcesTool];
|
|
5
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAA0B,MAAM,oBAAoB,CAAC;AAC/E,OAAO,EACH,mBAAmB,EACnB,uBAAuB,EACvB,wBAAwB,EACxB,4BAA4B,GAC/B,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EAAE,mBAAmB,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AAGjF,MAAM,CAAC,MAAM,cAAc,GAAmC,CAAC,mBAAmB,EAAE,wBAAwB,CAAC,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { CallToolResult } from "@mongodb-js/mcp-types";
|
|
2
|
+
import type { OperationType, ToolCategory } from "@mongodb-js/mcp-types";
|
|
3
|
+
import { AssistantToolBase } from "../../assistantTool.js";
|
|
4
|
+
export type KnowledgeSource = {
|
|
5
|
+
/** The name of the data source */
|
|
6
|
+
id: string;
|
|
7
|
+
/** The type of the data source */
|
|
8
|
+
type: string;
|
|
9
|
+
/** A list of available versions for this data source */
|
|
10
|
+
versions: {
|
|
11
|
+
/** The version label of the data source */
|
|
12
|
+
label: string;
|
|
13
|
+
/** Whether this version is the current/default version */
|
|
14
|
+
isCurrent: boolean;
|
|
15
|
+
}[];
|
|
16
|
+
};
|
|
17
|
+
export type ListKnowledgeSourcesResponse = {
|
|
18
|
+
dataSources: KnowledgeSource[];
|
|
19
|
+
};
|
|
20
|
+
export declare const ListKnowledgeSourcesToolName = "list-knowledge-sources";
|
|
21
|
+
export declare class ListKnowledgeSourcesTool extends AssistantToolBase {
|
|
22
|
+
static toolName: string;
|
|
23
|
+
static category: ToolCategory;
|
|
24
|
+
static operationType: OperationType;
|
|
25
|
+
description: string;
|
|
26
|
+
argsShape: {};
|
|
27
|
+
protected execute(): Promise<CallToolResult>;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=listKnowledgeSources.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"listKnowledgeSources.d.ts","sourceRoot":"","sources":["../../../src/tools/read/listKnowledgeSources.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAE5D,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAEzE,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAG3D,MAAM,MAAM,eAAe,GAAG;IAC1B,kCAAkC;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,kCAAkC;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,wDAAwD;IACxD,QAAQ,EAAE;QACN,2CAA2C;QAC3C,KAAK,EAAE,MAAM,CAAC;QACd,0DAA0D;QAC1D,SAAS,EAAE,OAAO,CAAC;KACtB,EAAE,CAAC;CACP,CAAC;AAEF,MAAM,MAAM,4BAA4B,GAAG;IACvC,WAAW,EAAE,eAAe,EAAE,CAAC;CAClC,CAAC;AAEF,eAAO,MAAM,4BAA4B,2BAA2B,CAAC;AAErE,qBAAa,wBAAyB,SAAQ,iBAAiB;IAC3D,MAAM,CAAC,QAAQ,SAAgC;IAC/C,MAAM,CAAC,QAAQ,EAAE,YAAY,CAAe;IAC5C,MAAM,CAAC,aAAa,EAAE,aAAa,CAAU;IACtC,WAAW,SAAqL;IAChM,SAAS,KAAM;cAEN,OAAO,IAAI,OAAO,CAAC,cAAc,CAAC;CAsCrD"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { formatUntrustedData } from "@mongodb-js/mcp-core";
|
|
2
|
+
import { LogId } from "@mongodb-js/mcp-core";
|
|
3
|
+
import { AssistantToolBase } from "../../assistantTool.js";
|
|
4
|
+
import { stringify as yamlStringify } from "yaml";
|
|
5
|
+
export const ListKnowledgeSourcesToolName = "list-knowledge-sources";
|
|
6
|
+
export class ListKnowledgeSourcesTool extends AssistantToolBase {
|
|
7
|
+
constructor() {
|
|
8
|
+
super(...arguments);
|
|
9
|
+
this.description = `List available data sources in the MongoDB Assistant knowledge base. Use this to explore available data sources or to find search filter parameters to use in search-knowledge.`;
|
|
10
|
+
this.argsShape = {};
|
|
11
|
+
}
|
|
12
|
+
async execute() {
|
|
13
|
+
const response = await this.callAssistantApi({
|
|
14
|
+
method: "GET",
|
|
15
|
+
endpoint: "content/sources",
|
|
16
|
+
});
|
|
17
|
+
if (!response.ok) {
|
|
18
|
+
const message = `Failed to list knowledge sources: ${response.statusText}`;
|
|
19
|
+
this.session.logger.debug({
|
|
20
|
+
id: LogId.assistantListKnowledgeSourcesError,
|
|
21
|
+
context: "assistant-list-knowledge-sources",
|
|
22
|
+
message,
|
|
23
|
+
});
|
|
24
|
+
return {
|
|
25
|
+
content: [
|
|
26
|
+
{
|
|
27
|
+
type: "text",
|
|
28
|
+
text: message,
|
|
29
|
+
},
|
|
30
|
+
],
|
|
31
|
+
isError: true,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
const { dataSources } = (await response.json());
|
|
35
|
+
const text = yamlStringify(dataSources.map((ds) => {
|
|
36
|
+
const currentVersion = ds.versions.find(({ isCurrent }) => isCurrent)?.label;
|
|
37
|
+
return currentVersion ? { ...ds, currentVersion } : ds;
|
|
38
|
+
}));
|
|
39
|
+
return {
|
|
40
|
+
content: formatUntrustedData(`Found ${dataSources.length} data sources in the MongoDB Assistant knowledge base.`, text),
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
ListKnowledgeSourcesTool.toolName = ListKnowledgeSourcesToolName;
|
|
45
|
+
ListKnowledgeSourcesTool.category = "assistant";
|
|
46
|
+
ListKnowledgeSourcesTool.operationType = "read";
|
|
47
|
+
//# sourceMappingURL=listKnowledgeSources.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"listKnowledgeSources.js","sourceRoot":"","sources":["../../../src/tools/read/listKnowledgeSources.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAE3D,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,SAAS,IAAI,aAAa,EAAE,MAAM,MAAM,CAAC;AAoBlD,MAAM,CAAC,MAAM,4BAA4B,GAAG,wBAAwB,CAAC;AAErE,MAAM,OAAO,wBAAyB,SAAQ,iBAAiB;IAA/D;;QAIW,gBAAW,GAAG,iLAAiL,CAAC;QAChM,cAAS,GAAG,EAAE,CAAC;IAwC1B,CAAC;IAtCa,KAAK,CAAC,OAAO;QACnB,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC;YACzC,MAAM,EAAE,KAAK;YACb,QAAQ,EAAE,iBAAiB;SAC9B,CAAC,CAAC;QACH,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;YACf,MAAM,OAAO,GAAG,qCAAqC,QAAQ,CAAC,UAAU,EAAE,CAAC;YAC3E,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC;gBACtB,EAAE,EAAE,KAAK,CAAC,kCAAkC;gBAC5C,OAAO,EAAE,kCAAkC;gBAC3C,OAAO;aACV,CAAC,CAAC;YACH,OAAO;gBACH,OAAO,EAAE;oBACL;wBACI,IAAI,EAAE,MAAM;wBACZ,IAAI,EAAE,OAAO;qBAChB;iBACJ;gBACD,OAAO,EAAE,IAAI;aAChB,CAAC;QACN,CAAC;QACD,MAAM,EAAE,WAAW,EAAE,GAAG,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAiC,CAAC;QAEhF,MAAM,IAAI,GAAG,aAAa,CACtB,WAAW,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE;YACnB,MAAM,cAAc,GAAG,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC,SAAS,CAAC,EAAE,KAAK,CAAC;YAC7E,OAAO,cAAc,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,EAAE,cAAc,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC3D,CAAC,CAAC,CACL,CAAC;QAEF,OAAO;YACH,OAAO,EAAE,mBAAmB,CACxB,SAAS,WAAW,CAAC,MAAM,wDAAwD,EACnF,IAAI,CACP;SACJ,CAAC;IACN,CAAC;;AA3CM,iCAAQ,GAAG,4BAA4B,AAA/B,CAAgC;AACxC,iCAAQ,GAAiB,WAAW,AAA5B,CAA6B;AACrC,sCAAa,GAAkB,MAAM,AAAxB,CAAyB"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { CallToolResult } from "@mongodb-js/mcp-types";
|
|
3
|
+
import type { ToolArgs } from "@mongodb-js/mcp-core";
|
|
4
|
+
import type { OperationType, ToolCategory } from "@mongodb-js/mcp-types";
|
|
5
|
+
import { AssistantToolBase } from "../../assistantTool.js";
|
|
6
|
+
export declare const SearchKnowledgeToolArgs: {
|
|
7
|
+
query: z.ZodString;
|
|
8
|
+
limit: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
9
|
+
dataSources: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
10
|
+
name: z.ZodString;
|
|
11
|
+
versionLabel: z.ZodOptional<z.ZodString>;
|
|
12
|
+
}, z.core.$strip>>>;
|
|
13
|
+
};
|
|
14
|
+
export type SearchKnowledgeResponse = {
|
|
15
|
+
/** A list of search results */
|
|
16
|
+
results: {
|
|
17
|
+
/** The URL of the search result */
|
|
18
|
+
url: string;
|
|
19
|
+
/** The page title of the search result */
|
|
20
|
+
title: string;
|
|
21
|
+
/** The text of the page chunk returned from the search */
|
|
22
|
+
text: string;
|
|
23
|
+
/** Metadata for the search result */
|
|
24
|
+
metadata: {
|
|
25
|
+
/** A list of tags that describe the page */
|
|
26
|
+
tags: string[];
|
|
27
|
+
/** Additional metadata */
|
|
28
|
+
[key: string]: unknown;
|
|
29
|
+
};
|
|
30
|
+
}[];
|
|
31
|
+
};
|
|
32
|
+
export declare const SearchKnowledgeToolName = "search-knowledge";
|
|
33
|
+
export declare class SearchKnowledgeTool extends AssistantToolBase {
|
|
34
|
+
static toolName: string;
|
|
35
|
+
static category: ToolCategory;
|
|
36
|
+
static operationType: OperationType;
|
|
37
|
+
description: string;
|
|
38
|
+
argsShape: {
|
|
39
|
+
query: z.ZodString;
|
|
40
|
+
limit: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
41
|
+
dataSources: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
42
|
+
name: z.ZodString;
|
|
43
|
+
versionLabel: z.ZodOptional<z.ZodString>;
|
|
44
|
+
}, z.core.$strip>>>;
|
|
45
|
+
};
|
|
46
|
+
protected execute(args: ToolArgs<typeof this.argsShape>): Promise<CallToolResult>;
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=searchKnowledge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"searchKnowledge.d.ts","sourceRoot":"","sources":["../../../src/tools/read/searchKnowledge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAE5D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAEzE,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAG3D,eAAO,MAAM,uBAAuB;;;;;;;CAkBnC,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG;IAClC,+BAA+B;IAC/B,OAAO,EAAE;QACL,mCAAmC;QACnC,GAAG,EAAE,MAAM,CAAC;QACZ,0CAA0C;QAC1C,KAAK,EAAE,MAAM,CAAC;QACd,0DAA0D;QAC1D,IAAI,EAAE,MAAM,CAAC;QACb,qCAAqC;QACrC,QAAQ,EAAE;YACN,4CAA4C;YAC5C,IAAI,EAAE,MAAM,EAAE,CAAC;YACf,0BAA0B;YAC1B,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;SAC1B,CAAC;KACL,EAAE,CAAC;CACP,CAAC;AAEF,eAAO,MAAM,uBAAuB,qBAAqB,CAAC;AAE1D,qBAAa,mBAAoB,SAAQ,iBAAiB;IACtD,MAAM,CAAC,QAAQ,SAA2B;IAC1C,MAAM,CAAC,QAAQ,EAAE,YAAY,CAAe;IAC5C,MAAM,CAAC,aAAa,EAAE,aAAa,CAAU;IACtC,WAAW,SAC2M;IACtN,SAAS;;;;;;;MAEd;cAEc,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,OAAO,CAAC,cAAc,CAAC;CAkC1F"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { formatUntrustedData } from "@mongodb-js/mcp-core";
|
|
3
|
+
import { LogId } from "@mongodb-js/mcp-core";
|
|
4
|
+
import { AssistantToolBase } from "../../assistantTool.js";
|
|
5
|
+
import { stringify as yamlStringify } from "yaml";
|
|
6
|
+
export const SearchKnowledgeToolArgs = {
|
|
7
|
+
query: z
|
|
8
|
+
.string()
|
|
9
|
+
.describe("A natural language query to search for in the MongoDB Assistant knowledge base. This should be a single question or a topic that is relevant to the user's MongoDB use case."),
|
|
10
|
+
limit: z.number().min(1).max(100).optional().default(5).describe("The maximum number of results to return"),
|
|
11
|
+
dataSources: z
|
|
12
|
+
.array(z.object({
|
|
13
|
+
name: z.string().describe("The name of the data source"),
|
|
14
|
+
versionLabel: z.string().optional().describe("The version label of the data source"),
|
|
15
|
+
}))
|
|
16
|
+
.optional()
|
|
17
|
+
.describe(`A list of one or more data sources to limit the search to. You can specify a specific version of a data source by providing the version label. If not provided, the latest version of all data sources will be searched. Available data sources and their versions can be listed by calling the list-knowledge-sources tool.`),
|
|
18
|
+
};
|
|
19
|
+
export const SearchKnowledgeToolName = "search-knowledge";
|
|
20
|
+
export class SearchKnowledgeTool extends AssistantToolBase {
|
|
21
|
+
constructor() {
|
|
22
|
+
super(...arguments);
|
|
23
|
+
this.description = "Search for information in the MongoDB Assistant knowledge base. This includes official documentation, curated expert guidance, and other resources provided by MongoDB. Supports filtering by data source and version.";
|
|
24
|
+
this.argsShape = {
|
|
25
|
+
...SearchKnowledgeToolArgs,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
async execute(args) {
|
|
29
|
+
const response = await this.callAssistantApi({
|
|
30
|
+
method: "POST",
|
|
31
|
+
endpoint: "content/search",
|
|
32
|
+
body: args,
|
|
33
|
+
});
|
|
34
|
+
if (!response.ok) {
|
|
35
|
+
const message = `Failed to search knowledge base: ${response.statusText}`;
|
|
36
|
+
this.session.logger.debug({
|
|
37
|
+
id: LogId.assistantSearchKnowledgeError,
|
|
38
|
+
context: "assistant-search-knowledge",
|
|
39
|
+
message,
|
|
40
|
+
});
|
|
41
|
+
return {
|
|
42
|
+
content: [
|
|
43
|
+
{
|
|
44
|
+
type: "text",
|
|
45
|
+
text: message,
|
|
46
|
+
},
|
|
47
|
+
],
|
|
48
|
+
isError: true,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
const { results } = (await response.json());
|
|
52
|
+
const text = yamlStringify(results);
|
|
53
|
+
return {
|
|
54
|
+
content: formatUntrustedData(`Found ${results.length} results in the MongoDB Assistant knowledge base.`, text),
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
SearchKnowledgeTool.toolName = SearchKnowledgeToolName;
|
|
59
|
+
SearchKnowledgeTool.category = "assistant";
|
|
60
|
+
SearchKnowledgeTool.operationType = "read";
|
|
61
|
+
//# sourceMappingURL=searchKnowledge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"searchKnowledge.js","sourceRoot":"","sources":["../../../src/tools/read/searchKnowledge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAG3D,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,SAAS,IAAI,aAAa,EAAE,MAAM,MAAM,CAAC;AAElD,MAAM,CAAC,MAAM,uBAAuB,GAAG;IACnC,KAAK,EAAE,CAAC;SACH,MAAM,EAAE;SACR,QAAQ,CACL,8KAA8K,CACjL;IACL,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,yCAAyC,CAAC;IAC3G,WAAW,EAAE,CAAC;SACT,KAAK,CACF,CAAC,CAAC,MAAM,CAAC;QACL,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,6BAA6B,CAAC;QACxD,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,sCAAsC,CAAC;KACvF,CAAC,CACL;SACA,QAAQ,EAAE;SACV,QAAQ,CACL,8TAA8T,CACjU;CACR,CAAC;AAqBF,MAAM,CAAC,MAAM,uBAAuB,GAAG,kBAAkB,CAAC;AAE1D,MAAM,OAAO,mBAAoB,SAAQ,iBAAiB;IAA1D;;QAIW,gBAAW,GACd,wNAAwN,CAAC;QACtN,cAAS,GAAG;YACf,GAAG,uBAAuB;SAC7B,CAAC;IAoCN,CAAC;IAlCa,KAAK,CAAC,OAAO,CAAC,IAAqC;QACzD,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC;YACzC,MAAM,EAAE,MAAM;YACd,QAAQ,EAAE,gBAAgB;YAC1B,IAAI,EAAE,IAAI;SACb,CAAC,CAAC;QACH,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;YACf,MAAM,OAAO,GAAG,oCAAoC,QAAQ,CAAC,UAAU,EAAE,CAAC;YAC1E,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC;gBACtB,EAAE,EAAE,KAAK,CAAC,6BAA6B;gBACvC,OAAO,EAAE,4BAA4B;gBACrC,OAAO;aACV,CAAC,CAAC;YACH,OAAO;gBACH,OAAO,EAAE;oBACL;wBACI,IAAI,EAAE,MAAM;wBACZ,IAAI,EAAE,OAAO;qBAChB;iBACJ;gBACD,OAAO,EAAE,IAAI;aAChB,CAAC;QACN,CAAC;QACD,MAAM,EAAE,OAAO,EAAE,GAAG,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAA4B,CAAC;QAEvE,MAAM,IAAI,GAAG,aAAa,CAAC,OAAO,CAAC,CAAC;QAEpC,OAAO;YACH,OAAO,EAAE,mBAAmB,CACxB,SAAS,OAAO,CAAC,MAAM,mDAAmD,EAC1E,IAAI,CACP;SACJ,CAAC;IACN,CAAC;;AA1CM,4BAAQ,GAAG,uBAAuB,AAA1B,CAA2B;AACnC,4BAAQ,GAAiB,WAAW,AAA5B,CAA6B;AACrC,iCAAa,GAAkB,MAAM,AAAxB,CAAyB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../src/tools/tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACzF,OAAO,EAAE,wBAAwB,EAAE,4BAA4B,EAAE,MAAM,gCAAgC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.js","sourceRoot":"","sources":["../../src/tools/tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACzF,OAAO,EAAE,wBAAwB,EAAE,4BAA4B,EAAE,MAAM,gCAAgC,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@mongodb-js/mcp-tools-assistant",
|
|
3
|
+
"version": "3.0.0-prerelease.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "Assistant tools for the MongoDB MCP server",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"default": "./dist/index.js"
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
"main": "./dist/index.js",
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"files": [
|
|
15
|
+
"dist"
|
|
16
|
+
],
|
|
17
|
+
"scripts": {
|
|
18
|
+
"build": "tsc --build tsconfig.build.json",
|
|
19
|
+
"test": "vitest --run",
|
|
20
|
+
"check": "tsc --build tsconfig.build.json --noEmit"
|
|
21
|
+
},
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@mongodb-js/mcp-core": "workspace:*",
|
|
24
|
+
"@mongodb-js/mcp-fetch": "workspace:*",
|
|
25
|
+
"yaml": "^2.8.1",
|
|
26
|
+
"zod": "^4.0.0"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"@mongodb-js/mcp-types": "workspace:*",
|
|
30
|
+
"@types/node": "^25.6.0",
|
|
31
|
+
"typescript": "^5.9.2",
|
|
32
|
+
"vitest": "^4.1.4"
|
|
33
|
+
},
|
|
34
|
+
"publishConfig": {
|
|
35
|
+
"access": "public"
|
|
36
|
+
}
|
|
37
|
+
}
|