Skip to content

Commit 9ad0257

Browse files
committed
adds error handling for when container non-existent
1 parent 975909e commit 9ad0257

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

src/tools/atlasLocal/atlasLocalTool.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,20 @@ please log a ticket here: https://github.com/mongodb-js/mongodb-mcp-server/issue
4848
args: ToolArgs<typeof this.argsShape>
4949
): Promise<CallToolResult> | CallToolResult {
5050
// Error Handling for expected Atlas Local errors go here
51+
const errorMessage = error instanceof Error ? error.message : String(error);
52+
if (errorMessage.includes("No such container")) {
53+
const deploymentName =
54+
"deploymentName" in args ? (args.deploymentName as string) : "the specified deployment";
55+
return {
56+
content: [
57+
{
58+
type: "text",
59+
text: `The Atlas Local deployment "${deploymentName}" was not found. Please check the deployment name or use "atlas-local-list-deployments" to see available deployments.`,
60+
},
61+
],
62+
isError: true,
63+
};
64+
}
5165

5266
// For other types of errors, use the default error handling from the base class
5367
return super.handleError(error, args);

tests/integration/tools/atlas-local/deleteDeployment.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,16 @@ describe("atlas-local-delete-deployment", () => {
5252
"should return 'no such container' error when deployment to delete does not exist",
5353
async ({ signal }) => {
5454
await waitUntilMcpClientIsSet(integration.mcpServer(), signal);
55+
const deploymentName = "non-existent";
5556

5657
const response = await integration.mcpClient().callTool({
5758
name: "atlas-local-delete-deployment",
58-
arguments: { deploymentName: "non-existent" },
59+
arguments: { deploymentName },
5960
});
6061
const elements = getResponseElements(response.content);
6162
expect(elements.length).toBeGreaterThanOrEqual(1);
6263
expect(elements[0]?.text).toContain(
63-
"Docker responded with status code 404: No such container: non-existent"
64+
`The Atlas Local deployment "${deploymentName}" was not found. Please check the deployment name or use "atlas-local-list-deployments" to see available deployments.`
6465
);
6566
}
6667
);

0 commit comments

Comments
 (0)