Skip to content

feat(compare_metric): add SIC / peer-group filters and pagination beyond limit=100 #7

@cyanheads

Description

@cyanheads

secedgar_compare_metric only supports global top/bottom-N ranking with limit ≤ 100. For typical metrics, the universe is 2,000–3,000 companies (total_companies: 2945 for revenue / CY2024), which means there is no way to:

  • Find a specific company's rank without paginating to it
  • Compare within an industry (e.g., semiconductors only, SIC 3674)
  • Restrict to a peer group by ticker list

Proposal

Add filtering and pagination to compare_metric. Filters narrow the universe before ranking; pagination lets callers walk past the top-100.

Proposed behavior

New optional input fields:

{
  concept: 'revenue',
  period: 'CY2024',
  // Existing
  limit: 25,
  sort: 'desc',
  unit: 'USD',
  // New
  sic?: string,         // SIC code prefix (e.g., '3674' for semiconductors,
                        // '36' for all electronic/electrical equipment)
  ciks?: string[],      // Restrict to this set of CIKs (peer group analysis)
  offset?: number,      // Pagination offset (0-based)
}

Output gains a total_filtered field so the caller knows the universe after filters apply, and an offset echo for pagination state.

Flow

request → fetch frames data → apply sic/ciks filter → sort → slice(offset, limit) → respond

Design / Tradeoffs

Philosophy: let callers narrow before ranking, not after.

Option Strengths Weaknesses
Add sic + ciks + offset to existing tool Minimal new surface; one-tool-does-it-all Tool input grows; requires SIC code knowledge for industry use case
New peer_compare_metric tool taking explicit ciks: string[] Cleaner separation Two tools to maintain; user has to pick
Server-side SIC group aliases (group: 'tech' → SIC list) Friendlier UX Maintenance burden; arbitrary groupings

Lean toward option 1. SIC filtering is well-understood by analysts; explicit ciks covers peer-group cases.

Scope

  • src/mcp-server/tools/definitions/compare-metric.tool.ts — input schema, handler
  • src/services/edgar/edgar-api-service.ts — possibly extend the frames-fetch helper to apply post-filters
  • Tool description — add SIC/peer-group examples

Out of scope

  • Server-side SIC group aliases (separate enhancement if demand surfaces)
  • Cross-period comparison (separate tool)
  • Industry rollups / aggregates

Alternatives considered

  • Caller does N get_financials calls per peer — works for small peer groups but won't scale to "rank all semiconductor revenue."
  • Caller fetches full universe via compare_metric(limit=100) and pages by offset — currently no offset param; even with one, walking 30 pages to reach a known target is wasteful.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions