Skip to main content
Glama
andyfe76

CouchDB MCP Server

by andyfe76

couchdb_list_indexes

Retrieve all indexes in a CouchDB database to manage query performance and understand database structure for efficient document retrieval.

Instructions

List all indexes in a database

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
databaseYesName of the database

Implementation Reference

  • The _list_indexes handler method that implements the logic to list all indexes in a CouchDB database. It queries the _index endpoint and returns the indexes with metadata.
    async def _list_indexes(self, database: str) -> list[TextContent]:
        """List all indexes in a database."""
        try:
            db = self._get_server()[database]
    
            # Get all indexes
            result = db.resource.get_json('_index')
    
            indexes = result[1].get("indexes", [])
    
            response = {
                "indexes": indexes,
                "count": len(indexes),
                "total_rows": result[1].get("total_rows")
            }
    
            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 listing indexes: {str(e)}")]
  • Tool schema definition in list_tools() that defines the couchdb_list_indexes tool with its name, description, and input schema (requires 'database' parameter).
    Tool(
        name="couchdb_list_indexes",
        description="List all indexes in a database",
        inputSchema={
            "type": "object",
            "properties": {
                "database": {
                    "type": "string",
                    "description": "Name of the database",
                },
            },
            "required": ["database"],
        },
    ),
  • Tool registration routing in call_tool() that maps the couchdb_list_indexes tool name to its handler method.
    elif name == "couchdb_list_indexes":
        return await self._list_indexes(arguments["database"])

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