@cyanheads/secedgar-mcp-server 0.20.0 → 0.20.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +23 -22
- package/CLAUDE.md +23 -22
- package/README.md +21 -9
- package/changelog/0.20.x/0.20.1.md +39 -0
- package/changelog/template.md +10 -8
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/mcp-server/tools/definitions/company-search.tool.js +1 -1
- package/dist/mcp-server/tools/definitions/company-search.tool.js.map +1 -1
- package/dist/mcp-server/tools/definitions/compare-companies.tool.d.ts.map +1 -1
- package/dist/mcp-server/tools/definitions/compare-companies.tool.js +35 -21
- package/dist/mcp-server/tools/definitions/compare-companies.tool.js.map +1 -1
- package/dist/mcp-server/tools/definitions/dataframe-query.tool.d.ts.map +1 -1
- package/dist/mcp-server/tools/definitions/dataframe-query.tool.js +28 -5
- package/dist/mcp-server/tools/definitions/dataframe-query.tool.js.map +1 -1
- package/dist/mcp-server/tools/definitions/fetch-frames.tool.d.ts.map +1 -1
- package/dist/mcp-server/tools/definitions/fetch-frames.tool.js +4 -2
- package/dist/mcp-server/tools/definitions/fetch-frames.tool.js.map +1 -1
- package/dist/mcp-server/tools/definitions/find-holders.tool.js +3 -3
- package/dist/mcp-server/tools/definitions/find-holders.tool.js.map +1 -1
- package/dist/mcp-server/tools/definitions/get-beneficial-owners.tool.js +1 -1
- package/dist/mcp-server/tools/definitions/get-beneficial-owners.tool.js.map +1 -1
- package/dist/mcp-server/tools/definitions/get-filing.tool.d.ts +14 -2
- package/dist/mcp-server/tools/definitions/get-filing.tool.d.ts.map +1 -1
- package/dist/mcp-server/tools/definitions/get-filing.tool.js +220 -86
- package/dist/mcp-server/tools/definitions/get-filing.tool.js.map +1 -1
- package/dist/mcp-server/tools/definitions/get-financials.tool.d.ts.map +1 -1
- package/dist/mcp-server/tools/definitions/get-financials.tool.js +82 -18
- package/dist/mcp-server/tools/definitions/get-financials.tool.js.map +1 -1
- package/dist/mcp-server/tools/definitions/get-fund-holdings.tool.js +3 -3
- package/dist/mcp-server/tools/definitions/get-fund-holdings.tool.js.map +1 -1
- package/dist/mcp-server/tools/definitions/get-insider-transactions.tool.d.ts +18 -2
- package/dist/mcp-server/tools/definitions/get-insider-transactions.tool.d.ts.map +1 -1
- package/dist/mcp-server/tools/definitions/get-insider-transactions.tool.js +299 -104
- package/dist/mcp-server/tools/definitions/get-insider-transactions.tool.js.map +1 -1
- package/dist/mcp-server/tools/definitions/get-institutional-holdings.tool.js +5 -5
- package/dist/mcp-server/tools/definitions/get-institutional-holdings.tool.js.map +1 -1
- package/dist/mcp-server/tools/definitions/get-material-events.tool.js +1 -1
- package/dist/mcp-server/tools/definitions/get-material-events.tool.js.map +1 -1
- package/dist/mcp-server/tools/definitions/get-snapshot.tool.d.ts.map +1 -1
- package/dist/mcp-server/tools/definitions/get-snapshot.tool.js +24 -22
- package/dist/mcp-server/tools/definitions/get-snapshot.tool.js.map +1 -1
- package/dist/mcp-server/tools/definitions/index.d.ts +17 -2
- package/dist/mcp-server/tools/definitions/index.d.ts.map +1 -1
- package/dist/mcp-server/tools/definitions/search-concepts.tool.d.ts.map +1 -1
- package/dist/mcp-server/tools/definitions/search-concepts.tool.js +16 -11
- package/dist/mcp-server/tools/definitions/search-concepts.tool.js.map +1 -1
- package/dist/mcp-server/tools/definitions/search-filings.tool.d.ts +2 -0
- package/dist/mcp-server/tools/definitions/search-filings.tool.d.ts.map +1 -1
- package/dist/mcp-server/tools/definitions/search-filings.tool.js +88 -40
- package/dist/mcp-server/tools/definitions/search-filings.tool.js.map +1 -1
- package/dist/services/edgar/call-scope.d.ts +13 -1
- package/dist/services/edgar/call-scope.d.ts.map +1 -1
- package/dist/services/edgar/call-scope.js +4 -1
- package/dist/services/edgar/call-scope.js.map +1 -1
- package/dist/services/edgar/concept-map.d.ts.map +1 -1
- package/dist/services/edgar/concept-map.js +18 -2
- package/dist/services/edgar/concept-map.js.map +1 -1
- package/dist/services/edgar/concept-series.d.ts +32 -1
- package/dist/services/edgar/concept-series.d.ts.map +1 -1
- package/dist/services/edgar/concept-series.js +72 -1
- package/dist/services/edgar/concept-series.js.map +1 -1
- package/dist/services/edgar/edgar-api-service.d.ts +2 -12
- package/dist/services/edgar/edgar-api-service.d.ts.map +1 -1
- package/dist/services/edgar/edgar-api-service.js +18 -31
- package/dist/services/edgar/edgar-api-service.js.map +1 -1
- package/dist/services/edgar/filing-to-text.d.ts +20 -8
- package/dist/services/edgar/filing-to-text.d.ts.map +1 -1
- package/dist/services/edgar/filing-to-text.js +583 -51
- package/dist/services/edgar/filing-to-text.js.map +1 -1
- package/dist/services/edgar/fiscal-periods.d.ts +2 -0
- package/dist/services/edgar/fiscal-periods.d.ts.map +1 -1
- package/dist/services/edgar/fiscal-periods.js +1 -1
- package/dist/services/edgar/fiscal-periods.js.map +1 -1
- package/dist/services/edgar/types.d.ts +9 -6
- package/dist/services/edgar/types.d.ts.map +1 -1
- package/package.json +8 -8
- package/server.json +3 -3
- package/skills/secedgar-guide/SKILL.md +16 -2
|
@@ -282,6 +282,7 @@ export declare function buildToolDefinitions(options: ToolDefinitionOptions): (i
|
|
|
282
282
|
total: import("zod").ZodNumber;
|
|
283
283
|
total_is_exact: import("zod").ZodBoolean;
|
|
284
284
|
total_documents: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
285
|
+
next_offset: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
285
286
|
results: import("zod").ZodArray<import("zod").ZodObject<{
|
|
286
287
|
accession_number: import("zod").ZodString;
|
|
287
288
|
form: import("zod").ZodOptional<import("zod").ZodString>;
|
|
@@ -476,8 +477,14 @@ export declare function buildToolDefinitions(options: ToolDefinitionOptions): (i
|
|
|
476
477
|
}, {
|
|
477
478
|
readonly reason: "filing_not_found";
|
|
478
479
|
readonly code: import("@cyanheads/mcp-ts-core/errors").JsonRpcErrorCode.NotFound;
|
|
479
|
-
readonly when: "No
|
|
480
|
+
readonly when: "No EDGAR source lists the accession number — no directory tried holds it, full-text search has no record of it, and SEC serves no index page for it — or the lookups that could show it were unavailable";
|
|
480
481
|
readonly recovery: "Verify the accession number and pass the company CIK explicitly.";
|
|
482
|
+
}, {
|
|
483
|
+
readonly reason: "filing_not_served";
|
|
484
|
+
readonly code: import("@cyanheads/mcp-ts-core/errors").JsonRpcErrorCode.ServiceUnavailable;
|
|
485
|
+
readonly when: "EDGAR shows the filing exists — full-text search lists it, SEC serves its index page, or this server read it earlier — but the SEC archive answered 404 for its directory listing under every CIK tried, an answer SEC caches for several minutes";
|
|
486
|
+
readonly recovery: "Retry the same call in a few minutes — the SEC archive is not serving this existing filing right now, and nothing in the request needs to change.";
|
|
487
|
+
readonly retryable: true;
|
|
481
488
|
}, {
|
|
482
489
|
readonly reason: "offset_out_of_range";
|
|
483
490
|
readonly code: import("@cyanheads/mcp-ts-core/errors").JsonRpcErrorCode.ValidationError;
|
|
@@ -795,6 +802,10 @@ export declare function buildToolDefinitions(options: ToolDefinitionOptions): (i
|
|
|
795
802
|
readonly resolvedAs: import("zod").ZodOptional<import("zod").ZodString>;
|
|
796
803
|
}> | import("@cyanheads/mcp-ts-core").ToolDefinition<import("zod").ZodObject<{
|
|
797
804
|
company: import("zod").ZodString;
|
|
805
|
+
role: import("zod").ZodDefault<import("zod").ZodEnum<{
|
|
806
|
+
issuer: "issuer";
|
|
807
|
+
reporting_owner: "reporting_owner";
|
|
808
|
+
}>>;
|
|
798
809
|
transaction_type: import("zod").ZodDefault<import("zod").ZodEnum<{
|
|
799
810
|
all: "all";
|
|
800
811
|
purchase: "purchase";
|
|
@@ -807,12 +818,16 @@ export declare function buildToolDefinitions(options: ToolDefinitionOptions): (i
|
|
|
807
818
|
issuer_name: import("zod").ZodString;
|
|
808
819
|
issuer_cik: import("zod").ZodString;
|
|
809
820
|
issuer_ticker: import("zod").ZodOptional<import("zod").ZodString>;
|
|
821
|
+
role: import("zod").ZodOptional<import("zod").ZodLiteral<"reporting_owner">>;
|
|
810
822
|
transactions: import("zod").ZodArray<import("zod").ZodObject<{
|
|
811
823
|
filing_date: import("zod").ZodString;
|
|
812
824
|
period_of_report: import("zod").ZodOptional<import("zod").ZodString>;
|
|
813
825
|
accession_number: import("zod").ZodString;
|
|
814
826
|
reporting_person: import("zod").ZodString;
|
|
815
827
|
relationship: import("zod").ZodString;
|
|
828
|
+
issuer_cik: import("zod").ZodOptional<import("zod").ZodString>;
|
|
829
|
+
issuer_name: import("zod").ZodOptional<import("zod").ZodString>;
|
|
830
|
+
issuer_ticker: import("zod").ZodOptional<import("zod").ZodString>;
|
|
816
831
|
security_title: import("zod").ZodString;
|
|
817
832
|
transaction_date: import("zod").ZodOptional<import("zod").ZodString>;
|
|
818
833
|
transaction_code: import("zod").ZodString;
|
|
@@ -853,7 +868,7 @@ export declare function buildToolDefinitions(options: ToolDefinitionOptions): (i
|
|
|
853
868
|
}, {
|
|
854
869
|
readonly reason: "no_filings_found";
|
|
855
870
|
readonly code: import("@cyanheads/mcp-ts-core/errors").JsonRpcErrorCode.NotFound;
|
|
856
|
-
readonly when: "A call without a date window finds no Form 4 filings in the recent submissions window";
|
|
871
|
+
readonly when: "A call without a date window finds no Form 4 filings in the recent submissions window, or under role reporting_owner none listing the company as a reporting owner";
|
|
857
872
|
readonly recovery: "Pass filed_after / filed_before to read an older period, or use secedgar_search_filings with forms=[\"4\"] to find the filings.";
|
|
858
873
|
}, {
|
|
859
874
|
readonly reason: 'rate_limited';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAmB3E;;;;GAIG;AACH,MAAM,WAAW,qBAAsB,SAAQ,iBAAiB;IAC9D;;;OAGG;IACH,WAAW,EAAE,OAAO,CAAC;CACtB;AAED;;;;GAIG;AACH,wB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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBA0BlE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"search-concepts.tool.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/search-concepts.tool.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAQ,CAAC,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"search-concepts.tool.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/search-concepts.tool.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAQ,CAAC,EAAE,MAAM,wBAAwB,CAAC;AAoBjD,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAmL7B,CAAC"}
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
import { tool, z } from '@cyanheads/mcp-ts-core';
|
|
9
9
|
import { escapeMarkdownInline } from '@cyanheads/mcp-ts-core/utils';
|
|
10
10
|
import { searchConcepts } from '../../../services/edgar/concept-map.js';
|
|
11
|
+
import { relatedTagsFor } from '../../../services/edgar/concept-series.js';
|
|
11
12
|
const GROUP_VALUES = [
|
|
12
13
|
'income_statement',
|
|
13
14
|
'balance_sheet',
|
|
@@ -31,7 +32,7 @@ export const searchConceptsTool = tool('secedgar_search_concepts', {
|
|
|
31
32
|
group: z
|
|
32
33
|
.enum(GROUP_VALUES)
|
|
33
34
|
.optional()
|
|
34
|
-
.describe('
|
|
35
|
+
.describe('One statement group: income_statement (P&L), balance_sheet (positions; use instant periods in secedgar_fetch_frames), cash_flow, per_share (EPS and the diluted share count it divides by), or entity_info (DEI items such as shares outstanding).'),
|
|
35
36
|
taxonomy: z
|
|
36
37
|
.enum(TAXONOMY_VALUES)
|
|
37
38
|
.optional()
|
|
@@ -118,16 +119,20 @@ export const searchConceptsTool = tool('secedgar_search_concepts', {
|
|
|
118
119
|
}
|
|
119
120
|
return {
|
|
120
121
|
total: results.length,
|
|
121
|
-
concepts: results.map((c) =>
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
122
|
+
concepts: results.map((c) => {
|
|
123
|
+
// us-gaap elements: none is listed under an ifrs-full filter (#258).
|
|
124
|
+
const related = relatedTagsFor(c.name, input.taxonomy ?? 'us-gaap');
|
|
125
|
+
return {
|
|
126
|
+
name: c.name,
|
|
127
|
+
label: c.label,
|
|
128
|
+
tags: c.tags,
|
|
129
|
+
...(c.ifrsTags?.length ? { ifrs_tags: c.ifrsTags } : {}),
|
|
130
|
+
...(related.length ? { related_tags: [...related] } : {}),
|
|
131
|
+
taxonomy: c.taxonomy,
|
|
132
|
+
unit: c.unit,
|
|
133
|
+
group: c.group,
|
|
134
|
+
};
|
|
135
|
+
}),
|
|
131
136
|
};
|
|
132
137
|
},
|
|
133
138
|
format: (result) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"search-concepts.tool.js","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/search-concepts.tool.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;
|
|
1
|
+
{"version":3,"file":"search-concepts.tool.js","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/search-concepts.tool.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAGpE,MAAM,YAAY,GAAG;IACnB,kBAAkB;IAClB,eAAe;IACf,WAAW;IACX,WAAW;IACX,aAAa;CAC6B,CAAC;AAE7C,MAAM,eAAe,GAAG;IACtB,SAAS;IACT,WAAW;IACX,KAAK;CACwC,CAAC;AAEhD,MAAM,CAAC,MAAM,kBAAkB,GAAG,IAAI,CAAC,0BAA0B,EAAE;IACjE,WAAW,EACT,0WAA0W;IAC5W,WAAW,EA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31,6 +31,7 @@ export declare const searchFilingsTool: import("@cyanheads/mcp-ts-core").ToolDef
|
|
|
31
31
|
total: z.ZodNumber;
|
|
32
32
|
total_is_exact: z.ZodBoolean;
|
|
33
33
|
total_documents: z.ZodOptional<z.ZodNumber>;
|
|
34
|
+
next_offset: z.ZodOptional<z.ZodNumber>;
|
|
34
35
|
results: z.ZodArray<z.ZodObject<{
|
|
35
36
|
accession_number: z.ZodString;
|
|
36
37
|
form: z.ZodOptional<z.ZodString>;
|
|
@@ -163,6 +164,7 @@ export declare function createSearchFilingsTool(options: LimitClampOptions): imp
|
|
|
163
164
|
total: z.ZodNumber;
|
|
164
165
|
total_is_exact: z.ZodBoolean;
|
|
165
166
|
total_documents: z.ZodOptional<z.ZodNumber>;
|
|
167
|
+
next_offset: z.ZodOptional<z.ZodNumber>;
|
|
166
168
|
results: z.ZodArray<z.ZodObject<{
|
|
167
169
|
accession_number: z.ZodString;
|
|
168
170
|
form: z.ZodOptional<z.ZodString>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"search-filings.tool.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/search-filings.tool.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAsB,CAAC,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EACL,gBAAgB,EAIjB,MAAM,+BAA+B,CAAC;AAKvC,OAAO,EACL,KAAK,iBAAiB,EAGvB,MAAM,mCAAmC,CAAC;AAmC3C;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,OAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"search-filings.tool.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/search-filings.tool.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAsB,CAAC,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EACL,gBAAgB,EAIjB,MAAM,+BAA+B,CAAC;AAKvC,OAAO,EACL,KAAK,iBAAiB,EAGvB,MAAM,mCAAmC,CAAC;AAmC3C;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,OAAQ,CAAC;AAg1B1C,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA0uB5B,CAAC;AAEH,+FAA+F;AAC/F,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAEjE"}
|
|
@@ -390,14 +390,16 @@ function sortRows(rows, sort) {
|
|
|
390
390
|
* `total` is the assembled filing count. When `totalIsExact` is false the sources
|
|
391
391
|
* held more than was read (an archive cap, a scan cap, or a full-text window short
|
|
392
392
|
* of its document total), so the dataframe is flagged truncated and the truncation
|
|
393
|
-
* notice
|
|
393
|
+
* notice says to narrow even on the last page, since no offset reaches those rows.
|
|
394
|
+
* `next_offset` names the next page while assembled rows lie past this one (#259).
|
|
394
395
|
*/
|
|
395
396
|
async function finishAssembledResult(ctx, args) {
|
|
396
397
|
const sorted = sortRows(args.matched, args.sort);
|
|
397
398
|
const total = sorted.length;
|
|
398
399
|
const truncated = !args.totalIsExact;
|
|
399
|
-
const
|
|
400
|
-
const
|
|
400
|
+
const pageEnd = args.offset + args.limit;
|
|
401
|
+
const nextOffset = pageEnd < total ? pageEnd : undefined;
|
|
402
|
+
const results = sorted.slice(args.offset, pageEnd).map(toInlineResult);
|
|
401
403
|
const formDistribution = buildFormDistribution(sorted.map((row) => row.form));
|
|
402
404
|
let dataset;
|
|
403
405
|
const bridge = getCanvasBridge();
|
|
@@ -427,27 +429,31 @@ async function finishAssembledResult(ctx, args) {
|
|
|
427
429
|
notice.push(dataframeGuidance(dataset));
|
|
428
430
|
ctx.enrich.notice(notice.join(' '));
|
|
429
431
|
}
|
|
430
|
-
else if (
|
|
432
|
+
else if (nextOffset !== undefined || truncated) {
|
|
431
433
|
// `notice` is last-wins across notice/truncated, so every applicable clause —
|
|
432
|
-
// coverage, the fetch boundary, the staged-dataframe pointer — is
|
|
433
|
-
// into this one guidance string rather than emitted as competing notices (#104).
|
|
434
|
+
// coverage, the next page, the fetch boundary, the staged-dataframe pointer — is
|
|
435
|
+
// composed into this one guidance string rather than emitted as competing notices (#104).
|
|
434
436
|
const guidance = [args.coverageNote];
|
|
437
|
+
if (nextOffset !== undefined)
|
|
438
|
+
guidance.push(`Page on with offset ${nextOffset}.`);
|
|
435
439
|
if (truncated)
|
|
436
440
|
guidance.push(MORE_MATCHES_BEYOND_ROWS);
|
|
437
441
|
if (dataset)
|
|
438
442
|
guidance.push(dataframeGuidance(dataset));
|
|
439
|
-
else if (!truncated)
|
|
440
|
-
guidance.push('Page further with offset.');
|
|
441
443
|
ctx.enrich.truncated({
|
|
442
444
|
shown: results.length,
|
|
443
445
|
cap: args.limit,
|
|
444
446
|
guidance: guidance.join(' '),
|
|
445
447
|
});
|
|
446
448
|
}
|
|
449
|
+
else if (dataset) {
|
|
450
|
+
ctx.enrich.notice(`${args.coverageNote} ${dataframeGuidance(dataset)}`);
|
|
451
|
+
}
|
|
447
452
|
return {
|
|
448
453
|
total,
|
|
449
454
|
total_is_exact: args.totalIsExact,
|
|
450
455
|
total_documents: args.totalDocuments,
|
|
456
|
+
next_offset: nextOffset,
|
|
451
457
|
results,
|
|
452
458
|
form_distribution: formDistribution,
|
|
453
459
|
scan: args.scan,
|
|
@@ -672,13 +678,13 @@ export const searchFilingsTool = tool('secedgar_search_filings', {
|
|
|
672
678
|
notice: z
|
|
673
679
|
.string()
|
|
674
680
|
.optional()
|
|
675
|
-
.describe('Why nothing matched,
|
|
681
|
+
.describe('Why nothing matched, how to reach filings past this page, or that offset passed the filings available.'),
|
|
676
682
|
truncated: z
|
|
677
683
|
.boolean()
|
|
678
684
|
.optional()
|
|
679
|
-
.describe('True when
|
|
680
|
-
shown: z.number().optional().describe('
|
|
681
|
-
cap: z.number().optional().describe('The limit
|
|
685
|
+
.describe('True when filings lie past this page: next_offset reaches them, or only narrowing does.'),
|
|
686
|
+
shown: z.number().optional().describe('Results shown inline.'),
|
|
687
|
+
cap: z.number().optional().describe('The limit applied.'),
|
|
682
688
|
},
|
|
683
689
|
errors: [
|
|
684
690
|
{
|
|
@@ -749,11 +755,11 @@ export const searchFilingsTool = tool('secedgar_search_filings', {
|
|
|
749
755
|
.describe('Full-text search query. Supports: exact phrases ("material weakness"), boolean operators (revenue OR income), exclusion (-preliminary), wildcard suffix (account*), entity targeting (one ticker:AAPL or cik:320193 term, never led by - or NOT). Terms are AND\'d by default.'),
|
|
750
756
|
])
|
|
751
757
|
.optional()
|
|
752
|
-
.describe('Full-text search
|
|
758
|
+
.describe('Full-text search terms. Omit or pass "" to browse by forms and/or ticker:/cik: scope instead; a date range alone is not a search. Full text covers 2001 onward: an earlier range needs ticker:/cik: scope, or no text terms and a forms filter. ticker: reads tickers as secedgar_company_search does.'),
|
|
753
759
|
forms: z
|
|
754
760
|
.array(z.string())
|
|
755
761
|
.optional()
|
|
756
|
-
.describe('
|
|
762
|
+
.describe('Form types to filter to (e.g. ["10-K", "8-K"]); omit for all. "10-K" also matches 10-K/A. "SC 13D"/"SC 13G" became "SCHEDULE 13D"/"SCHEDULE 13G" on 2024-12-18; list both across that date. Forms 3, 4, 5 index by reporting person, with no trades; secedgar_get_insider_transactions parses Form 4.'),
|
|
757
763
|
filed_after: z
|
|
758
764
|
.union([
|
|
759
765
|
z.literal(''),
|
|
@@ -781,11 +787,11 @@ export const searchFilingsTool = tool('secedgar_search_filings', {
|
|
|
781
787
|
.min(0)
|
|
782
788
|
.max(9999)
|
|
783
789
|
.default(0)
|
|
784
|
-
.describe(`
|
|
790
|
+
.describe(`Where the page starts; pass next_offset to page on. Under sort=relevance on a 2001-onward search it counts documents (a filing can recur); EDGAR serves offsets up to ${MAX_RELEVANCE_OFFSET} there, and a deeper offset is rejected. Elsewhere it indexes this call's rows; the notice says when only narrowing reaches more.`),
|
|
785
791
|
sort: z
|
|
786
792
|
.enum(['filing_date_desc', 'filing_date_asc', 'relevance'])
|
|
787
793
|
.default('filing_date_desc')
|
|
788
|
-
.describe('
|
|
794
|
+
.describe('"filing_date_desc" (default, newest first), "filing_date_asc", or "relevance" (SEC\'s search score). Date sorts reorder the top 100 hits, so a broad search without ticker:/cik: scope can miss newer filings past them. A no-query browse and pre-2001 rows have no score; there relevance is newest first.'),
|
|
789
795
|
}),
|
|
790
796
|
// This tool's former date spellings, and other spellings in use across tools (#115):
|
|
791
797
|
// company_search names its filing count filing_limit (#212).
|
|
@@ -808,6 +814,10 @@ export const searchFilingsTool = tool('secedgar_search_filings', {
|
|
|
808
814
|
.number()
|
|
809
815
|
.optional()
|
|
810
816
|
.describe("EDGAR's count of matching full-text documents, capped at 10,000; a search counts a filing once per matching document, a browse one document per filing. Absent on pure pre-2001 archive paths."),
|
|
817
|
+
next_offset: z
|
|
818
|
+
.number()
|
|
819
|
+
.optional()
|
|
820
|
+
.describe("The next page's offset (documents under sort=relevance). Absent on the last page or when only narrowing reaches more."),
|
|
811
821
|
results: z
|
|
812
822
|
.array(z
|
|
813
823
|
.object({
|
|
@@ -815,7 +825,7 @@ export const searchFilingsTool = tool('secedgar_search_filings', {
|
|
|
815
825
|
form: z
|
|
816
826
|
.string()
|
|
817
827
|
.optional()
|
|
818
|
-
.describe('Form type (e.g. "10-K"). Absent
|
|
828
|
+
.describe('Form type (e.g. "10-K"). Absent when the index has none.'),
|
|
819
829
|
filing_date: z.string().describe('Date the filing was submitted (YYYY-MM-DD).'),
|
|
820
830
|
period_ending: z
|
|
821
831
|
.string()
|
|
@@ -846,7 +856,7 @@ export const searchFilingsTool = tool('secedgar_search_filings', {
|
|
|
846
856
|
})
|
|
847
857
|
.describe('One document of this filing that matched the query.'))
|
|
848
858
|
.optional()
|
|
849
|
-
.describe('Documents of this filing that matched, in rank order;
|
|
859
|
+
.describe('Documents of this filing that matched, in rank order; a comma-separated filename column in the dataframe.'),
|
|
850
860
|
sic: z
|
|
851
861
|
.string()
|
|
852
862
|
.optional()
|
|
@@ -858,7 +868,7 @@ export const searchFilingsTool = tool('secedgar_search_filings', {
|
|
|
858
868
|
source: z
|
|
859
869
|
.enum(['efts', 'submissions', 'full-index'])
|
|
860
870
|
.optional()
|
|
861
|
-
.describe('"efts" (2001+ full-text), "submissions" (pre-2001 entity history), or "full-index" (pre-2001 quarterly index). A range crossing 2001-01-01 mixes sources; total sums its archive rows and the filings of one 100-document full-text window.
|
|
871
|
+
.describe('"efts" (2001+ full-text), "submissions" (pre-2001 entity history), or "full-index" (pre-2001 quarterly index). A range crossing 2001-01-01 mixes sources; total sums its archive rows and the filings of one 100-document full-text window.'),
|
|
862
872
|
})
|
|
863
873
|
.describe('One matching filing. period_ending, ticker, file_description, matched_documents, sic, and location are absent on pre-2001 archive rows (source submissions or full-index).'))
|
|
864
874
|
.describe('Matching filings.'),
|
|
@@ -876,7 +886,7 @@ export const searchFilingsTool = tool('secedgar_search_filings', {
|
|
|
876
886
|
.describe('True when candidates exceeded the 50-document cap; unread filings may match, so narrow forms or dates.'),
|
|
877
887
|
})
|
|
878
888
|
.optional()
|
|
879
|
-
.describe("Pre-2001 entity-scoped free-text path only
|
|
889
|
+
.describe("Pre-2001 entity-scoped free-text path only; each candidate's whole accession .txt is read, so a match may sit in an exhibit."),
|
|
880
890
|
dataset: datasetSchema
|
|
881
891
|
.extend({
|
|
882
892
|
truncated: z
|
|
@@ -1076,6 +1086,24 @@ export const searchFilingsTool = tool('secedgar_search_filings', {
|
|
|
1076
1086
|
? rows.slice(input.offset, input.offset + limit)
|
|
1077
1087
|
: rows.slice(0, collapseEftsHits(response.hits.hits.slice(0, limit)).length);
|
|
1078
1088
|
const results = pageRows.map(toInlineResult);
|
|
1089
|
+
// The next page in this path's `offset` unit, named only when that offset returns rows
|
|
1090
|
+
// (#259). Under sort=relevance it is a document offset EDGAR serves, short of a total it
|
|
1091
|
+
// calls exact — never offset plus the documents fetched, since EDGAR answers up to 100
|
|
1092
|
+
// from `from` whatever `size` asks; elsewhere a row of the one window this call sorted.
|
|
1093
|
+
// `unreachable` marks matches no offset reaches: past that one window, or past the
|
|
1094
|
+
// deepest relevance page EDGAR serves.
|
|
1095
|
+
const pageEnd = input.offset + limit;
|
|
1096
|
+
const documentsPastPage = response.hits.total.relation !== 'eq' || pageEnd < totalDocuments;
|
|
1097
|
+
const nextOffset = wideFetch
|
|
1098
|
+
? pageEnd < rows.length
|
|
1099
|
+
? pageEnd
|
|
1100
|
+
: undefined
|
|
1101
|
+
: documentsPastPage && pageEnd <= MAX_RELEVANCE_OFFSET
|
|
1102
|
+
? pageEnd
|
|
1103
|
+
: undefined;
|
|
1104
|
+
const unreachable = wideFetch
|
|
1105
|
+
? !windowComplete
|
|
1106
|
+
: documentsPastPage && pageEnd > MAX_RELEVANCE_OFFSET;
|
|
1079
1107
|
// The filings in hand — the rows the dataframe holds. EFTS's own form_filter
|
|
1080
1108
|
// aggregation counts documents by root form (amendments folded in), so it
|
|
1081
1109
|
// describes neither these rows nor `total` (#6, #124).
|
|
@@ -1119,6 +1147,8 @@ export const searchFilingsTool = tool('secedgar_search_filings', {
|
|
|
1119
1147
|
? `${searched} (filed ${dates.startDate} to ${dates.endDate})`
|
|
1120
1148
|
: searched;
|
|
1121
1149
|
ctx.enrich.echo(effectiveQuery);
|
|
1150
|
+
// EDGAR caps its count at 10,000 and calls it `gte` there: a floor, not the count.
|
|
1151
|
+
const documentCount = `${totalDocuments}${response.hits.total.relation === 'eq' ? '' : '+'}`;
|
|
1122
1152
|
if (totalDocuments === 0) {
|
|
1123
1153
|
// Genuine no-match — EFTS returned zero hits. Echo all active criteria; on the
|
|
1124
1154
|
// browse path (no query text) lead with the form/entity criteria instead of an
|
|
@@ -1153,38 +1183,53 @@ export const searchFilingsTool = tool('secedgar_search_filings', {
|
|
|
1153
1183
|
: 'switch to sort=relevance for EDGAR-side pagination up to 10,000 matching documents, or narrow the search with forms, dates, or entity targeting';
|
|
1154
1184
|
ctx.enrich.notice((windowComplete
|
|
1155
1185
|
? `Offset (${input.offset}) exceeds the ${rows.length} matching filings — lower the offset.`
|
|
1156
|
-
: `Offset (${input.offset}) exceeds the ${rows.length} filings in the fetched window (the first ${fetchedDocuments} of ${
|
|
1186
|
+
: `Offset (${input.offset}) exceeds the ${rows.length} filings in the fetched window (the first ${fetchedDocuments} of ${documentCount} matching ${countsFilings ? 'filings' : 'documents'} — date sorts and entity targeting fetch a single window): ${deeperPaging}.`) +
|
|
1157
1187
|
(dataset ? ` ${dataframeGuidance(dataset)}` : ''));
|
|
1158
1188
|
}
|
|
1159
|
-
else if (
|
|
1160
|
-
// `notice` is last-wins across notice/truncated, so the
|
|
1161
|
-
// dataframe pointer compose into one guidance string (#104).
|
|
1189
|
+
else if (nextOffset !== undefined || unreachable) {
|
|
1190
|
+
// `notice` is last-wins across notice/truncated, so the next page, the window
|
|
1191
|
+
// boundary, and the dataframe pointer compose into one guidance string (#104).
|
|
1162
1192
|
const guidance = [];
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1193
|
+
const ofTotal = `${total}${totalIsExact ? '' : '+'} matching filings`;
|
|
1194
|
+
const ofDocuments = `${documentCount} matching documents`;
|
|
1195
|
+
if (wideFetch) {
|
|
1196
|
+
if (nextOffset !== undefined)
|
|
1197
|
+
guidance.push(`Page on with offset ${nextOffset}.`);
|
|
1198
|
+
if (unreachable) {
|
|
1199
|
+
const reach = entityCik
|
|
1200
|
+
? 'narrow with forms or dates'
|
|
1201
|
+
: 'switch to sort=relevance to page deeper, or narrow with forms, dates, or entity targeting';
|
|
1202
|
+
guidance.push(countsFilings
|
|
1170
1203
|
? `The rows fetched are the first ${rows.length} of ${ofTotal} — ${reach} to reach the rest.`
|
|
1171
|
-
: `
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1204
|
+
: `total counts the filings among the first ${fetchedDocuments} of ${ofDocuments} — ${reach} to reach the rest.`);
|
|
1205
|
+
}
|
|
1206
|
+
}
|
|
1207
|
+
else {
|
|
1208
|
+
const fetched = countsFilings
|
|
1209
|
+
? `The rows fetched are the ${rows.length} filings from offset ${input.offset} of ${ofTotal}`
|
|
1210
|
+
: `total counts the filings among the ${fetchedDocuments} documents fetched from offset ${input.offset} of ${ofDocuments}`;
|
|
1211
|
+
const recur = countsFilings
|
|
1212
|
+
? ''
|
|
1213
|
+
: ', which counts documents under sort=relevance, so a filing can recur on the next page';
|
|
1214
|
+
// A page from 0 whose window held every match has nothing to qualify about total.
|
|
1215
|
+
guidance.push(nextOffset === undefined
|
|
1216
|
+
? `${fetched} — EDGAR serves no sort=relevance page past offset ${MAX_RELEVANCE_OFFSET}, so narrow the search with a shorter filed_after/filed_before window, a forms filter, or more specific terms to reach the rest.`
|
|
1217
|
+
: windowComplete
|
|
1218
|
+
? `Page on with offset ${nextOffset}${recur}.`
|
|
1219
|
+
: `${fetched} — page on with offset ${nextOffset}${recur}.`);
|
|
1175
1220
|
}
|
|
1176
1221
|
if (dataset)
|
|
1177
1222
|
guidance.push(dataframeGuidance(dataset));
|
|
1178
|
-
ctx.enrich.truncated({
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
});
|
|
1223
|
+
ctx.enrich.truncated({ shown: results.length, cap: limit, guidance: guidance.join(' ') });
|
|
1224
|
+
}
|
|
1225
|
+
else if (dataset) {
|
|
1226
|
+
ctx.enrich.notice(dataframeGuidance(dataset));
|
|
1183
1227
|
}
|
|
1184
1228
|
return {
|
|
1185
1229
|
total,
|
|
1186
1230
|
total_is_exact: totalIsExact,
|
|
1187
1231
|
total_documents: totalDocuments,
|
|
1232
|
+
next_offset: nextOffset,
|
|
1188
1233
|
results,
|
|
1189
1234
|
form_distribution: formDistribution,
|
|
1190
1235
|
dataset,
|
|
@@ -1201,6 +1246,9 @@ export const searchFilingsTool = tool('secedgar_search_filings', {
|
|
|
1201
1246
|
? ''
|
|
1202
1247
|
: ` — ${result.total_documents}${result.total_documents >= 10_000 ? '+' : ''} matching documents in the full-text index`;
|
|
1203
1248
|
const lines = [`Found ${result.total} filings (${exactness})${documents}`];
|
|
1249
|
+
if (result.next_offset !== undefined) {
|
|
1250
|
+
lines.push(`Next offset: ${result.next_offset} — pass as offset to read the next page.`);
|
|
1251
|
+
}
|
|
1204
1252
|
// Names, descriptions, filenames, and locations are SEC text, escaped to read back as written.
|
|
1205
1253
|
for (const r of result.results) {
|
|
1206
1254
|
const period = r.period_ending ? ` (period: ${r.period_ending})` : '';
|