search_documents
Search SEC filing sections for debt-related terms like covenant language and credit agreement terms. Specify section type to target specific debt documents.
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
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | Search terms | |
| ticker | No | Company ticker(s) | |
| section_type | No | Section type to search | |
| limit | No | Maximum results (default 10) |
Implementation Reference
- debtstack/mcp_server.py:547-558 (handler)MCP server handler for search_documents tool. Parses arguments, calls api_get('/documents/search'), formats results using format_document_result helper.
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)] - debtstack/mcp_server.py:362-391 (schema)MCP tool registration with input schema for search_documents: query (required string), ticker, section_type (enum), limit (integer).
Tool( 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"] } - debtstack/langchain.py:622-624 (registration)LangChain toolkit registration: DebtStackSearchDocumentsTool is included in the get_tools() list.
DebtStackSearchDocumentsTool(api_wrapper=self.api_wrapper), DebtStackGetChangesTool(api_wrapper=self.api_wrapper), ] - debtstack/mcp_server.py:177-189 (helper)Helper function to format a single document search result into readable text with 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) - debtstack/langchain.py:101-103 (helper)LangChain API wrapper method that makes the actual HTTP GET request to /documents/search endpoint.
def search_documents(self, **kwargs) -> Dict[str, Any]: """Search SEC filing sections.""" return self._get("/documents/search", params=kwargs)