Skip to content

Commit eaa142d

Browse files
authored
Merge branch 'main' into unit-jest
2 parents f9768c1 + c118770 commit eaa142d

24 files changed

+847
-40
lines changed

README.md

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,38 @@ npm run build
4343

4444
### Tool List
4545

46-
- `auth` - Authenticate to MongoDB Atlas
47-
- `list-clusters` - Lists MongoDB Atlas clusters
48-
- `list-projects` - Lists MongoDB Atlas projects
46+
#### MongoDB Atlas Tools
47+
48+
- `atlas-auth` - Authenticate to MongoDB Atlas
49+
- `atlas-list-clusters` - Lists MongoDB Atlas clusters
50+
- `atlas-list-projects` - Lists MongoDB Atlas projects
51+
- `atlas-inspect-cluster` - Inspect a specific MongoDB Atlas cluster
52+
- `atlas-create-free-cluster` - Create a free MongoDB Atlas cluster
53+
- `atlas-create-access-list` - Configure IP/CIDR access list for MongoDB Atlas clusters
54+
- `atlas-inspect-access-list` - Inspect IP/CIDR ranges with access to MongoDB Atlas clusters
55+
56+
#### MongoDB Database Tools
57+
58+
- `connect` - Connect to a MongoDB instance
59+
- `find` - Run a find query against a MongoDB collection
60+
- `aggregate` - Run an aggregation against a MongoDB collection
61+
- `count` - Get the number of documents in a MongoDB collection
62+
- `insert-one` - Insert a single document into a MongoDB collection
63+
- `insert-many` - Insert multiple documents into a MongoDB collection
64+
- `create-index` - Create an index for a MongoDB collection
65+
- `update-one` - Update a single document in a MongoDB collection
66+
- `update-many` - Update multiple documents in a MongoDB collection
67+
- `rename-collection` - Rename a MongoDB collection
68+
- `delete-one` - Delete a single document from a MongoDB collection
69+
- `delete-many` - Delete multiple documents from a MongoDB collection
70+
- `drop-collection` - Remove a collection from a MongoDB database
71+
- `drop-database` - Remove a MongoDB database
72+
- `list-databases` - List all databases for a MongoDB connection
73+
- `list-collections` - List all collections for a given database
74+
- `collection-indexes` - Describe the indexes for a collection
75+
- `collection-schema` - Describe the schema for a collection
76+
- `collection-storage-size` - Get the size of a collection in MB
77+
- `db-stats` - Return statistics about a MongoDB database
4978

5079
## 👩‍💻 Client Integration (Use the server!)
5180

package-lock.json

Lines changed: 8 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@
6060
"@types/express": "^5.0.1",
6161
"bson": "^6.10.3",
6262
"mongodb": "^6.15.0",
63+
"mongodb-log-writer": "^2.4.1",
64+
"mongodb-redact": "^1.1.6",
6365
"mongodb-schema": "^12.6.2",
6466
"ts-jest": "^29.3.1",
6567
"zod": "^3.24.2"

scripts/filter.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ function filterOpenapi(openapi: OpenAPIV3_1.Document): OpenAPIV3_1.Document {
2424
"listClusters",
2525
"createCluster",
2626
"listClustersForAllProjects",
27+
"createDatabaseUser",
28+
"listDatabaseUsers",
29+
"listProjectIpAccessLists",
30+
"createProjectIpAccessList",
2731
];
2832

2933
const filteredPaths = {};

src/common/atlas/client.ts renamed to src/common/atlas/apiClient.ts

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ import {
66
PaginatedAtlasGroupView,
77
ClusterDescription20240805,
88
PaginatedClusterDescription20240805,
9+
PaginatedNetworkAccessView,
10+
NetworkPermissionEntry,
11+
CloudDatabaseUser,
12+
PaginatedApiAtlasDatabaseUserView,
913
} from "./openapi.js";
1014

1115
export interface OAuthToken {
@@ -65,7 +69,7 @@ export class ApiClient {
6569
credentials: !this.token?.access_token ? undefined : "include",
6670
headers: {
6771
"Content-Type": "application/json",
68-
Accept: "application/vnd.atlas.2025-04-07+json",
72+
Accept: `application/vnd.atlas.${config.atlasApiVersion}+json`,
6973
"User-Agent": config.userAgent,
7074
...authHeaders,
7175
},
@@ -269,6 +273,20 @@ export class ApiClient {
269273
return await this.do<PaginatedAtlasGroupView>("/groups");
270274
}
271275

276+
async listProjectIpAccessLists(groupId: string): Promise<PaginatedNetworkAccessView> {
277+
return await this.do<PaginatedNetworkAccessView>(`/groups/${groupId}/accessList`);
278+
}
279+
280+
async createProjectIpAccessList(
281+
groupId: string,
282+
entries: NetworkPermissionEntry[]
283+
): Promise<PaginatedNetworkAccessView> {
284+
return await this.do<PaginatedNetworkAccessView>(`/groups/${groupId}/accessList`, {
285+
method: "POST",
286+
body: JSON.stringify(entries),
287+
});
288+
}
289+
272290
async getProject(groupId: string): Promise<Group> {
273291
return await this.do<Group>(`/groups/${groupId}`);
274292
}
@@ -294,4 +312,15 @@ export class ApiClient {
294312
body: JSON.stringify(cluster),
295313
});
296314
}
315+
316+
async createDatabaseUser(groupId: string, user: CloudDatabaseUser): Promise<CloudDatabaseUser> {
317+
return await this.do<CloudDatabaseUser>(`/groups/${groupId}/databaseUsers`, {
318+
method: "POST",
319+
body: JSON.stringify(user),
320+
});
321+
}
322+
323+
async listDatabaseUsers(groupId: string): Promise<PaginatedApiAtlasDatabaseUserView> {
324+
return await this.do<PaginatedApiAtlasDatabaseUserView>(`/groups/${groupId}/databaseUsers`);
325+
}
297326
}

src/common/atlas/auth.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { ApiClient } from "./client";
2-
import { State } from "../../state";
1+
import { ApiClient } from "./apiClient.js";
2+
import { State } from "../../state.js";
33

44
export async function ensureAuthenticated(state: State, apiClient: ApiClient): Promise<void> {
55
if (!(await isAuthenticated(state, apiClient))) {

0 commit comments

Comments
 (0)