mcp-mongo-server 1.3.0 → 2.1.0
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/README.md +18 -339
- package/build/index.js +1825 -63
- package/package.json +74 -50
- package/build/mongo.js +0 -33
- package/build/schemas/call.js +0 -591
- package/build/schemas/completion.js +0 -112
- package/build/schemas/ping.js +0 -20
- package/build/schemas/prompts.js +0 -71
- package/build/schemas/resource.js +0 -213
- package/build/schemas/templates.js +0 -39
- package/build/schemas/tools.js +0 -281
- package/build/server.js +0 -65
package/build/schemas/ping.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
export async function handlePingRequest({ request, client, db, isReadOnlyMode, }) {
|
|
2
|
-
try {
|
|
3
|
-
// Check MongoDB connection
|
|
4
|
-
if (!client) {
|
|
5
|
-
throw new Error("MongoDB connection is not available");
|
|
6
|
-
}
|
|
7
|
-
// Ping MongoDB to verify connection
|
|
8
|
-
const pong = await db.command({ ping: 1 });
|
|
9
|
-
if (pong.ok !== 1) {
|
|
10
|
-
throw new Error(`MongoDB ping failed: ${pong.errmsg}`);
|
|
11
|
-
}
|
|
12
|
-
return {};
|
|
13
|
-
}
|
|
14
|
-
catch (error) {
|
|
15
|
-
if (error instanceof Error) {
|
|
16
|
-
throw new Error(`MongoDB ping failed: ${error.message}`);
|
|
17
|
-
}
|
|
18
|
-
throw new Error("MongoDB ping failed: Unknown error");
|
|
19
|
-
}
|
|
20
|
-
}
|
package/build/schemas/prompts.js
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
export async function handleListPromptsRequest({ request, client, db, isReadOnlyMode, }) {
|
|
2
|
-
return {
|
|
3
|
-
prompts: [
|
|
4
|
-
{
|
|
5
|
-
name: "analyze_collection",
|
|
6
|
-
description: "Analyze a MongoDB collection structure and contents",
|
|
7
|
-
arguments: [
|
|
8
|
-
{
|
|
9
|
-
name: "collection",
|
|
10
|
-
description: "Name of the collection to analyze",
|
|
11
|
-
required: true,
|
|
12
|
-
},
|
|
13
|
-
],
|
|
14
|
-
},
|
|
15
|
-
],
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
export async function handleGetPromptRequest({ request, client, db, isReadOnlyMode, }) {
|
|
19
|
-
const { name, arguments: args = {} } = request.params;
|
|
20
|
-
if (name !== "analyze_collection") {
|
|
21
|
-
throw new Error("Unknown prompt");
|
|
22
|
-
}
|
|
23
|
-
const collectionName = args.collection;
|
|
24
|
-
if (!collectionName) {
|
|
25
|
-
throw new Error("Collection name is required");
|
|
26
|
-
}
|
|
27
|
-
try {
|
|
28
|
-
const collection = db.collection(collectionName);
|
|
29
|
-
if (collection.collectionName.startsWith("system.")) {
|
|
30
|
-
throw new Error("Access to system collections is not allowed");
|
|
31
|
-
}
|
|
32
|
-
const schemaSample = await collection.findOne({});
|
|
33
|
-
const stats = await collection
|
|
34
|
-
.aggregate([{ $collStats: { count: {} } }])
|
|
35
|
-
.toArray();
|
|
36
|
-
const sampleDocs = await collection.find({}).limit(5).toArray();
|
|
37
|
-
const documentCount = stats[0]?.count ?? "unknown";
|
|
38
|
-
return {
|
|
39
|
-
messages: [
|
|
40
|
-
{
|
|
41
|
-
role: "user",
|
|
42
|
-
content: {
|
|
43
|
-
type: "text",
|
|
44
|
-
text: `Please analyze the following MongoDB collection:
|
|
45
|
-
Collection: ${collectionName}
|
|
46
|
-
|
|
47
|
-
Schema:
|
|
48
|
-
${JSON.stringify(schemaSample, null, 2)}
|
|
49
|
-
|
|
50
|
-
Stats:
|
|
51
|
-
Document count: ${documentCount}
|
|
52
|
-
|
|
53
|
-
Sample documents:
|
|
54
|
-
${JSON.stringify(sampleDocs, null, 2)}`,
|
|
55
|
-
},
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
role: "user",
|
|
59
|
-
content: {
|
|
60
|
-
type: "text",
|
|
61
|
-
text: "Provide insights about the collection's structure, data types, and basic statistics.",
|
|
62
|
-
},
|
|
63
|
-
},
|
|
64
|
-
],
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
catch (error) {
|
|
68
|
-
const msg = error instanceof Error ? error.message : "Unknown error";
|
|
69
|
-
throw new Error(`Failed to analyze collection ${collectionName}: ${msg}`);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
@@ -1,213 +0,0 @@
|
|
|
1
|
-
import { ObjectId } from "mongodb";
|
|
2
|
-
/**
|
|
3
|
-
* Detects the MongoDB-specific type of a value
|
|
4
|
-
* @param value The value to detect the type of
|
|
5
|
-
* @returns A string representing the detected type
|
|
6
|
-
*/
|
|
7
|
-
function detectMongoType(value) {
|
|
8
|
-
if (value === null)
|
|
9
|
-
return 'null';
|
|
10
|
-
if (value === undefined)
|
|
11
|
-
return 'undefined';
|
|
12
|
-
if (value instanceof ObjectId)
|
|
13
|
-
return 'ObjectId';
|
|
14
|
-
if (value instanceof Date)
|
|
15
|
-
return 'Date';
|
|
16
|
-
if (Array.isArray(value)) {
|
|
17
|
-
if (value.length === 0)
|
|
18
|
-
return 'Array';
|
|
19
|
-
// Check if array has consistent types
|
|
20
|
-
const elementTypes = new Set(value.map(item => detectMongoType(item)));
|
|
21
|
-
if (elementTypes.size === 1) {
|
|
22
|
-
return `Array<${Array.from(elementTypes)[0]}>`;
|
|
23
|
-
}
|
|
24
|
-
return 'Array<mixed>';
|
|
25
|
-
}
|
|
26
|
-
if (typeof value === 'object') {
|
|
27
|
-
// Handle nested documents
|
|
28
|
-
return 'Document';
|
|
29
|
-
}
|
|
30
|
-
return typeof value;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Helper function to infer a schema from multiple documents
|
|
34
|
-
* @param documents Array of sample documents from the collection
|
|
35
|
-
* @returns Inferred schema with field names and types
|
|
36
|
-
*/
|
|
37
|
-
function inferSchemaFromSamples(documents) {
|
|
38
|
-
if (!documents || documents.length === 0) {
|
|
39
|
-
return { fields: [] };
|
|
40
|
-
}
|
|
41
|
-
// Use a Map to store field information, with the key being the field name
|
|
42
|
-
const fieldMap = new Map();
|
|
43
|
-
// Process each document to collect field information
|
|
44
|
-
for (const doc of documents) {
|
|
45
|
-
for (const [key, value] of Object.entries(doc)) {
|
|
46
|
-
if (!fieldMap.has(key)) {
|
|
47
|
-
// Initialize field info if we haven't seen this field before
|
|
48
|
-
fieldMap.set(key, {
|
|
49
|
-
name: key,
|
|
50
|
-
types: new Set([detectMongoType(value)]),
|
|
51
|
-
nullable: false,
|
|
52
|
-
// Store sample values for complex types
|
|
53
|
-
samples: [value],
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
else {
|
|
57
|
-
// Update existing field info
|
|
58
|
-
const fieldInfo = fieldMap.get(key);
|
|
59
|
-
fieldInfo.types.add(detectMongoType(value));
|
|
60
|
-
// Store up to 3 different sample values
|
|
61
|
-
if (fieldInfo.samples.length < 3 &&
|
|
62
|
-
!fieldInfo.samples.some((sample) => JSON.stringify(sample) === JSON.stringify(value))) {
|
|
63
|
-
fieldInfo.samples.push(value);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
// Check for nullable fields by seeing which fields are missing in some documents
|
|
69
|
-
for (const doc of documents) {
|
|
70
|
-
for (const [key] of fieldMap.entries()) {
|
|
71
|
-
if (!(key in doc)) {
|
|
72
|
-
const fieldInfo = fieldMap.get(key);
|
|
73
|
-
fieldInfo.nullable = true;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
// Process nested document schemas
|
|
78
|
-
for (const [key, fieldInfo] of fieldMap.entries()) {
|
|
79
|
-
if (fieldInfo.types.has('Document')) {
|
|
80
|
-
// Extract nested documents for this field
|
|
81
|
-
const nestedDocs = documents
|
|
82
|
-
.filter(doc => doc[key] && typeof doc[key] === 'object' && !Array.isArray(doc[key]))
|
|
83
|
-
.map(doc => doc[key]);
|
|
84
|
-
if (nestedDocs.length > 0) {
|
|
85
|
-
// Recursively infer schema for nested documents
|
|
86
|
-
fieldInfo.nestedSchema = inferSchemaFromSamples(nestedDocs);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
// Convert the Map to an array of field objects with additional info
|
|
91
|
-
const fields = Array.from(fieldMap.values()).map(fieldInfo => {
|
|
92
|
-
const result = {
|
|
93
|
-
name: fieldInfo.name,
|
|
94
|
-
types: Array.from(fieldInfo.types),
|
|
95
|
-
nullable: fieldInfo.nullable,
|
|
96
|
-
prevalence: Math.round((documents.filter(doc => fieldInfo.name in doc).length / documents.length) * 100) + '%',
|
|
97
|
-
examples: [],
|
|
98
|
-
};
|
|
99
|
-
// Include nested schema if available
|
|
100
|
-
if (fieldInfo.nestedSchema) {
|
|
101
|
-
result.nestedSchema = fieldInfo.nestedSchema;
|
|
102
|
-
}
|
|
103
|
-
// Include simplified sample values
|
|
104
|
-
const sampleValues = fieldInfo.samples.map((sample) => {
|
|
105
|
-
if (sample instanceof ObjectId)
|
|
106
|
-
return sample.toString();
|
|
107
|
-
if (sample instanceof Date)
|
|
108
|
-
return sample.toISOString();
|
|
109
|
-
if (typeof sample === 'object') {
|
|
110
|
-
// For objects/arrays, just indicate type rather than full structure
|
|
111
|
-
return Array.isArray(sample) ? '[...]' : '{...}';
|
|
112
|
-
}
|
|
113
|
-
return sample;
|
|
114
|
-
});
|
|
115
|
-
result.examples = sampleValues;
|
|
116
|
-
return result;
|
|
117
|
-
});
|
|
118
|
-
return { fields };
|
|
119
|
-
}
|
|
120
|
-
export async function handleReadResourceRequest({ request, client, db, isReadOnlyMode, }) {
|
|
121
|
-
const url = new URL(request.params.uri);
|
|
122
|
-
const collectionName = url.pathname.replace(/^\//, "");
|
|
123
|
-
try {
|
|
124
|
-
const collection = db.collection(collectionName);
|
|
125
|
-
// Set sample size for schema inference
|
|
126
|
-
const sampleSize = 100;
|
|
127
|
-
let sampleDocuments = [];
|
|
128
|
-
try {
|
|
129
|
-
// First try using MongoDB's $sample aggregation to get a diverse set of documents
|
|
130
|
-
sampleDocuments = await collection
|
|
131
|
-
.aggregate([{ $sample: { size: sampleSize } }])
|
|
132
|
-
.toArray();
|
|
133
|
-
}
|
|
134
|
-
catch (sampleError) {
|
|
135
|
-
// Fallback to sequential scan if $sample is not available
|
|
136
|
-
console.warn(`$sample aggregation failed for ${collectionName}, falling back to sequential scan: ${sampleError}`);
|
|
137
|
-
sampleDocuments = await collection
|
|
138
|
-
.find({})
|
|
139
|
-
.limit(sampleSize)
|
|
140
|
-
.toArray();
|
|
141
|
-
}
|
|
142
|
-
// Get indexes for the collection
|
|
143
|
-
const indexes = await collection.indexes();
|
|
144
|
-
// Infer schema from samples
|
|
145
|
-
const inferredSchema = inferSchemaFromSamples(sampleDocuments);
|
|
146
|
-
// Get document count with timeout protection
|
|
147
|
-
let documentCount = null;
|
|
148
|
-
try {
|
|
149
|
-
// Set a timeout for the count operation
|
|
150
|
-
documentCount = await Promise.race([
|
|
151
|
-
collection.countDocuments(),
|
|
152
|
-
new Promise((_, reject) => setTimeout(() => reject(new Error('Count operation timed out')), 5000))
|
|
153
|
-
]);
|
|
154
|
-
}
|
|
155
|
-
catch (countError) {
|
|
156
|
-
console.warn(`Count operation failed or timed out for ${collectionName}: ${countError}`);
|
|
157
|
-
// Estimate count based on sample size and collection stats
|
|
158
|
-
try {
|
|
159
|
-
const stats = await db.command({ collStats: collectionName });
|
|
160
|
-
documentCount = stats.count;
|
|
161
|
-
}
|
|
162
|
-
catch {
|
|
163
|
-
documentCount = 'unknown (count operation timed out)';
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
const schema = {
|
|
167
|
-
type: "collection",
|
|
168
|
-
name: collectionName,
|
|
169
|
-
fields: inferredSchema.fields,
|
|
170
|
-
indexes: indexes.map((idx) => ({
|
|
171
|
-
name: idx.name,
|
|
172
|
-
keys: idx.key,
|
|
173
|
-
})),
|
|
174
|
-
documentCount: documentCount,
|
|
175
|
-
sampleSize: sampleDocuments.length,
|
|
176
|
-
lastUpdated: new Date().toISOString(),
|
|
177
|
-
};
|
|
178
|
-
return {
|
|
179
|
-
contents: [
|
|
180
|
-
{
|
|
181
|
-
uri: request.params.uri,
|
|
182
|
-
mimeType: "application/json",
|
|
183
|
-
text: JSON.stringify(schema, null, 2),
|
|
184
|
-
},
|
|
185
|
-
],
|
|
186
|
-
};
|
|
187
|
-
}
|
|
188
|
-
catch (error) {
|
|
189
|
-
if (error instanceof Error) {
|
|
190
|
-
throw new Error(`Failed to read collection ${collectionName}: ${error.message}`);
|
|
191
|
-
}
|
|
192
|
-
throw new Error(`Failed to read collection ${collectionName}: Unknown error`);
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
export async function handleListResourcesRequest({ request, client, db, isReadOnlyMode, }) {
|
|
196
|
-
try {
|
|
197
|
-
const collections = await db.listCollections().toArray();
|
|
198
|
-
return {
|
|
199
|
-
resources: collections.map((collection) => ({
|
|
200
|
-
uri: `mongodb:///${collection.name}`,
|
|
201
|
-
mimeType: "application/json",
|
|
202
|
-
name: collection.name,
|
|
203
|
-
description: `MongoDB collection: ${collection.name}`,
|
|
204
|
-
})),
|
|
205
|
-
};
|
|
206
|
-
}
|
|
207
|
-
catch (error) {
|
|
208
|
-
if (error instanceof Error) {
|
|
209
|
-
throw new Error(`Failed to list collections: ${error.message}`);
|
|
210
|
-
}
|
|
211
|
-
throw new Error("Failed to list collections: Unknown error");
|
|
212
|
-
}
|
|
213
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
export async function handleListResourceTemplatesRequest({ request, client, db, isReadOnlyMode, }) {
|
|
2
|
-
return {
|
|
3
|
-
resourceTemplates: [
|
|
4
|
-
{
|
|
5
|
-
name: "mongodb_query",
|
|
6
|
-
description: "Template for constructing MongoDB queries",
|
|
7
|
-
uriTemplate: "mongodb:///{collection}",
|
|
8
|
-
text: `To query MongoDB collections, you can use these operators:
|
|
9
|
-
|
|
10
|
-
Filter operators:
|
|
11
|
-
- $eq: Matches values equal to a specified value
|
|
12
|
-
- $gt/$gte: Matches values greater than (or equal to) a specified value
|
|
13
|
-
- $lt/$lte: Matches values less than (or equal to) a specified value
|
|
14
|
-
- $in: Matches any of the values in an array
|
|
15
|
-
- $nin: Matches none of the values in an array
|
|
16
|
-
- $ne: Matches values not equal to a specified value
|
|
17
|
-
- $exists: Matches documents that have the specified field
|
|
18
|
-
|
|
19
|
-
Example queries:
|
|
20
|
-
1. Find documents where age > 21:
|
|
21
|
-
{ "age": { "$gt": 21 } }
|
|
22
|
-
|
|
23
|
-
2. Find documents with specific status:
|
|
24
|
-
{ "status": { "$in": ["active", "pending"] } }
|
|
25
|
-
|
|
26
|
-
3. Find documents with existing email:
|
|
27
|
-
{ "email": { "$exists": true } }
|
|
28
|
-
|
|
29
|
-
4. Find documents with dates:
|
|
30
|
-
// Using ISO date string format
|
|
31
|
-
{ "createdAt": { "$gt": "2023-01-01T00:00:00Z" } }
|
|
32
|
-
// Using ISODate syntax
|
|
33
|
-
{ "createdAt": { "$gt": ISODate("2023-01-01T00:00:00Z") } }
|
|
34
|
-
|
|
35
|
-
Use these patterns to construct MongoDB queries.`,
|
|
36
|
-
},
|
|
37
|
-
],
|
|
38
|
-
};
|
|
39
|
-
}
|
package/build/schemas/tools.js
DELETED
|
@@ -1,281 +0,0 @@
|
|
|
1
|
-
export async function handleListToolsRequest({ request, client, db, isReadOnlyMode, }) {
|
|
2
|
-
return {
|
|
3
|
-
tools: [
|
|
4
|
-
{
|
|
5
|
-
name: "query",
|
|
6
|
-
description: "Execute a MongoDB query with optional execution plan analysis",
|
|
7
|
-
inputSchema: {
|
|
8
|
-
type: "object",
|
|
9
|
-
properties: {
|
|
10
|
-
collection: {
|
|
11
|
-
type: "string",
|
|
12
|
-
description: "Name of the collection to query",
|
|
13
|
-
},
|
|
14
|
-
filter: {
|
|
15
|
-
type: "object",
|
|
16
|
-
description: "MongoDB query filter. Supports date strings in ISO format ('2025-01-01T00:00:00Z') and ISODate('2025-01-01T00:00:00Z') notation"
|
|
17
|
-
},
|
|
18
|
-
projection: {
|
|
19
|
-
type: "object",
|
|
20
|
-
description: "Fields to include/exclude",
|
|
21
|
-
},
|
|
22
|
-
limit: {
|
|
23
|
-
type: "number",
|
|
24
|
-
description: "Maximum number of documents to return",
|
|
25
|
-
default: 10,
|
|
26
|
-
},
|
|
27
|
-
explain: {
|
|
28
|
-
type: "string",
|
|
29
|
-
description: "Optional: Get query execution information",
|
|
30
|
-
enum: ["queryPlanner", "executionStats", "allPlansExecution"],
|
|
31
|
-
},
|
|
32
|
-
objectIdMode: {
|
|
33
|
-
type: "string",
|
|
34
|
-
description: "Control how 24-character hex strings are handled",
|
|
35
|
-
enum: ["auto", "none", "force"],
|
|
36
|
-
default: "auto",
|
|
37
|
-
},
|
|
38
|
-
},
|
|
39
|
-
required: ["collection"],
|
|
40
|
-
},
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
name: "aggregate",
|
|
44
|
-
description: "Execute a MongoDB aggregation pipeline with optional execution plan analysis",
|
|
45
|
-
inputSchema: {
|
|
46
|
-
type: "object",
|
|
47
|
-
properties: {
|
|
48
|
-
collection: {
|
|
49
|
-
type: "string",
|
|
50
|
-
description: "Name of the collection to aggregate",
|
|
51
|
-
},
|
|
52
|
-
pipeline: {
|
|
53
|
-
type: "array",
|
|
54
|
-
description: "Aggregation pipeline stages. Supports date strings in ISO format ('2025-01-01T00:00:00Z') and ISODate('2025-01-01T00:00:00Z') notation",
|
|
55
|
-
items: {
|
|
56
|
-
type: "object",
|
|
57
|
-
},
|
|
58
|
-
},
|
|
59
|
-
explain: {
|
|
60
|
-
type: "string",
|
|
61
|
-
description: "Optional: Get aggregation execution information (queryPlanner, executionStats, or allPlansExecution)",
|
|
62
|
-
enum: ["queryPlanner", "executionStats", "allPlansExecution"],
|
|
63
|
-
},
|
|
64
|
-
objectIdMode: {
|
|
65
|
-
type: "string",
|
|
66
|
-
description: "Control how 24-character hex strings are handled",
|
|
67
|
-
enum: ["auto", "none", "force"],
|
|
68
|
-
default: "auto",
|
|
69
|
-
},
|
|
70
|
-
},
|
|
71
|
-
required: ["collection", "pipeline"],
|
|
72
|
-
},
|
|
73
|
-
},
|
|
74
|
-
{
|
|
75
|
-
name: "update",
|
|
76
|
-
description: "Update documents in a MongoDB collection",
|
|
77
|
-
inputSchema: {
|
|
78
|
-
type: "object",
|
|
79
|
-
properties: {
|
|
80
|
-
collection: {
|
|
81
|
-
type: "string",
|
|
82
|
-
description: "Name of the collection to update",
|
|
83
|
-
},
|
|
84
|
-
filter: {
|
|
85
|
-
type: "object",
|
|
86
|
-
description: "Filter to select documents to update. Supports date strings in ISO format ('2025-01-01T00:00:00Z') and ISODate('2025-01-01T00:00:00Z') notation",
|
|
87
|
-
},
|
|
88
|
-
update: {
|
|
89
|
-
type: "object",
|
|
90
|
-
description: "Update operations to apply ($set, $unset, $inc, etc.)",
|
|
91
|
-
},
|
|
92
|
-
upsert: {
|
|
93
|
-
type: "boolean",
|
|
94
|
-
description: "Create a new document if no documents match the filter",
|
|
95
|
-
},
|
|
96
|
-
multi: {
|
|
97
|
-
type: "boolean",
|
|
98
|
-
description: "Update multiple documents that match the filter",
|
|
99
|
-
},
|
|
100
|
-
objectIdMode: {
|
|
101
|
-
type: "string",
|
|
102
|
-
description: "Control how 24-character hex strings are handled",
|
|
103
|
-
enum: ["auto", "none", "force"],
|
|
104
|
-
default: "auto",
|
|
105
|
-
},
|
|
106
|
-
},
|
|
107
|
-
required: ["collection", "filter", "update"],
|
|
108
|
-
},
|
|
109
|
-
},
|
|
110
|
-
{
|
|
111
|
-
name: "serverInfo",
|
|
112
|
-
description: "Get MongoDB server information including version, storage engine, and other details",
|
|
113
|
-
inputSchema: {
|
|
114
|
-
type: "object",
|
|
115
|
-
properties: {
|
|
116
|
-
includeDebugInfo: {
|
|
117
|
-
type: "boolean",
|
|
118
|
-
description: "Include additional debug information about the server",
|
|
119
|
-
},
|
|
120
|
-
},
|
|
121
|
-
},
|
|
122
|
-
},
|
|
123
|
-
{
|
|
124
|
-
name: "insert",
|
|
125
|
-
description: "Insert one or more documents into a MongoDB collection",
|
|
126
|
-
inputSchema: {
|
|
127
|
-
type: "object",
|
|
128
|
-
properties: {
|
|
129
|
-
collection: {
|
|
130
|
-
type: "string",
|
|
131
|
-
description: "Name of the collection to insert into",
|
|
132
|
-
},
|
|
133
|
-
documents: {
|
|
134
|
-
type: "array",
|
|
135
|
-
description: "Array of documents to insert",
|
|
136
|
-
items: { type: "object" },
|
|
137
|
-
},
|
|
138
|
-
ordered: {
|
|
139
|
-
type: "boolean",
|
|
140
|
-
description: "If true, perform ordered insert. If false, insert unordered",
|
|
141
|
-
},
|
|
142
|
-
writeConcern: {
|
|
143
|
-
type: "object",
|
|
144
|
-
description: "Write concern for the insert operation",
|
|
145
|
-
},
|
|
146
|
-
bypassDocumentValidation: {
|
|
147
|
-
type: "boolean",
|
|
148
|
-
description: "Allow insert to bypass schema validation",
|
|
149
|
-
},
|
|
150
|
-
objectIdMode: {
|
|
151
|
-
type: "string",
|
|
152
|
-
description: "Control how 24-character hex strings are handled",
|
|
153
|
-
enum: ["auto", "none", "force"],
|
|
154
|
-
default: "auto",
|
|
155
|
-
},
|
|
156
|
-
},
|
|
157
|
-
required: ["collection", "documents"],
|
|
158
|
-
},
|
|
159
|
-
},
|
|
160
|
-
{
|
|
161
|
-
name: "createIndex",
|
|
162
|
-
description: "Create one or more indexes on a MongoDB collection",
|
|
163
|
-
inputSchema: {
|
|
164
|
-
type: "object",
|
|
165
|
-
properties: {
|
|
166
|
-
collection: {
|
|
167
|
-
type: "string",
|
|
168
|
-
description: "Name of the collection to create indexes on",
|
|
169
|
-
},
|
|
170
|
-
indexes: {
|
|
171
|
-
type: "array",
|
|
172
|
-
description: "Array of index specifications",
|
|
173
|
-
items: {
|
|
174
|
-
type: "object",
|
|
175
|
-
properties: {
|
|
176
|
-
key: {
|
|
177
|
-
type: "object",
|
|
178
|
-
description: "Index key pattern, e.g. { field: 1 }",
|
|
179
|
-
},
|
|
180
|
-
name: {
|
|
181
|
-
type: "string",
|
|
182
|
-
description: "Optional: Name of the index",
|
|
183
|
-
},
|
|
184
|
-
unique: {
|
|
185
|
-
type: "boolean",
|
|
186
|
-
description: "Optional: Creates a unique index",
|
|
187
|
-
},
|
|
188
|
-
sparse: {
|
|
189
|
-
type: "boolean",
|
|
190
|
-
description: "Optional: Creates a sparse index",
|
|
191
|
-
},
|
|
192
|
-
background: {
|
|
193
|
-
type: "boolean",
|
|
194
|
-
description: "Optional: Builds index in background",
|
|
195
|
-
},
|
|
196
|
-
expireAfterSeconds: {
|
|
197
|
-
type: "number",
|
|
198
|
-
description: "TTL in seconds for documents",
|
|
199
|
-
},
|
|
200
|
-
partialFilterExpression: {
|
|
201
|
-
type: "object",
|
|
202
|
-
description: "Filter expression for partial indexes",
|
|
203
|
-
},
|
|
204
|
-
},
|
|
205
|
-
required: ["key"],
|
|
206
|
-
},
|
|
207
|
-
},
|
|
208
|
-
writeConcern: {
|
|
209
|
-
type: "object",
|
|
210
|
-
description: "Write concern for index creation",
|
|
211
|
-
},
|
|
212
|
-
commitQuorum: {
|
|
213
|
-
type: "string",
|
|
214
|
-
description: "Number of members required to create the index",
|
|
215
|
-
},
|
|
216
|
-
objectIdMode: {
|
|
217
|
-
type: "string",
|
|
218
|
-
description: "Control how 24-character hex strings are handled",
|
|
219
|
-
enum: ["auto", "none", "force"],
|
|
220
|
-
default: "auto",
|
|
221
|
-
},
|
|
222
|
-
},
|
|
223
|
-
required: ["collection", "indexes"],
|
|
224
|
-
},
|
|
225
|
-
},
|
|
226
|
-
{
|
|
227
|
-
name: "count",
|
|
228
|
-
description: "Count documents in a collection matching a query",
|
|
229
|
-
inputSchema: {
|
|
230
|
-
type: "object",
|
|
231
|
-
properties: {
|
|
232
|
-
collection: { type: "string", description: "Collection name" },
|
|
233
|
-
query: { type: "object", description: "Query filter to count" },
|
|
234
|
-
limit: { type: "integer", description: "Max documents to count" },
|
|
235
|
-
skip: {
|
|
236
|
-
type: "integer",
|
|
237
|
-
description: "Docs to skip before counting",
|
|
238
|
-
},
|
|
239
|
-
hint: { type: "object", description: "Index hint" },
|
|
240
|
-
readConcern: { type: "object", description: "Read concern option" },
|
|
241
|
-
maxTimeMS: { type: "integer", description: "Max execution time" },
|
|
242
|
-
collation: {
|
|
243
|
-
type: "object",
|
|
244
|
-
description: "Collation rules for comparison",
|
|
245
|
-
},
|
|
246
|
-
objectIdMode: {
|
|
247
|
-
type: "string",
|
|
248
|
-
description: "Control how 24-character hex strings are handled",
|
|
249
|
-
enum: ["auto", "none", "force"],
|
|
250
|
-
default: "auto",
|
|
251
|
-
},
|
|
252
|
-
},
|
|
253
|
-
required: ["collection"],
|
|
254
|
-
},
|
|
255
|
-
},
|
|
256
|
-
{
|
|
257
|
-
name: "listCollections",
|
|
258
|
-
description: "List all collections in the MongoDB database",
|
|
259
|
-
inputSchema: {
|
|
260
|
-
type: "object",
|
|
261
|
-
properties: {
|
|
262
|
-
nameOnly: {
|
|
263
|
-
type: "boolean",
|
|
264
|
-
description: "If true, return only collection names",
|
|
265
|
-
},
|
|
266
|
-
filter: {
|
|
267
|
-
type: "object",
|
|
268
|
-
description: "Filter for collections",
|
|
269
|
-
},
|
|
270
|
-
objectIdMode: {
|
|
271
|
-
type: "string",
|
|
272
|
-
description: "Control how 24-character hex strings are handled",
|
|
273
|
-
enum: ["auto", "none", "force"],
|
|
274
|
-
default: "auto",
|
|
275
|
-
},
|
|
276
|
-
},
|
|
277
|
-
},
|
|
278
|
-
},
|
|
279
|
-
],
|
|
280
|
-
};
|
|
281
|
-
}
|