Skip to main content
Glama
hyperspell

hyperspell-mcp

Official
by hyperspell

Get Document

Retrieve specific documents from collections to access unstructured or semi-structured data through AI-powered applications.

Instructions

Get a document from a collection

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
document_idYes

Implementation Reference

  • Handler function that implements the 'Get Document' tool by calling the Hyperspell API to fetch a document by its ID and converting it to a Document object.
    @mcp.tool_or_resource("document://{document_id}", name="Get Document")
    def get_document(document_id: int) -> Document | Error:
        """Get a document from a collection"""
        # try:
        r = mcp.api.documents.get(document_id=document_id)
        return Document.from_pydantic(r)
        # except APIError as e:
        # return Error(error=e.__class__.__name__, message=e.message)
  • Dataclass schema defining the structure of a Document returned by the tool.
    @dataclass
    class Document(BaseModel):
        id: int
        title: str
        type: str
        summary: str
  • Dataclass schema defining the structure of an Error that may be returned by the tool.
    @dataclass
    class Error(BaseModel):
        error: str
        message: str
  • Custom decorator that registers the tool function either as a tool or resource based on config, handling the registration for 'Get Document'.
    def tool_or_resource(self, uri: str, name: str | None = None):
        def decorator(fn: Callable):
            description = fn.__doc__
            if self.config.use_resources:
                self.resource(
                    uri,
                    name=name,
                    description=description,
                    mime_type="application/json",
                )(fn)
            if self.config.use_tools:
                self.add_tool(fn, name=name, description=description)
            return fn
    
        return decorator

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/hyperspell/hyperspell-mcp'

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