Skip to content

Commit 4cf78c2

Browse files
committed
Merge remote-tracking branch 'origin/main' into MCP-68
2 parents c5c91e9 + e85fe91 commit 4cf78c2

File tree

3 files changed

+20
-10
lines changed

3 files changed

+20
-10
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ A Model Context Protocol server for interacting with MongoDB Databases and Mongo
2222
- [Environment Variables](#environment-variables)
2323
- [Command-Line Arguments](#command-line-arguments)
2424
- [MCP Client Configuration](#mcp-configuration-file-examples)
25+
- [Proxy Support](#proxy-support)
2526
- [🤝 Contributing](#contributing)
2627

2728
<a name="getting-started"></a>
@@ -574,6 +575,13 @@ npx -y mongodb-mcp-server@latest --apiClientId="your-atlas-service-accounts-clie
574575
}
575576
```
576577

578+
### Proxy Support
579+
580+
The MCP Server will detect typical PROXY environment variables and use them for
581+
connecting to the Atlas API, your MongoDB Cluster, or any other external calls
582+
to third-party services like OID Providers. The behaviour is the same as what
583+
`mongosh` does, so the same settings will work in the MCP Server.
584+
577585
## 🤝Contributing
578586

579587
Interested in contributing? Great! Please check our [Contributing Guide](CONTRIBUTING.md) for guidelines on code contributions, standards, adding new tools, and troubleshooting information.

src/common/session.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@ export class Session extends EventEmitter<{
118118
w: connectOptions.writeConcern,
119119
},
120120
timeoutMS: connectOptions.timeoutMS,
121+
proxy: { useEnvironmentVariableProxies: true },
122+
applyProxyToOIDC: true,
121123
});
122124
}
123125
}

tests/unit/common/session.test.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -63,30 +63,30 @@ describe("Session", () => {
6363
});
6464
}
6565

66-
it("should include client name when agent runner is set", async () => {
67-
session.setAgentRunner({ name: "test-client", version: "1.0.0" });
68-
69-
await session.connectToMongoDB("mongodb://localhost:27017", config.connectOptions);
66+
it("should configure the proxy to use environment variables", async () => {
67+
await session.connectToMongoDB("mongodb://localhost", config.connectOptions);
7068
expect(session.serviceProvider).toBeDefined();
7169

7270
const connectMock = MockNodeDriverServiceProvider.connect;
7371
expect(connectMock).toHaveBeenCalledOnce();
74-
const connectionString = connectMock.mock.calls[0]?.[0];
7572

76-
// Should include the client name in the appName
77-
expect(connectionString).toContain("--test-device-id--test-client");
73+
const connectionConfig = connectMock.mock.calls[0]?.[1];
74+
expect(connectionConfig?.proxy).toEqual({ useEnvironmentVariableProxies: true });
75+
expect(connectionConfig?.applyProxyToOIDC).toEqual(true);
7876
});
7977

80-
it("should use 'unknown' for client name when agent runner is not set", async () => {
78+
it("should include client name when agent runner is set", async () => {
79+
session.setAgentRunner({ name: "test-client", version: "1.0.0" });
80+
8181
await session.connectToMongoDB("mongodb://localhost:27017", config.connectOptions);
8282
expect(session.serviceProvider).toBeDefined();
8383

8484
const connectMock = MockNodeDriverServiceProvider.connect;
8585
expect(connectMock).toHaveBeenCalledOnce();
8686
const connectionString = connectMock.mock.calls[0]?.[0];
8787

88-
// Should use 'unknown' for client name when agent runner is not set
89-
expect(connectionString).toContain("--test-device-id--unknown");
88+
// Should include the client name in the appName
89+
expect(connectionString).toContain("--test-device-id--test-client");
9090
});
9191
});
9292
});

0 commit comments

Comments
 (0)