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") )

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