Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
0d44997
feat: add structured content for response in mongodb tools connect an…
dudaschar Jun 15, 2026
519407e
feat: add structured content for response in mongodb tool aggregate
dudaschar Jun 15, 2026
547c185
feat: add structured content for response in mongodb tool aggregateDB
dudaschar Jun 15, 2026
f5956af
feat: add structured content for response in mongodb tool count
dudaschar Jun 15, 2026
023b305
feat: add structured content for response in mongodb tool export
dudaschar Jun 15, 2026
21552cf
feat: add structured content for response in mongodb tool find
dudaschar Jun 15, 2026
01d0b67
refactor: unify ToolResult structure across MongoDB tools and remove …
dudaschar Jun 15, 2026
17e0ba7
Merge branch 'main' into MCP-374-structuredContent
dudaschar Jun 16, 2026
b6bb107
feat: add BSON to JSON serialization helper functions and integrate i…
dudaschar Jun 16, 2026
122c2a5
refactor: update document serialization in MongoDB tools to use JSON.…
dudaschar Jun 16, 2026
ef07952
docs: update public api docs with new output schema for structuredCon…
dudaschar Jun 16, 2026
0f9592b
refactor: remove unused output type definitions from MongoDB tools an…
dudaschar Jun 16, 2026
329d5bf
feat: enhance ConnectDeploymentTool with structured output schema and…
dudaschar Jun 17, 2026
061ea01
feat: implement structured output for CreateDeploymentTool and update…
dudaschar Jun 17, 2026
166f144
feat: implement structured output for DeleteDeploymentTool and update…
dudaschar Jun 17, 2026
11da0b5
feat: implement structured output for ListDeploymentsTool and update …
dudaschar Jun 17, 2026
b9f4b86
docs: update public api docs after output changes
dudaschar Jun 17, 2026
273051c
refactor: remove unused ListDeploymentsOutput type and update related…
dudaschar Jun 17, 2026
92a54b1
refactor: replace serializeBsonToJsonObjects with bsonToJson in Mongo…
dudaschar Jun 25, 2026
17c4b2f
refactor: revert export tool to main version
dudaschar Jun 25, 2026
3cf728f
refactor: update CURSOR_LIMIT_KEYS to use zod enum for improved type …
dudaschar Jun 25, 2026
3b4a6f9
refactor: rename aggResultsCount to count in aggregation output schema
dudaschar Jun 25, 2026
d1ccd42
Merge branch 'main' into MCP-374-structuredContent
dudaschar Jun 25, 2026
3cd5e3d
refactor: simplify document serialization in aggregation output by di…
dudaschar Jun 25, 2026
b434f1c
refactor: update CountOutputSchema to make count a required field
dudaschar Jun 25, 2026
31e3119
test: enhance bsonToJson tests to cover additional BSON types and JSO…
dudaschar Jun 25, 2026
75d4895
refactor: export FindOutputSchema and enhance structured content vali…
dudaschar Jun 25, 2026
912bb62
refactor: streamline appliedLimits handling in find tool
dudaschar Jun 25, 2026
38ee72c
refactor: simplify expectAggregateStructuredContent function by remov…
dudaschar Jun 25, 2026
57d8a47
Merge branch 'MCP-374-structuredContent' into MCP-374-structuredConte…
dudaschar Jun 25, 2026
1e44697
refactor: update resolveTelemetryMetadata method to use CallToolResult
dudaschar Jun 25, 2026
53dad36
refactor: update AggregateOutputSchema to allow 'indeterminate' as a …
dudaschar Jun 25, 2026
d22db29
docs: update public api documentation
dudaschar Jun 25, 2026
bcb4199
Merge branch 'main' into MCP-374-structuredContent
dudaschar Jun 25, 2026
e52ba42
Merge branch 'main' into MCP-374-structuredContent
dudaschar Jun 26, 2026
6d5931e
Merge branch 'MCP-374-structuredContent' into MCP-374-structuredConte…
dudaschar Jun 26, 2026
e6a2aae
docs: update public api docs with new output format
dudaschar Jun 26, 2026
e2426b2
fix: resolve conflict in AggregateTool outputSchema count type
dudaschar Jun 26, 2026
dd3795a
chore: release mongodb-mcp-server v1.14.0-prerelease.0 (#1286)
mongodb-devtools-bot[bot] Jun 26, 2026
c07449e
docs(atlas): clarify atlas-list-alerts returns triggered alerts, not …
blva Jun 26, 2026
4233f97
Merge branch 'main' into MCP-374-structuredContent-atlas-local
dudaschar Jun 29, 2026
e2d5a69
fix: remove error handle override from connect tool
dudaschar Jun 29, 2026
efe9a60
fix: wait for connection string when creating a deployment (#1291)
nirinchev Jun 29, 2026
75804f1
fix: mongot healtcheck failures (#1292)
nirinchev Jun 29, 2026
c17770b
ci: Integrate Braintrust eval suite CLOUDP-367319 (#1274)
nima-taheri-mongodb Jun 30, 2026
5c33bc0
Merge branch 'main' into MCP-374-structuredContent-atlas-local
dudaschar Jun 30, 2026
793a2f1
Merge branch 'main' into MCP-374-structuredContent-atlas-local
dudaschar Jun 30, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 32 additions & 8 deletions api-extractor/reports/tools.public.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -265,17 +265,22 @@ export class ConnectClusterTool extends AtlasToolBase {
export class ConnectDeploymentTool extends AtlasLocalToolBase {
// (undocumented)
argsShape: {
deploymentName: ZodString;
deploymentName: z.ZodString;
};
// (undocumented)
description: string;
// (undocumented)
protected executeWithAtlasLocalClient(input: ToolArgs<typeof ConnectDeploymentTool.argsShape>, input2: {
client: Client;
}): Promise<CallToolResult>;
}): Promise<ToolResult<typeof ConnectDeploymentOutputSchema> & Pick<CallToolResult, "_meta">>;
// (undocumented)
static operationType: OperationType;
// (undocumented)
outputSchema: {
connected: z.ZodBoolean;
deploymentName: z.ZodString;
};
// (undocumented)
protected resolveTelemetryMetadata(args: ToolArgs<typeof ConnectDeploymentTool.argsShape>, input: {
result: CallToolResult;
}): ConnectionMetadata;
Expand All @@ -295,8 +300,6 @@ export class ConnectTool extends MongoDBToolBase {
// (undocumented)
protected execute(input: ToolArgs<typeof ConnectTool.argsShape>): Promise<ToolResult<typeof ConnectTool.outputSchema>>;
// (undocumented)
protected handleError(error: unknown, args: ToolArgs<typeof ConnectTool.argsShape>): Promise<CallToolResult>;
// (undocumented)
static operationType: OperationType;
// (undocumented)
outputSchema: {
Expand Down Expand Up @@ -508,10 +511,17 @@ export class CreateDeploymentTool extends AtlasLocalToolBase {
// (undocumented)
protected executeWithAtlasLocalClient(input: ToolArgs<typeof CreateDeploymentTool.argsShape>, input2: {
client: Client;
}): Promise<CallToolResult>;
}): Promise<ToolResult<typeof CreateDeploymentOutputSchema> & Pick<CallToolResult, "_meta">>;
// (undocumented)
static operationType: OperationType;
// (undocumented)
outputSchema: {
deploymentName: z.ZodString;
containerId: z.ZodString;
loadSampleData: z.ZodBoolean;
imageTag: z.ZodString;
};
// (undocumented)
static toolName: string;
}

Expand Down Expand Up @@ -671,17 +681,22 @@ export class DbStatsTool extends MongoDBToolBase {
export class DeleteDeploymentTool extends AtlasLocalToolBase {
// (undocumented)
argsShape: {
deploymentName: ZodString;
deploymentName: z.ZodString;
};
// (undocumented)
description: string;
// (undocumented)
protected executeWithAtlasLocalClient(input: ToolArgs<typeof DeleteDeploymentTool.argsShape>, input2: {
client: Client;
}): Promise<CallToolResult>;
}): Promise<ToolResult<typeof DeleteDeploymentOutputSchema> & Pick<CallToolResult, "_meta">>;
// (undocumented)
static operationType: OperationType;
// (undocumented)
outputSchema: {
deleted: z.ZodBoolean;
deploymentName: z.ZodString;
};
// (undocumented)
static toolName: string;
}

Expand Down Expand Up @@ -1193,10 +1208,19 @@ export class ListDeploymentsTool extends AtlasLocalToolBase {
// (undocumented)
protected executeWithAtlasLocalClient(_args: ToolArgs<typeof ListDeploymentsTool.argsShape>, input: {
client: Client;
}): Promise<CallToolResult>;
}): Promise<ToolResult<typeof ListDeploymentsOutputSchema>>;
// (undocumented)
static operationType: OperationType;
// (undocumented)
outputSchema: {
count: z.ZodNumber;
deployments: z.ZodArray<z.ZodObject<{
name: z.ZodOptional<z.ZodString>;
state: z.ZodString;
mongodbVersion: z.ZodString;
}, z.core.$strip>>;
};
// (undocumented)
static toolName: string;
}

Expand Down
20 changes: 18 additions & 2 deletions src/tools/atlasLocal/connect/connectDeployment.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
import { z } from "zod";
import { AtlasLocalToolBase } from "../atlasLocalTool.js";
import type { OperationType, ToolArgs } from "../../tool.js";
import type { OperationType, ToolArgs, ToolResult } from "../../tool.js";
import type { Client } from "@mongodb-js/atlas-local";
import {
AtlasLocalDeploymentNotReadyError,
Expand All @@ -9,6 +10,11 @@ import {
import { CommonArgs } from "../../args.js";
import type { ConnectionMetadata } from "../../../telemetry/types.js";

const ConnectDeploymentOutputSchema = {
connected: z.boolean(),
deploymentName: z.string(),
};

export class ConnectDeploymentTool extends AtlasLocalToolBase {
static toolName = "atlas-local-connect-deployment";
public description = "Connect to a MongoDB Atlas Local deployment";
Expand All @@ -17,10 +23,12 @@ export class ConnectDeploymentTool extends AtlasLocalToolBase {
deploymentName: CommonArgs.string().describe("Name of the deployment to connect to"),
};

public override outputSchema = ConnectDeploymentOutputSchema;

protected async executeWithAtlasLocalClient(
{ deploymentName }: ToolArgs<typeof this.argsShape>,
{ client }: { client: Client }
): Promise<CallToolResult> {
): Promise<ToolResult<typeof ConnectDeploymentOutputSchema> & Pick<CallToolResult, "_meta">> {
Comment thread
lerouxb marked this conversation as resolved.
let connectionString: string;
try {
connectionString = await waitForConnectionString(client, deploymentName);
Expand All @@ -33,6 +41,10 @@ export class ConnectDeploymentTool extends AtlasLocalToolBase {
text: `Atlas Local deployment "${deploymentName}" is still starting up. Wait a few seconds and call atlas-local-connect-deployment again with the same deployment name.`,
},
],
structuredContent: {
connected: false,
deploymentName,
},
isError: true,
};
}
Expand All @@ -48,6 +60,10 @@ export class ConnectDeploymentTool extends AtlasLocalToolBase {
text: `Successfully connected to Atlas Local deployment "${deploymentName}".`,
},
],
structuredContent: {
connected: true,
deploymentName,
},
_meta: {
...(await this.lookupTelemetryMetadata(client, deploymentName)),
},
Expand Down
38 changes: 34 additions & 4 deletions src/tools/atlasLocal/create/createDeployment.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
import type { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
import { z } from "zod";
import { AtlasLocalToolBase } from "../atlasLocalTool.js";
import type { OperationType, ToolArgs } from "../../tool.js";
import type { Client, CreateDeploymentOptions } from "@mongodb-js/atlas-local";
import type { OperationType, ToolArgs, ToolResult } from "../../tool.js";
import type { Client, CreateDeploymentOptions, Deployment } from "@mongodb-js/atlas-local";
import {
AtlasLocalDeploymentNotReadyError,
waitForConnectionString,
} from "../../../common/atlasLocal/connectionString.js";
import { CommonArgs } from "../../args.js";
import z from "zod";

const CreateDeploymentOutputSchema = {
deploymentName: z.string(),
containerId: z.string(),
loadSampleData: z.boolean(),
imageTag: z.string(),
};

export type CreateDeploymentOutput = z.infer<z.ZodObject<typeof CreateDeploymentOutputSchema>>;

export class CreateDeploymentTool extends AtlasLocalToolBase {
static toolName = "atlas-local-create-deployment";
Expand All @@ -24,10 +33,12 @@ export class CreateDeploymentTool extends AtlasLocalToolBase {
.default("preview"),
};

public override outputSchema = CreateDeploymentOutputSchema;

protected async executeWithAtlasLocalClient(
{ deploymentName, loadSampleData, imageTag }: ToolArgs<typeof this.argsShape>,
{ client }: { client: Client }
): Promise<CallToolResult> {
): Promise<ToolResult<typeof CreateDeploymentOutputSchema> & Pick<CallToolResult, "_meta">> {
const deploymentOptions: CreateDeploymentOptions = {
name: deploymentName,
creationSource: {
Expand Down Expand Up @@ -57,6 +68,12 @@ export class CreateDeploymentTool extends AtlasLocalToolBase {
}
}

const structuredContent = this.buildStructuredContent(deployment, {
deploymentName: resolvedDeploymentName ?? "",
loadSampleData,
imageTag,
});

const startingNote = stillStarting
? " The deployment is still initializing; if atlas-local-connect-deployment fails, wait a few seconds and try connecting again."
: "";
Expand All @@ -68,9 +85,22 @@ export class CreateDeploymentTool extends AtlasLocalToolBase {
text: `Deployment with container ID "${deployment.containerId}" and name "${deployment.name}" created (imageTag: ${imageTag}).${startingNote}`,
},
],
structuredContent,
_meta: {
...(await this.lookupTelemetryMetadata(client, deployment.containerId)),
},
};
}

private buildStructuredContent(
deployment: Deployment,
args: { deploymentName: string; loadSampleData: boolean; imageTag: string }
): CreateDeploymentOutput {
return {
deploymentName: args.deploymentName,
containerId: deployment.containerId,
loadSampleData: args.loadSampleData,
imageTag: args.imageTag,
};
}
}
21 changes: 15 additions & 6 deletions src/tools/atlasLocal/delete/deleteDeployment.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
import type { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
import { z } from "zod";
import { AtlasLocalToolBase } from "../atlasLocalTool.js";
import type { OperationType, ToolArgs } from "../../tool.js";
import type { OperationType, ToolArgs, ToolResult } from "../../tool.js";
import type { Client } from "@mongodb-js/atlas-local";
import { CommonArgs } from "../../args.js";

const DeleteDeploymentOutputSchema = {
deleted: z.boolean(),
deploymentName: z.string(),
};

export class DeleteDeploymentTool extends AtlasLocalToolBase {
static toolName = "atlas-local-delete-deployment";
public description = "Delete a MongoDB Atlas local deployment";
Expand All @@ -12,20 +18,23 @@ export class DeleteDeploymentTool extends AtlasLocalToolBase {
deploymentName: CommonArgs.string().describe("Name of the deployment to delete"),
};

public override outputSchema = DeleteDeploymentOutputSchema;

protected async executeWithAtlasLocalClient(
{ deploymentName }: ToolArgs<typeof this.argsShape>,
{ client }: { client: Client }
): Promise<CallToolResult> {
// Lookup telemetry metadata
// We need to lookup the telemetry metadata before deleting the deployment
// to ensure that the deployment ID is set in the result metadata
): Promise<ToolResult<typeof DeleteDeploymentOutputSchema> & Pick<CallToolResult, "_meta">> {
// Resolve deployment ID for telemetry before the deployment is removed.
const telemetryMetadata = await this.lookupTelemetryMetadata(client, deploymentName);

// Delete the deployment
await client.deleteDeployment(deploymentName);

return {
content: [{ type: "text", text: `Deployment "${deploymentName}" deleted successfully.` }],
structuredContent: {
deleted: true,
deploymentName,
},
_meta: {
...telemetryMetadata,
},
Expand Down
29 changes: 25 additions & 4 deletions src/tools/atlasLocal/read/listDeployments.ts
Original file line number Diff line number Diff line change
@@ -1,32 +1,49 @@
import type { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
import { z } from "zod";
import { AtlasLocalToolBase } from "../atlasLocalTool.js";
import type { OperationType, ToolArgs } from "../../tool.js";
import type { OperationType, ToolArgs, ToolResult } from "../../tool.js";
import { formatUntrustedData } from "../../tool.js";
import type { Deployment } from "@mongodb-js/atlas-local";
import type { Client } from "@mongodb-js/atlas-local";

const ListDeploymentsOutputSchema = {
count: z.number(),
deployments: z.array(
z.object({
name: z.string().optional(),
state: z.string(),
mongodbVersion: z.string(),
})
),
};

export class ListDeploymentsTool extends AtlasLocalToolBase {
static toolName = "atlas-local-list-deployments";
public description = "List MongoDB Atlas local deployments";
static operationType: OperationType = "read";
public argsShape = {};

public override outputSchema = ListDeploymentsOutputSchema;

protected async executeWithAtlasLocalClient(
_args: ToolArgs<typeof this.argsShape>,
{ client }: { client: Client }
): Promise<CallToolResult> {
): Promise<ToolResult<typeof ListDeploymentsOutputSchema>> {
// List the deployments
const deployments = await client.listDeployments();

// Format the deployments
return this.formatDeploymentsTable(deployments);
}

private formatDeploymentsTable(deployments: Deployment[]): CallToolResult {
private formatDeploymentsTable(deployments: Deployment[]): ToolResult<typeof ListDeploymentsOutputSchema> {
// Check if deployments are absent
if (!deployments?.length) {
return {
content: [{ type: "text", text: "No deployments found." }],
structuredContent: {
count: 0,
deployments: [],
},
};
}

Expand All @@ -42,6 +59,10 @@ export class ListDeploymentsTool extends AtlasLocalToolBase {

return {
content: formatUntrustedData(`Found ${deployments.length} deployments`, JSON.stringify(deploymentsJson)),
structuredContent: {
count: deployments.length,
deployments: deploymentsJson,
},
};
}
}
12 changes: 0 additions & 12 deletions src/tools/mongodb/connect/connect.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { z } from "zod";
import type { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
import { MongoDBToolBase } from "../mongodbTool.js";
import type { ToolArgs, OperationType, ToolConstructorParams, ToolResult } from "../../tool.js";
import type { Server } from "../../../server.js";
Expand Down Expand Up @@ -56,15 +55,4 @@ export class ConnectTool extends MongoDBToolBase {
structuredContent: { connected: true },
};
}

protected override async handleError(
error: unknown,
args: ToolArgs<typeof this.argsShape>
): Promise<CallToolResult> {
const result = await super.handleError(error, args);
if (result.isError) {
return { ...result, structuredContent: { connected: false } };
}
return result;
}
}
4 changes: 4 additions & 0 deletions tests/accuracy/connectDeployment.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ describeAccuracyTests([
"Found 1 deployments",
'[{"name":"local-mflix","state":"Running","mongodbVersion":"6.0"}]'
),
structuredContent: {
count: 1,
deployments: [{ name: "local-mflix", state: "Running", mongodbVersion: "6.0" }],
},
}),
},
expectedToolCalls: [
Expand Down
10 changes: 10 additions & 0 deletions tests/accuracy/createDeployment.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ export function mockCreateDeploymentResponse(name: string): () => CallToolResult
text: `Deployment with container ID "1FOO" and name "${name}" created.`,
},
],
structuredContent: {
deploymentName: name,
containerId: "1FOO",
loadSampleData: false,
imageTag: "preview",
},
});
}

Expand Down Expand Up @@ -120,6 +126,10 @@ describeAccuracyTests([
text: "Deployment Name | State | MongoDB Version\n----------------|----------------|----------------\nexisting-database | Running | 6.0",
},
],
structuredContent: {
count: 1,
deployments: [{ name: "existing-database", state: "Running", mongodbVersion: "6.0" }],
},
}),
},
expectedToolCalls: [
Expand Down
Loading
Loading