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
openfec_search_legalis the only tool of the nine that omitstotalCountfrom itsenrichmentblock and never callsctx.enrich.total(). All eight other tools declareenrichment.totalCountand callctx.enrich.total(result.pagination.count)unconditionally.The value is already computed —
fec.searchLegal()returnsLegalResult.totalCount(populated frombody.total_allinopenfec-service.ts:202), and the handler surfaces it inoutput.total_count— but the enrichment channel is never set, so clients readingenrichment.totalCountgetundefined.Proposal
Align
search-legal.tool.tswith the other eight tools.Proposed behavior
Add
totalCountto the enrichment schema:Call
ctx.enrich.total()in the handler before the notice check:Scope
src/mcp-server/tools/definitions/search-legal.tool.ts— enrichment schema (one field) + handler (one call)Out of scope
buildSearchCriteria,total_countin the output schema, or other tools