Skip to main content
Glama
debtstack-ai

DebtStack MCP Server

search_documents

Search SEC filings for specific debt-related terms across covenant language, credit agreements, indentures, and liquidity discussions to analyze corporate credit data.

Instructions

Search SEC filing sections for specific terms. Section types: debt_footnote, credit_agreement, indenture, covenants, mda_liquidity. Use to find covenant language, credit agreement terms, or debt descriptions.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesSearch terms
tickerNoCompany ticker(s)
section_typeNoSection type to search
limitNoMaximum results (default 10)

Implementation Reference

  • MCP tool handler for search_documents that calls the API endpoint and formats results for the user
    elif name == "search_documents":
        params = {k: v for k, v in arguments.items() if v is not None}
        params.setdefault("limit", 10)
        result = api_get("/documents/search", params)
    
        docs = result.get("data", [])
        if not docs:
            return [TextContent(type="text", text=f"No documents found for '{params.get('q', '')}'.")]
    
        text = f"Found {len(docs)} matching sections:\n\n"
        text += "\n\n---\n\n".join(format_document_result(d) for d in docs)
        return [TextContent(type="text", text=text)]
  • Tool registration in list_tools() with name, description, and input schema defining query, ticker, section_type, and limit parameters
        name="search_documents",
        description=(
            "Search SEC filing sections for specific terms. "
            "Section types: debt_footnote, credit_agreement, indenture, covenants, mda_liquidity. "
            "Use to find covenant language, credit agreement terms, or debt descriptions."
        ),
        inputSchema={
            "type": "object",
            "properties": {
                "query": {
                    "type": "string",
                    "description": "Search terms"
                },
                "ticker": {
                    "type": "string",
                    "description": "Company ticker(s)"
                },
                "section_type": {
                    "type": "string",
                    "enum": ["debt_footnote", "credit_agreement", "indenture", "covenants", "mda_liquidity", "exhibit_21", "guarantor_list"],
                    "description": "Section type to search"
                },
                "limit": {
                    "type": "integer",
                    "description": "Maximum results (default 10)"
                }
            },
            "required": ["query"]
        }
    ),
  • Helper function format_document_result() that formats individual document search results with section type, ticker, filing info, and snippet
    def format_document_result(d: dict) -> str:
        """Format document search result."""
        lines = [
            f"**{d.get('section_type', 'Document')}** - {d.get('ticker', '?')}",
            f"Filing: {d.get('doc_type', '?')} ({d.get('filing_date', '?')})"
        ]
    
        if d.get('snippet'):
            # Clean up HTML tags in snippet
            snippet = d['snippet'].replace('<b>', '**').replace('</b>', '**')
            lines.append(f"...{snippet}...")
    
        return "\n".join(lines)
  • Async client method search_documents() that performs the actual HTTP GET request to /documents/search with query parameters and returns the JSON response
    async def search_documents(
        self,
        q: str,
        ticker: Optional[str] = None,
        doc_type: Optional[str] = None,
        section_type: Optional[str] = None,
        filed_after: Optional[Union[str, date]] = None,
        filed_before: Optional[Union[str, date]] = None,
        fields: Optional[str] = None,
        sort: str = "-relevance",
        limit: int = 50,
        offset: int = 0,
    ) -> Dict[str, Any]:
        """
        Full-text search across SEC filing sections.
    
        Args:
            q: Search query (required)
            ticker: Comma-separated company tickers
            doc_type: Filing type: 10-K, 10-Q, 8-K
            section_type: Section type:
                - exhibit_21: Subsidiary list
                - debt_footnote: Long-term debt details
                - mda_liquidity: Liquidity and Capital Resources
                - credit_agreement: Full credit facility documents
                - indenture: Bond indentures
                - guarantor_list: Guarantor subsidiaries
                - covenants: Financial covenant details
            filed_after: Minimum filing date
            filed_before: Maximum filing date
            fields: Comma-separated fields to return
            sort: -relevance (default), -filing_date, filing_date
            limit: Results per page (max 100)
            offset: Pagination offset
    
        Returns:
            Dictionary with search results and snippets
    
        Example:
            # Search for covenant language
            result = await client.search_documents(
                q="maintenance covenant",
                section_type="credit_agreement",
                ticker="CHTR"
            )
        """
        params = {
            "q": q,
            "sort": sort,
            "limit": limit,
            "offset": offset,
        }
    
        if ticker:
            params["ticker"] = ticker
        if doc_type:
            params["doc_type"] = doc_type
        if section_type:
            params["section_type"] = section_type
        if filed_after:
            params["filed_after"] = str(filed_after)
        if filed_before:
            params["filed_before"] = str(filed_before)
        if fields:
            params["fields"] = fields
    
        client = await self._get_client()
        response = await client.get("/documents/search", params=params)
        response.raise_for_status()
        return response.json()
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions what the tool searches (SEC filing sections) and lists section types, but it does not describe critical behaviors like whether the search is case-sensitive, how results are returned (e.g., snippets or full sections), pagination, rate limits, or authentication needs. For a search tool with no annotation coverage, this leaves significant gaps in understanding its operation.

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 appropriately sized and front-loaded, with two sentences that efficiently convey the tool's purpose, section types, and use cases without any wasted words. Every sentence adds value, making it easy to scan and understand quickly.

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

Completeness3/5

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

Given the tool's moderate complexity (4 parameters, no output schema, no annotations), the description is partially complete. It covers the purpose and usage context well but lacks details on behavioral aspects like result format or limitations. Without an output schema, the description should ideally hint at what is returned, but it does not, leaving gaps in overall 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 parameters thoroughly. The description adds some value by listing section types (matching the enum) and implying the query's purpose (e.g., 'specific terms'), but it does not provide additional semantics beyond what the schema specifies, such as query syntax or ticker format details. This meets the baseline for high schema coverage.

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 tool's purpose with a specific verb ('Search') and resource ('SEC filing sections'), and it distinguishes itself from sibling tools by focusing on document sections rather than bonds, companies, pricing, or other corporate data. The mention of specific section types and use cases (covenant language, credit agreement terms, debt descriptions) further clarifies its unique function.

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 on when to use this tool by listing section types and example use cases (e.g., 'find covenant language'), which helps differentiate it from siblings like search_bonds or search_companies. However, it does not explicitly state when not to use it or name specific alternatives, such as which sibling tool to use for non-document searches.

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/debtstack-ai/debtstack-python'

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