Skip to content

feat(search_legal): add totalCount to enrichment block #6

@cyanheads

Description

@cyanheads

openfec_search_legal is the only tool of the nine that omits totalCount from its enrichment block and never calls ctx.enrich.total(). All eight other tools declare enrichment.totalCount and call ctx.enrich.total(result.pagination.count) unconditionally.

The value is already computed — fec.searchLegal() returns LegalResult.totalCount (populated from body.total_all in openfec-service.ts:202), and the handler surfaces it in output.total_count — but the enrichment channel is never set, so clients reading enrichment.totalCount get undefined.

Proposal

Align search-legal.tool.ts with the other eight tools.

Proposed behavior

Add totalCount to the enrichment schema:

enrichment: {
  totalCount: z.number().describe('Total matching legal documents across all types.'),
  notice: z
    .string()
    .optional()
    .describe('Guidance when no legal documents matched — echoes filters and suggests how to broaden.'),
},

Call ctx.enrich.total() in the handler before the notice check:

ctx.enrich.total(data.totalCount);
if (trimmed.length === 0) {
  ctx.enrich.notice('...');
}

Scope

  • src/mcp-server/tools/definitions/search-legal.tool.ts — enrichment schema (one field) + handler (one call)

Out of scope

  • Changes to buildSearchCriteria, total_count in the output schema, or other tools

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