Skip to main content
Glama
debtstack-ai

DebtStack MCP Server

search_companies

Search corporate credit data to find companies by ticker, sector, leverage ratios, and risk flags for financial analysis and peer comparison.

Instructions

Search companies by ticker, sector, leverage ratio, and risk flags. Use to find companies with specific characteristics, compare leverage across peers, or screen for structural subordination risk. Example: 'Find tech companies with leverage above 4x'

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
tickerNoComma-separated tickers (e.g., 'AAPL,MSFT,GOOGL')
sectorNoFilter by sector (e.g., 'Technology', 'Energy')
min_leverageNoMinimum leverage ratio
max_leverageNoMaximum leverage ratio
has_structural_subNoFilter for structural subordination
limitNoMaximum results (default 10)

Implementation Reference

  • Tool registration with name, description, and input schema for search_companies
    @app.list_tools()
    async def list_tools() -> list[Tool]:
        """List available DebtStack tools."""
        return [
            Tool(
                name="search_companies",
                description=(
                    "Search companies by ticker, sector, leverage ratio, and risk flags. "
                    "Use to find companies with specific characteristics, compare leverage across peers, "
                    "or screen for structural subordination risk. "
                    "Example: 'Find tech companies with leverage above 4x'"
                ),
                inputSchema={
                    "type": "object",
                    "properties": {
                        "ticker": {
                            "type": "string",
                            "description": "Comma-separated tickers (e.g., 'AAPL,MSFT,GOOGL')"
                        },
                        "sector": {
                            "type": "string",
                            "description": "Filter by sector (e.g., 'Technology', 'Energy')"
                        },
                        "min_leverage": {
                            "type": "number",
                            "description": "Minimum leverage ratio"
                        },
                        "max_leverage": {
                            "type": "number",
                            "description": "Maximum leverage ratio"
                        },
                        "has_structural_sub": {
                            "type": "boolean",
                            "description": "Filter for structural subordination"
                        },
                        "limit": {
                            "type": "integer",
                            "description": "Maximum results (default 10)"
                        }
                    },
                    "required": []
                }
  • Handler that executes search_companies by calling the API, formatting results, and returning formatted text
    if name == "search_companies":
        params = {k: v for k, v in arguments.items() if v is not None}
        params.setdefault("limit", 10)
        result = api_get("/companies", params)
    
        companies = result.get("data", [])
        if not companies:
            return [TextContent(type="text", text="No companies found matching criteria.")]
    
        text = f"Found {len(companies)} companies:\n\n"
        text += "\n\n---\n\n".join(format_company(c) for c in companies)
        return [TextContent(type="text", text=text)]
  • Helper function that formats company data for readable output
    def format_company(c: dict) -> str:
        """Format company data for display."""
        lines = [f"**{c.get('name', 'Unknown')}** ({c.get('ticker', '?')})"]
    
        if c.get('sector'):
            lines.append(f"Sector: {c['sector']}")
    
        debt = c.get('total_debt')
        if debt:
            lines.append(f"Total Debt: ${debt / 100_000_000_000:.2f}B")
    
        lev = c.get('net_leverage_ratio')
        if lev:
            lines.append(f"Net Leverage: {lev:.1f}x")
    
        cov = c.get('interest_coverage')
        if cov:
            lines.append(f"Interest Coverage: {cov:.1f}x")
    
        if c.get('has_structural_sub'):
            lines.append("⚠️ Has structural subordination")
    
        if c.get('has_near_term_maturity'):
            lines.append("⚠️ Near-term maturities")
    
        return "\n".join(lines)
  • Helper function that makes HTTP GET requests to the DebtStack API
    def api_get(endpoint: str, params: dict = None) -> dict:
        """Make GET request to DebtStack API."""
        response = httpx.get(
            f"{BASE_URL}{endpoint}",
            params=params,
            headers=get_headers(),
            timeout=30.0
        )
        response.raise_for_status()
        return response.json()
  • Pydantic schema for search_companies input validation used in LangChain integration
    class SearchCompaniesInput(BaseModel):
        """Input for company search tool."""
        ticker: Optional[str] = Field(
            None,
            description="Comma-separated tickers (e.g., 'AAPL,MSFT,GOOGL')"
        )
        sector: Optional[str] = Field(
            None,
            description="Filter by sector (e.g., 'Technology', 'Energy')"
        )
        min_leverage: Optional[float] = Field(
            None,
            description="Minimum leverage ratio (e.g., 3.0)"
        )
        max_leverage: Optional[float] = Field(
            None,
            description="Maximum leverage ratio (e.g., 6.0)"
        )
        has_structural_sub: Optional[bool] = Field(
            None,
            description="Filter for companies with structural subordination"
        )
        fields: Optional[str] = Field(
            None,
            description="Comma-separated fields to return (e.g., 'ticker,name,net_leverage_ratio')"
        )
        sort: Optional[str] = Field(
            None,
            description="Sort field, prefix with - for descending (e.g., '-net_leverage_ratio')"
        )
        limit: int = Field(
            10,
            description="Maximum results to return"
Behavior3/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. It mentions search functionality and risk screening, but lacks details on permissions, rate limits, pagination, or return format. The example adds some context, but behavioral traits are not fully disclosed.

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 the core purpose stated first, followed by usage contexts and an example. Every sentence adds value without redundancy, making it efficient and well-structured.

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 complexity (6 parameters, no output schema, no annotations), the description is adequate but incomplete. It covers purpose and usage but lacks details on behavioral aspects like response format or error handling, which are important for a search tool with multiple filters.

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. The description lists parameters (ticker, sector, leverage ratio, risk flags) but does not add meaning beyond what the schema provides, such as explaining relationships between min_leverage and max_leverage or clarifying structural subordination.

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 specific verbs ('Search companies') and resources ('by ticker, sector, leverage ratio, and risk flags'), and distinguishes it from siblings by focusing on company characteristics rather than bonds, documents, pricing, or other entities listed in sibling tools.

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 for when to use the tool ('to find companies with specific characteristics, compare leverage across peers, or screen for structural subordination risk') and includes an example, but does not explicitly state when not to use it or name alternatives among sibling tools.

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