-
Notifications
You must be signed in to change notification settings - Fork 53
improve: enhance tool descriptions for better LLM agent tool selection #37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,7 +17,11 @@ export async function handleListToolsRequest({ | |
| { | ||
| name: "query", | ||
| description: | ||
| "Execute a MongoDB query with optional execution plan analysis", | ||
| "Execute a MongoDB find query to retrieve documents from a collection, with optional execution plan analysis.\n\n" + | ||
| "Use when the user wants to read, search, or filter documents in a specific collection.\n" + | ||
| "Do not use when you need to perform multi-stage data transformations (use aggregate instead) or when you want to modify data (use update or insert instead).\n" + | ||
| "Accepts 'collection' (required), 'filter' (optional query object), 'projection' (optional field selection), 'limit' (optional, default 10), and 'explain' (optional, for query plan analysis).\n" + | ||
| "Raises an error if the collection does not exist or the filter syntax is invalid.", | ||
| inputSchema: { | ||
| type: "object", | ||
| properties: { | ||
|
|
@@ -57,7 +61,11 @@ export async function handleListToolsRequest({ | |
| { | ||
| name: "aggregate", | ||
| description: | ||
| "Execute a MongoDB aggregation pipeline with optional execution plan analysis", | ||
| "Execute a MongoDB aggregation pipeline to perform multi-stage data transformations, grouping, joins, or analytics.\n\n" + | ||
| "Use when the user needs $group, $lookup, $unwind, $match chains, or any computation that goes beyond simple filtering.\n" + | ||
| "Do not use when a simple find query with filter and projection is sufficient (use query instead).\n" + | ||
| "Accepts 'collection' (required), 'pipeline' (required, array of stage objects), and 'explain' (optional, for execution plan analysis).\n" + | ||
| "Raises an error if the pipeline syntax is invalid or a stage operator is unrecognized.", | ||
|
||
| inputSchema: { | ||
| type: "object", | ||
| properties: { | ||
|
|
@@ -91,7 +99,12 @@ export async function handleListToolsRequest({ | |
| }, | ||
| { | ||
| name: "update", | ||
| description: "Update documents in a MongoDB collection", | ||
| description: | ||
| "Update one or more documents in a MongoDB collection using update operators ($set, $unset, $inc, etc.).\n\n" + | ||
| "Use when the user wants to modify existing documents — change field values, increment counters, or remove fields.\n" + | ||
| "Do not use when you need to add new documents (use insert instead) or when you need to read data (use query instead).\n" + | ||
| "Accepts 'collection' (required), 'filter' (required), 'update' (required, update operators), 'upsert' (optional), and 'multi' (optional, for updating multiple documents).\n" + | ||
| "Raises an error if the filter or update syntax is invalid.", | ||
|
||
| inputSchema: { | ||
| type: "object", | ||
| properties: { | ||
|
|
@@ -131,7 +144,11 @@ export async function handleListToolsRequest({ | |
| { | ||
| name: "serverInfo", | ||
| description: | ||
| "Get MongoDB server information including version, storage engine, and other details", | ||
| "Retrieve MongoDB server metadata including version, storage engine, host, and uptime.\n\n" + | ||
| "Use when the user wants to check the database server version, verify the storage engine, or diagnose server-level configuration.\n" + | ||
| "Do not use when you need to list collections (use listCollections instead) or query data (use query instead).\n" + | ||
| "Accepts 'includeDebugInfo' (optional boolean, includes additional diagnostic details).\n" + | ||
| "Raises an error if the server is unreachable.", | ||
|
||
| inputSchema: { | ||
| type: "object", | ||
| properties: { | ||
|
|
@@ -145,7 +162,12 @@ export async function handleListToolsRequest({ | |
| }, | ||
| { | ||
| name: "insert", | ||
| description: "Insert one or more documents into a MongoDB collection", | ||
| description: | ||
| "Insert one or more new documents into a MongoDB collection.\n\n" + | ||
| "Use when the user wants to add new records, seed data, or create documents in a collection.\n" + | ||
| "Do not use when you need to modify existing documents (use update instead) or when you need to read data (use query instead).\n" + | ||
| "Accepts 'collection' (required), 'documents' (required, array of document objects), 'ordered' (optional), and 'writeConcern' (optional).\n" + | ||
| "Raises an error if the collection name is invalid or document validation fails.", | ||
|
||
| inputSchema: { | ||
| type: "object", | ||
| properties: { | ||
|
|
@@ -183,7 +205,12 @@ export async function handleListToolsRequest({ | |
| }, | ||
| { | ||
| name: "createIndex", | ||
| description: "Create one or more indexes on a MongoDB collection", | ||
| description: | ||
| "Create one or more indexes on a MongoDB collection to improve query performance.\n\n" + | ||
| "Use when the user wants to add indexes for frequently queried fields, enforce uniqueness, or set up TTL expiration on documents.\n" + | ||
| "Do not use when you need to query or modify data (use query, update, or insert instead).\n" + | ||
| "Accepts 'collection' (required) and 'indexes' (required, array of index specs with key patterns). Each index supports options like 'unique', 'sparse', 'expireAfterSeconds', and 'partialFilterExpression'.\n" + | ||
| "Raises an error if the index key pattern is invalid or the collection does not exist.", | ||
|
||
| inputSchema: { | ||
| type: "object", | ||
| properties: { | ||
|
|
@@ -249,7 +276,12 @@ export async function handleListToolsRequest({ | |
| }, | ||
| { | ||
| name: "count", | ||
| description: "Count documents in a collection matching a query", | ||
| description: | ||
| "Count the number of documents in a collection that match a query filter.\n\n" + | ||
| "Use when the user wants to know how many documents exist, check if data is present, or get collection statistics.\n" + | ||
| "Do not use when you need to retrieve the actual documents (use query instead) or perform aggregation counts with grouping (use aggregate instead).\n" + | ||
| "Accepts 'collection' (required), 'query' (optional filter), 'limit' (optional max count), and 'skip' (optional docs to skip).\n" + | ||
| "Raises an error if the collection does not exist or the query filter is invalid.", | ||
|
||
| inputSchema: { | ||
| type: "object", | ||
| properties: { | ||
|
|
@@ -279,7 +311,12 @@ export async function handleListToolsRequest({ | |
| }, | ||
| { | ||
| name: "listCollections", | ||
| description: "List all collections in the MongoDB database", | ||
| description: | ||
| "List all collections in the connected MongoDB database.\n\n" + | ||
| "Use when the user wants to explore available collections before querying, or to verify a collection exists.\n" + | ||
| "Do not use when you already know the collection name and need to query its documents (use query instead).\n" + | ||
| "Accepts 'nameOnly' (optional boolean, returns only collection names for a compact listing) and 'filter' (optional, to filter collections by properties).\n" + | ||
| "Raises an error if the database connection is unavailable.", | ||
|
||
| inputSchema: { | ||
| type: "object", | ||
| properties: { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tool description is missing the
objectIdModeparameter in theAcceptssection. For the LLM to be aware of all available parameters, it's important to list them all.Additionally, for better readability and maintainability, I suggest using a template literal for the multi-line description string instead of string concatenation.