Skip to main content
Glama
andyfe76

CouchDB MCP Server

by andyfe76

couchdb_create_index

Create indexes in CouchDB to improve Mango query performance and ensure reliable results by specifying database and fields to index.

Instructions

Create an index to improve Mango query performance. While optional, indexes dramatically speed up queries and ensure reliable results.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
databaseYesName of the database
fieldsYesFields to index (e.g., ['type', 'name'])
index_nameNoOptional name for the index

Implementation Reference

  • The _create_index method is the actual handler implementation that creates an index in CouchDB using the _index endpoint. It accepts database name, list of fields, and optional index name, then posts the index specification to CouchDB and returns the result.
    async def _create_index(self, database: str, fields: list, index_name: str | None = None) -> list[TextContent]:
        """Create an index for Mango queries."""
        try:
            db = self._get_server()[database]
    
            # Build index specification
            index_spec = {
                "index": {
                    "fields": fields
                },
                "type": "json"
            }
    
            if index_name:
                index_spec["name"] = index_name
    
            # Create the index
            result = db.resource.post_json('_index', body=index_spec)
    
            response = {
                "result": result[1].get("result"),
                "id": result[1].get("id"),
                "name": result[1].get("name"),
                "message": f"Index created successfully on fields: {fields}"
            }
    
            return [TextContent(type="text", text=json.dumps(response, indent=2))]
        except KeyError:
            return [TextContent(type="text", text=f"Database '{database}' not found")]
        except Exception as e:
            return [TextContent(type="text", text=f"Error creating index: {str(e)}")]
  • Tool registration schema definition for couchdb_create_index. Defines the input schema with required 'database' and 'fields' parameters, and optional 'index_name' parameter. The description emphasizes that indexes improve query performance.
    Tool(
        name="couchdb_create_index",
        description="Create an index to improve Mango query performance. While optional, indexes dramatically speed up queries and ensure reliable results.",
        inputSchema={
            "type": "object",
            "properties": {
                "database": {
                    "type": "string",
                    "description": "Name of the database",
                },
                "fields": {
                    "type": "array",
                    "items": {"type": "string"},
                    "description": "Fields to index (e.g., ['type', 'name'])",
                },
                "index_name": {
                    "type": "string",
                    "description": "Optional name for the index",
                },
            },
            "required": ["database", "fields"],
        },
    ),
  • Registration point in the call_tool method that maps the tool name 'couchdb_create_index' to its handler function _create_index, extracting the database, fields, and optional index_name arguments.
    elif name == "couchdb_create_index":
        return await self._create_index(
            arguments["database"],
            arguments["fields"],
            arguments.get("index_name")
        )
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden. While it mentions performance benefits, it doesn't disclose important behavioral traits like whether this is a write operation, what permissions are required, whether indexes are permanent or can be deleted, or any rate limits. The description is insufficient for a mutation tool with zero annotation coverage.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is perfectly concise with two sentences that each earn their place. The first states the core purpose, and the second provides important context about benefits. No wasted words or unnecessary information.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a mutation tool (creating indexes) with no annotations and no output schema, the description is incomplete. It doesn't explain what happens after index creation, whether there are side effects, what the response looks like, or any error conditions. The performance benefit mention is helpful but insufficient for full contextual understanding.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents all three parameters. The description doesn't add any parameter-specific information beyond what's in the schema. The baseline of 3 is appropriate when the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('create') and resource ('index') with specific purpose ('to improve Mango query performance'). It distinguishes from siblings like couchdb_create_database and couchdb_create_document by focusing on indexes rather than databases or documents.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear context about when to use this tool ('to improve Mango query performance') and indicates it's optional but beneficial. However, it doesn't explicitly state when NOT to use it or mention specific alternatives among the sibling tools.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/andyfe76/couchdb_mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server