Skip to main content
Glama

get_document_by_id

Retrieve a document from a Couchbase database by specifying its bucket, scope, collection, and document ID. Returns the document data or raises an exception if not found.

Instructions

Get a document by its ID from the specified scope and collection. If the document is not found, it will raise an exception.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
bucket_nameYes
scope_nameYes
collection_nameYes
document_idYes

Implementation Reference

  • The core handler function for the 'get_document_by_id' tool. Retrieves a document from Couchbase using the cluster connection, bucket, scope, collection, and document ID. Returns the document content as dict or raises exception.
    def get_document_by_id( ctx: Context, bucket_name: str, scope_name: str, collection_name: str, document_id: str, ) -> dict[str, Any]: """Get a document by its ID from the specified scope and collection. If the document is not found, it will raise an exception.""" cluster = get_cluster_connection(ctx) bucket = connect_to_bucket(cluster, bucket_name) try: collection = bucket.scope(scope_name).collection(collection_name) result = collection.get(document_id) return result.content_as[dict] except Exception as e: logger.error(f"Error getting document {document_id}: {e}") raise
  • Imports the get_document_by_id handler from the kv module into the tools package __init__, exposing it for use in ALL_TOOLS and server registration.
    from .kv import ( delete_document_by_id, get_document_by_id, upsert_document_by_id, )
  • Registers all tools from ALL_TOOLS, including get_document_by_id, with the FastMCP server instance.
    # Register all tools for tool in ALL_TOOLS: mcp.add_tool(tool)

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/Couchbase-Ecosystem/mcp-server-couchbase'

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