@cyanheads/secedgar-mcp-server 0.20.1 → 0.21.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.
Files changed (126) hide show
  1. package/AGENTS.md +33 -26
  2. package/CLAUDE.md +33 -26
  3. package/README.md +23 -12
  4. package/changelog/0.21.x/0.21.0.md +35 -0
  5. package/changelog/0.21.x/0.21.1.md +29 -0
  6. package/dist/mcp-server/prompts/definitions/company-analysis.prompt.js +3 -3
  7. package/dist/mcp-server/prompts/definitions/company-analysis.prompt.js.map +1 -1
  8. package/dist/mcp-server/tools/annual-report-reads.d.ts +53 -0
  9. package/dist/mcp-server/tools/annual-report-reads.d.ts.map +1 -0
  10. package/dist/mcp-server/tools/annual-report-reads.js +145 -0
  11. package/dist/mcp-server/tools/annual-report-reads.js.map +1 -0
  12. package/dist/mcp-server/tools/blockquote.d.ts +13 -0
  13. package/dist/mcp-server/tools/blockquote.d.ts.map +1 -0
  14. package/dist/mcp-server/tools/blockquote.js +18 -0
  15. package/dist/mcp-server/tools/blockquote.js.map +1 -0
  16. package/dist/mcp-server/tools/calendar-quarter.d.ts +22 -0
  17. package/dist/mcp-server/tools/calendar-quarter.d.ts.map +1 -0
  18. package/dist/mcp-server/tools/calendar-quarter.js +34 -0
  19. package/dist/mcp-server/tools/calendar-quarter.js.map +1 -0
  20. package/dist/mcp-server/tools/definitions/company-search.tool.d.ts.map +1 -1
  21. package/dist/mcp-server/tools/definitions/company-search.tool.js +10 -21
  22. package/dist/mcp-server/tools/definitions/company-search.tool.js.map +1 -1
  23. package/dist/mcp-server/tools/definitions/compare-companies.tool.d.ts +12 -2
  24. package/dist/mcp-server/tools/definitions/compare-companies.tool.d.ts.map +1 -1
  25. package/dist/mcp-server/tools/definitions/compare-companies.tool.js +120 -29
  26. package/dist/mcp-server/tools/definitions/compare-companies.tool.js.map +1 -1
  27. package/dist/mcp-server/tools/definitions/find-holders.tool.d.ts.map +1 -1
  28. package/dist/mcp-server/tools/definitions/find-holders.tool.js +9 -16
  29. package/dist/mcp-server/tools/definitions/find-holders.tool.js.map +1 -1
  30. package/dist/mcp-server/tools/definitions/get-beneficial-owners.tool.d.ts +31 -9
  31. package/dist/mcp-server/tools/definitions/get-beneficial-owners.tool.d.ts.map +1 -1
  32. package/dist/mcp-server/tools/definitions/get-beneficial-owners.tool.js +268 -88
  33. package/dist/mcp-server/tools/definitions/get-beneficial-owners.tool.js.map +1 -1
  34. package/dist/mcp-server/tools/definitions/get-filing.tool.d.ts +10 -0
  35. package/dist/mcp-server/tools/definitions/get-filing.tool.d.ts.map +1 -1
  36. package/dist/mcp-server/tools/definitions/get-filing.tool.js +164 -10
  37. package/dist/mcp-server/tools/definitions/get-filing.tool.js.map +1 -1
  38. package/dist/mcp-server/tools/definitions/get-financials.tool.d.ts +1 -0
  39. package/dist/mcp-server/tools/definitions/get-financials.tool.d.ts.map +1 -1
  40. package/dist/mcp-server/tools/definitions/get-financials.tool.js +219 -128
  41. package/dist/mcp-server/tools/definitions/get-financials.tool.js.map +1 -1
  42. package/dist/mcp-server/tools/definitions/get-fund-holdings.tool.d.ts.map +1 -1
  43. package/dist/mcp-server/tools/definitions/get-fund-holdings.tool.js +2 -3
  44. package/dist/mcp-server/tools/definitions/get-fund-holdings.tool.js.map +1 -1
  45. package/dist/mcp-server/tools/definitions/get-insider-transactions.tool.d.ts +44 -0
  46. package/dist/mcp-server/tools/definitions/get-insider-transactions.tool.d.ts.map +1 -1
  47. package/dist/mcp-server/tools/definitions/get-insider-transactions.tool.js +336 -75
  48. package/dist/mcp-server/tools/definitions/get-insider-transactions.tool.js.map +1 -1
  49. package/dist/mcp-server/tools/definitions/get-institutional-holdings.tool.d.ts +12 -0
  50. package/dist/mcp-server/tools/definitions/get-institutional-holdings.tool.d.ts.map +1 -1
  51. package/dist/mcp-server/tools/definitions/get-institutional-holdings.tool.js +16 -31
  52. package/dist/mcp-server/tools/definitions/get-institutional-holdings.tool.js.map +1 -1
  53. package/dist/mcp-server/tools/definitions/get-material-events.tool.d.ts +15 -0
  54. package/dist/mcp-server/tools/definitions/get-material-events.tool.d.ts.map +1 -1
  55. package/dist/mcp-server/tools/definitions/get-material-events.tool.js +107 -54
  56. package/dist/mcp-server/tools/definitions/get-material-events.tool.js.map +1 -1
  57. package/dist/mcp-server/tools/definitions/get-snapshot.tool.d.ts +5 -0
  58. package/dist/mcp-server/tools/definitions/get-snapshot.tool.d.ts.map +1 -1
  59. package/dist/mcp-server/tools/definitions/get-snapshot.tool.js +48 -17
  60. package/dist/mcp-server/tools/definitions/get-snapshot.tool.js.map +1 -1
  61. package/dist/mcp-server/tools/definitions/index.d.ts +526 -464
  62. package/dist/mcp-server/tools/definitions/index.d.ts.map +1 -1
  63. package/dist/mcp-server/tools/definitions/search-concepts.tool.js +1 -1
  64. package/dist/mcp-server/tools/definitions/search-filings.tool.d.ts +16 -0
  65. package/dist/mcp-server/tools/definitions/search-filings.tool.d.ts.map +1 -1
  66. package/dist/mcp-server/tools/definitions/search-filings.tool.js +194 -70
  67. package/dist/mcp-server/tools/definitions/search-filings.tool.js.map +1 -1
  68. package/dist/mcp-server/tools/filing-dates.d.ts +48 -0
  69. package/dist/mcp-server/tools/filing-dates.d.ts.map +1 -0
  70. package/dist/mcp-server/tools/filing-dates.js +99 -0
  71. package/dist/mcp-server/tools/filing-dates.js.map +1 -0
  72. package/dist/mcp-server/tools/limit-clamp.d.ts.map +1 -1
  73. package/dist/mcp-server/tools/limit-clamp.js +6 -2
  74. package/dist/mcp-server/tools/limit-clamp.js.map +1 -1
  75. package/dist/services/edgar/body-text-decoder.d.ts +33 -0
  76. package/dist/services/edgar/body-text-decoder.d.ts.map +1 -0
  77. package/dist/services/edgar/body-text-decoder.js +103 -0
  78. package/dist/services/edgar/body-text-decoder.js.map +1 -0
  79. package/dist/services/edgar/call-scope.d.ts +9 -0
  80. package/dist/services/edgar/call-scope.d.ts.map +1 -1
  81. package/dist/services/edgar/call-scope.js +3 -0
  82. package/dist/services/edgar/call-scope.js.map +1 -1
  83. package/dist/services/edgar/concept-map.d.ts.map +1 -1
  84. package/dist/services/edgar/concept-map.js +70 -12
  85. package/dist/services/edgar/concept-map.js.map +1 -1
  86. package/dist/services/edgar/concept-series.d.ts +126 -9
  87. package/dist/services/edgar/concept-series.d.ts.map +1 -1
  88. package/dist/services/edgar/concept-series.js +217 -21
  89. package/dist/services/edgar/concept-series.js.map +1 -1
  90. package/dist/services/edgar/edgar-api-service.d.ts +31 -15
  91. package/dist/services/edgar/edgar-api-service.d.ts.map +1 -1
  92. package/dist/services/edgar/edgar-api-service.js +182 -36
  93. package/dist/services/edgar/edgar-api-service.js.map +1 -1
  94. package/dist/services/edgar/eight-k-items.d.ts +19 -1
  95. package/dist/services/edgar/eight-k-items.d.ts.map +1 -1
  96. package/dist/services/edgar/eight-k-items.js +24 -1
  97. package/dist/services/edgar/eight-k-items.js.map +1 -1
  98. package/dist/services/edgar/filing-headers.d.ts +22 -10
  99. package/dist/services/edgar/filing-headers.d.ts.map +1 -1
  100. package/dist/services/edgar/filing-headers.js +98 -15
  101. package/dist/services/edgar/filing-headers.js.map +1 -1
  102. package/dist/services/edgar/filing-to-text.d.ts +13 -6
  103. package/dist/services/edgar/filing-to-text.d.ts.map +1 -1
  104. package/dist/services/edgar/filing-to-text.js +23 -3
  105. package/dist/services/edgar/filing-to-text.js.map +1 -1
  106. package/dist/services/edgar/fiscal-periods.d.ts +14 -1
  107. package/dist/services/edgar/fiscal-periods.d.ts.map +1 -1
  108. package/dist/services/edgar/fiscal-periods.js +47 -18
  109. package/dist/services/edgar/fiscal-periods.js.map +1 -1
  110. package/dist/services/edgar/form4-amendments.d.ts +63 -0
  111. package/dist/services/edgar/form4-amendments.d.ts.map +1 -0
  112. package/dist/services/edgar/form4-amendments.js +99 -0
  113. package/dist/services/edgar/form4-amendments.js.map +1 -0
  114. package/dist/services/edgar/mirror/companyfacts-sync.d.ts +6 -1
  115. package/dist/services/edgar/mirror/companyfacts-sync.d.ts.map +1 -1
  116. package/dist/services/edgar/mirror/companyfacts-sync.js +29 -6
  117. package/dist/services/edgar/mirror/companyfacts-sync.js.map +1 -1
  118. package/dist/services/edgar/ownership-parser.d.ts +24 -0
  119. package/dist/services/edgar/ownership-parser.d.ts.map +1 -1
  120. package/dist/services/edgar/ownership-parser.js +82 -0
  121. package/dist/services/edgar/ownership-parser.js.map +1 -1
  122. package/dist/services/edgar/types.d.ts +5 -1
  123. package/dist/services/edgar/types.d.ts.map +1 -1
  124. package/package.json +3 -3
  125. package/server.json +3 -3
  126. package/skills/secedgar-guide/SKILL.md +11 -7
@@ -1,18 +1,22 @@
1
1
  /**
2
- * @fileoverview Blockholder ownership for one issuer, parsed from the structured
3
- * SCHEDULE 13D / SCHEDULE 13G XML that SEC has required since 2024-12-18. Completes the
4
- * ownership triangle alongside secedgar_get_insider_transactions (Form 4 officers and
5
- * directors) and secedgar_get_institutional_holdings (13F portfolios): this tool covers the
6
- * 5%-and-over stakes, activist and passive. Discovery runs off the issuer's own submissions
7
- * feed — SEC cross-lists a 13D/G under every CIK party to it. Each document's issuer CIK
8
- * must therefore match before its ownership is attributed to the requested company.
2
+ * @fileoverview Blockholder ownership parsed from the structured SCHEDULE 13D / SCHEDULE 13G
3
+ * XML that SEC has required since 2024-12-18: the schedules filed about one issuer, or under
4
+ * role `filer` those one holder filed across issuers. Completes the ownership triangle
5
+ * alongside secedgar_get_insider_transactions (Form 4 officers and directors) and
6
+ * secedgar_get_institutional_holdings (13F portfolios): this tool covers the 5%-and-over
7
+ * stakes, activist and passive. Discovery runs off the company's own submissions feed, which
8
+ * lists each schedule it is party to on one side — about it, or filed by it — so each role
9
+ * reads its own side and counts the other before any document is read (#276). A date window
10
+ * also reads the archive pages behind `recent`, and `offset` continues a truncated scan (#279).
9
11
  * @module mcp-server/tools/definitions/get-beneficial-owners
10
12
  */
11
13
  import { tool, z } from '@cyanheads/mcp-ts-core';
12
14
  import { JsonRpcErrorCode } from '@cyanheads/mcp-ts-core/errors';
13
15
  import { escapeMarkdownInline } from '@cyanheads/mcp-ts-core/utils';
14
16
  import { ambiguousMatches } from '../ambiguous-matches.js';
17
+ import { blockquote } from '../blockquote.js';
15
18
  import { datasetSchema } from '../dataset-schema.js';
19
+ import { checkFilingDates, describeWindow, filingDateField, } from '../filing-dates.js';
16
20
  import { limitClamp, withLimitClamps, } from '../limit-clamp.js';
17
21
  import { resolvedAsField } from '../resolved-as.js';
18
22
  import { SEC_UPSTREAM_ERRORS } from '../sec-upstream-errors.js';
@@ -22,11 +26,14 @@ import { CallScope } from '../../../services/edgar/call-scope.js';
22
26
  import { getEdgarApiService, rawDocumentName } from '../../../services/edgar/edgar-api-service.js';
23
27
  import { nonUsListingNote } from '../../../services/edgar/listing-codes.js';
24
28
  import { sameCik } from '../../../services/edgar/same-cik.js';
29
+ import { ARCHIVE_PAGE_SCAN_CAP, SubmissionsArchiveWalk, } from '../../../services/edgar/submissions-archive.js';
25
30
  /**
26
31
  * First filing date on which every beneficial-ownership filing arrived in the structured
27
32
  * format. The legacy `SC 13D` / `SC 13G` names stop dead here: EDGAR full-text search counts
28
33
  * 37 legacy filings on 2024-12-17 and zero on 2024-12-18, against 44 structured ones the
29
- * same day. Filings before it are text or HTML documents with no XML to parse.
34
+ * same day. Filings before it are text or HTML documents with no XML to parse. A few keep the
35
+ * legacy name after it, still text, such as a tender offer's combined SC TO-T/A + SC 13D/A
36
+ * amendment: EDGAR's quarterly indexes list 36 SC 13D/A accessions from 2025-Q1 through 2026-Q3.
30
37
  */
31
38
  const STRUCTURED_FROM = '2024-12-18';
32
39
  /** Maximum schedule documents examined in one newest-first scan. */
@@ -35,6 +42,42 @@ const FILING_SCAN_CAP = 50;
35
42
  const FILING_RESULT_CAP = 20;
36
43
  /** Legacy form names that carry the same disclosure with no parseable XML. */
37
44
  const LEGACY_FORMS = ['SC 13D', 'SC 13D/A', 'SC 13G', 'SC 13G/A'];
45
+ /** The structured form names, as a secedgar_search_filings `forms` value. */
46
+ const SCHEDULE_FORMS = '["SCHEDULE 13D","SCHEDULE 13D/A","SCHEDULE 13G","SCHEDULE 13G/A"]';
47
+ /**
48
+ * The side a schedule row of a company's own submissions feed sits on. EDGAR files a schedule
49
+ * under its subject company's `005-` file number and lists it in two feeds: the subject's,
50
+ * whose row carries that number, and its one filer's, whose row carries none — the inverse of
51
+ * a Form 4 (#260). Only an empty file number marks the filer's side, so a feed without the
52
+ * column reads as all subject-side: the issuer role reads every row, its issuer check after
53
+ * the read deciding (#189), and the filer role selects none.
54
+ */
55
+ function sideOf(fileNumbers, i) {
56
+ return fileNumbers?.[i] === '' ? 'filer' : 'issuer';
57
+ }
58
+ /**
59
+ * The notice sentence counting the schedules on the side `role` leaves unread, naming the
60
+ * role that reads them. `scope` places them: "in its recent submissions", or the window.
61
+ */
62
+ function otherSideSentence(role, count, scope) {
63
+ const one = count === 1;
64
+ const lead = `${count} ${one ? 'schedule' : 'schedules'} ${scope}`;
65
+ return role === 'issuer'
66
+ ? `${lead} ${one ? 'was' : 'were'} filed by this company itself and ${one ? 'was' : 'were'} not read. Pass role: "filer" to read ${one ? 'it' : 'them'} as this company's own ${one ? 'stake' : 'stakes'}.`
67
+ : `${lead} ${one ? 'names' : 'name'} this company as the subject, which omitting role reads.`;
68
+ }
69
+ /** Descending code-point order, for the ISO dates, timestamps, and accession numbers compared. */
70
+ const descending = (a, b) => (a < b ? 1 : a > b ? -1 : 0);
71
+ /**
72
+ * Newest first: filing date, then acceptance time, then accession number — the order the feed
73
+ * lists schedules in, made explicit so `offset` counts the same schedules across calls that read
74
+ * different blocks (#279).
75
+ */
76
+ function newestFirst(a, b) {
77
+ return (descending(a.filingDate, b.filingDate) ||
78
+ descending(a.acceptance, b.acceptance) ||
79
+ descending(a.accessionNumber, b.accessionNumber));
80
+ }
38
81
  /**
39
82
  * Character bound on the Item 4 purpose-of-transaction prose, line breaks counted. Item 4 is
40
83
  * the substantive 13D field, so the bound sits just above the 90th percentile of 48 sampled
@@ -59,17 +102,6 @@ function clip(text, max) {
59
102
  return { text, cut: false };
60
103
  return { text: text.slice(0, max), cut: true };
61
104
  }
62
- /**
63
- * Filer-written text as the lines of a Markdown blockquote that a CommonMark parse reads back
64
- * as `text` (CR and CRLF as LF): escaped, then every line of the escaped value prefixed `> `
65
- * under `indent`. The escape writes each line break as a hard break, so the quote stays one
66
- * paragraph. The caller follows the quote with a blank line before anything else it writes.
67
- */
68
- function quote(text, indent = '') {
69
- return escapeMarkdownInline(text)
70
- .split('\n')
71
- .map((line) => `${indent}> ${line}`);
72
- }
73
105
  /** `limit`: a call returns at most 20 matching filings (#197). */
74
106
  const filingsLimit = limitClamp({
75
107
  tool: 'secedgar_get_beneficial_owners',
@@ -78,11 +110,11 @@ const filingsLimit = limitClamp({
78
110
  cap: FILING_RESULT_CAP,
79
111
  bound: 1000,
80
112
  shape: (n) => n.default(10),
81
- description: 'Number of successfully parsed filings naming the requested issuer to return, newest first. Other-issuer schedules and failed documents do not consume this limit; at most 50 documents are examined. Default 10.',
113
+ description: 'Parsed filings to return, newest first. Other-issuer schedules and failed documents do not consume this limit; at most 50 documents are examined. Default 10.',
82
114
  });
83
115
  export const getBeneficialOwnersTool = tool('secedgar_get_beneficial_owners', {
84
116
  title: 'Get Beneficial Owners',
85
- description: "List the 5%-and-over beneficial owners of a public company, parsed from the structured SCHEDULE 13D and SCHEDULE 13G filings made about it. The input is the ISSUER — the company being held — which is the opposite direction from secedgar_get_institutional_holdings, where the input is the manager. 13D is the activist form and carries the filer's stated purpose of the transaction; 13G is the passive form and has no purpose field at all, which is the substantive difference between a stake that intends to influence control and one that does not. Every filing is returned with each reporting person listed separately, because voting power, dispositive power, and percent of class are reported per person even on a joint filing where several funds and their controlling principal report overlapping shares — summing those percentages double-counts the same position. Coverage starts at 2024-12-18, when SEC replaced the legacy SC 13D / SC 13G text filings with this XML format; earlier stakes are readable but not parseable, and the response reports how many of them the issuer has. The full parsed set is materialized as df_<id> when a canvas is available, one row per reporting person, so it joins against the insider dataframes on issuer CIK and the 13F and NPORT-P dataframes on CUSIP — inspect it with secedgar_dataframe_describe, then analyze it with secedgar_dataframe_query.",
117
+ description: 'List the 5%-and-over beneficial owners of a public company from the structured SCHEDULE 13D and 13G filings made about it. The input is the ISSUER, the company held — the reverse of secedgar_get_institutional_holdings, whose input is the manager; with role "filer" it is a holder instead, and the result is the schedules that holder filed, across issuers. 13D is the activist form and states the filer\'s purpose; 13G is the passive form, with no purpose field. Each reporting person is listed separately: voting power, dispositive power, and percent of class are reported per person even on a joint filing, where a fund, its adviser, and its principal report the same shares, so summing them double-counts. Coverage starts 2024-12-18, when SEC replaced the legacy SC 13D / SC 13G text filings with this XML; earlier ones are readable but not parseable, and the response counts them. The full parsed set is materialized as df_<id> when a canvas is available, one row per reporting person, joining the insider, 13F, and NPORT-P dataframes — inspect it with secedgar_dataframe_describe, then query it with secedgar_dataframe_query.',
86
118
  annotations: { readOnlyHint: true, idempotentHint: true, openWorldHint: true },
87
119
  errors: [
88
120
  {
@@ -100,17 +132,22 @@ export const getBeneficialOwnersTool = tool('secedgar_get_beneficial_owners', {
100
132
  {
101
133
  reason: 'no_filings_found',
102
134
  code: JsonRpcErrorCode.NotFound,
103
- when: 'The issuer has no structured SCHEDULE 13D/13G filings matching the requested form kind',
135
+ when: 'On an undated call, no structured SCHEDULE 13D/13G matching the form filters sits on either side of the recent filings — none about the company and none it filed',
104
136
  recovery: 'Use secedgar_search_filings with forms ["SC 13D","SC 13G"] to reach the pre-2024-12-18 text filings, then read them with secedgar_get_filing.',
105
137
  },
106
138
  ...SEC_UPSTREAM_ERRORS,
107
139
  ],
108
- input: z.object({
140
+ input: z
141
+ .object({
109
142
  issuer: z
110
143
  .string()
111
144
  .trim()
112
145
  .min(1, 'Issuer cannot be blank')
113
- .describe('The company whose blockholders you want — a ticker ("AAPL"), a 10-digit CIK ("0000320193"), or a company name. This is the subject company of the schedule, not the investor filing it; passing an investment manager here returns the schedules filed about that manager, which is almost always empty.'),
146
+ .describe('The company whose blockholders you want, or under role filer the holder whose own schedules to read: a ticker ("AAPL"), a 10-digit CIK ("0000320193"), or a company name. A holder with no ticker resolves only by CIK.'),
147
+ role: z
148
+ .enum(['issuer', 'filer'])
149
+ .default('issuer')
150
+ .describe('"issuer" (default): read the schedules filed about the company, naming its holders. "filer": those it filed, its own stakes across issuers. A co-reporting person named only on another filer\'s cover page is found instead by secedgar_search_filings on its quoted 10-digit CIK.'),
114
151
  form_kind: z
115
152
  .enum(['all', '13D', '13G'])
116
153
  .default('all')
@@ -118,28 +155,42 @@ export const getBeneficialOwnersTool = tool('secedgar_get_beneficial_owners', {
118
155
  include_amendments: z
119
156
  .boolean()
120
157
  .default(true)
121
- .describe('Whether to include amendments (SCHEDULE 13D/A, SCHEDULE 13G/A). Amendments carry the current position and are how an ongoing stake is tracked, so they are included by default. Set false to see only filings that opened a new position.'),
158
+ .describe('Include amendments (SCHEDULE 13D/A, 13G/A), true by default: they carry the current position of an ongoing stake. False returns only filings that opened a position.'),
122
159
  limit: filingsLimit.schema(true),
123
- }),
160
+ filed_after: filingDateField('Only schedules filed on or after this date (YYYY-MM-DD). An undated call reads the recent submissions (last year or 1,000 filings); a window also reads the archive, from 2024-12-18 on.'),
161
+ filed_before: filingDateField('Only schedules filed on or before this date (YYYY-MM-DD). Use alone or with filed_after.'),
162
+ offset: z
163
+ .number()
164
+ .int()
165
+ .min(0)
166
+ .default(0)
167
+ .describe('Matching schedules to skip, newest first by filing date, acceptance time, then accession number. A truncated result names the filed_before and offset that continue it.'),
168
+ })
169
+ .superRefine(checkFilingDates),
124
170
  // The company-identifier keys other tools take. `issuer` is this tool's only company
125
- // input, so each maps one-to-one (#152).
171
+ // input, so each maps one-to-one (#152); the filing-date spellings are the insider tool's.
126
172
  inputAliases: {
127
173
  company: 'issuer',
128
174
  ticker: 'issuer',
129
175
  cik: 'issuer',
130
176
  ticker_or_cik: 'issuer',
131
177
  filing_limit: 'limit',
178
+ start_date: 'filed_after',
179
+ date_from: 'filed_after',
180
+ end_date: 'filed_before',
181
+ date_to: 'filed_before',
132
182
  },
133
183
  output: z.object({
134
184
  issuer: z.string().describe('The issuer input, echoed.'),
135
- issuer_cik: z.string().describe('CIK of the resolved issuer, zero-padded to 10 digits.'),
136
- issuer_name: z.string().describe('EDGAR-conformed name of the resolved issuer.'),
185
+ issuer_cik: z.string().describe('Resolved CIK, zero-padded to 10 digits.'),
186
+ issuer_name: z.string().describe('EDGAR-conformed name of the resolved CIK.'),
187
+ role: z.literal('filer').optional().describe('Role filer only; issuer_* then name the filer.'),
137
188
  form_kind: z
138
189
  .enum(['all', '13D', '13G'])
139
190
  .describe('The schedule filter applied (default "all").'),
140
191
  total_structured_filings: z
141
192
  .number()
142
- .describe('Indexed 13D/13G schedules matching form/amendment filters in the recent submissions window.'),
193
+ .describe('Role-side schedules matching the filters and window, from offset on, in the feed blocks read.'),
143
194
  filings_parsed: z.number().describe('Matching parsed filings, capped by limit.'),
144
195
  filings_examined: z.number().describe('Matches + exclusions + failures; at most 50 documents.'),
145
196
  filings_excluded_other_issuer: z
@@ -163,24 +214,27 @@ export const getBeneficialOwnersTool = tool('secedgar_get_beneficial_owners', {
163
214
  .describe('True when filings_failed is nonempty, independently of truncation.'),
164
215
  structured_coverage_from: z
165
216
  .string()
166
- .describe('First date SEC required this XML format (YYYY-MM-DD); earlier filings cannot be parsed here.'),
217
+ .describe('First date of the XML format (YYYY-MM-DD); earlier filings are not parsed.'),
167
218
  legacy_filings_before_coverage: z
168
219
  .number()
169
- .describe('Legacy SC 13D / SC 13G filings (pre-2024-12-18) in the recent submissions window (last year or 1,000 filings), so a floor; find them with secedgar_search_filings.'),
220
+ .describe('Role-side legacy SC 13D / SC 13G text filings in the window and feed blocks read, so a floor; find them with secedgar_search_filings.'),
170
221
  filings: z
171
222
  .array(z
172
223
  .object({
173
224
  form: z.string().describe('EDGAR form name, e.g. "SCHEDULE 13D" or "SCHEDULE 13G/A".'),
174
- schedule: z
175
- .enum(['13D', '13G'])
176
- .describe('Which schedule this is — 13D activist, 13G passive.'),
177
- is_amendment: z.boolean().describe('True when the form name carries the /A suffix.'),
225
+ schedule: z.enum(['13D', '13G']).describe('13D activist or 13G passive.'),
226
+ is_amendment: z.boolean().describe('True when the form ends in /A.'),
178
227
  amendment_number: z
179
228
  .string()
180
229
  .optional()
181
- .describe('Amendment sequence from the cover page. Absent on an original filing.'),
230
+ .describe('Amendment number from the cover page; absent on an original.'),
182
231
  accession_number: z.string().describe('Accession number for secedgar_get_filing.'),
183
- filing_date: z.string().describe('Date the schedule was submitted (YYYY-MM-DD).'),
232
+ filing_date: z.string().describe('Filing date (YYYY-MM-DD).'),
233
+ issuer_cik: z
234
+ .string()
235
+ .optional()
236
+ .describe('Subject CIK, zero-padded (role filer only).'),
237
+ issuer_name: z.string().optional().describe('Subject name as filed (role filer only).'),
184
238
  event_date: z
185
239
  .string()
186
240
  .optional()
@@ -195,7 +249,7 @@ export const getBeneficialOwnersTool = tool('secedgar_get_beneficial_owners', {
195
249
  purpose_of_transaction: z
196
250
  .string()
197
251
  .optional()
198
- .describe('Item 4 purpose of transaction as filed; 13D only. Absent on 13G and on an amendment that restates none.'),
252
+ .describe('Item 4 purpose of transaction as filed; absent on 13G and on a 13D amendment restating none.'),
199
253
  purpose_truncated: z
200
254
  .boolean()
201
255
  .describe(`True when purpose_of_transaction holds only its first ${charCount(PURPOSE_MAX_CHARS)} characters; secedgar_get_filing has it whole.`),
@@ -241,7 +295,7 @@ export const getBeneficialOwnersTool = tool('secedgar_get_beneficial_owners', {
241
295
  excludes_certain_shares: z
242
296
  .boolean()
243
297
  .optional()
244
- .describe('True when the aggregate excludes shares this person disclaims. Absent when the filing does not say.'),
298
+ .describe('True when the aggregate excludes shares this person disclaims; absent when unstated.'),
245
299
  notes: z
246
300
  .string()
247
301
  .optional()
@@ -253,23 +307,28 @@ export const getBeneficialOwnersTool = tool('secedgar_get_beneficial_owners', {
253
307
  .describe('One reporting person from the schedule cover page.'))
254
308
  .describe('Every reporting person; a joint filing lists each fund, adviser, and principal separately.'),
255
309
  })
256
- .describe('One SCHEDULE 13D or 13G filing made about this issuer.'))
257
- .describe('Blockholder filings, newest first, capped at limit.'),
310
+ .describe('One SCHEDULE 13D or 13G filing.'))
311
+ .describe('Parsed filings, newest first, capped at limit.'),
258
312
  dataset: datasetSchema
259
313
  .extend({
260
- truncated: z.boolean().describe('True when indexed schedules remain unexamined.'),
314
+ truncated: z
315
+ .boolean()
316
+ .describe('True when schedules remain past those examined, or may on unread archive pages.'),
261
317
  })
262
318
  .optional()
263
- .describe('Dataframe with one row per reporting person across parsed filings; joins insider dataframes on issuer_cik, and 13F and NPORT-P dataframes on cusip. Absent when canvas is unavailable or nothing parsed.'),
319
+ .describe('One row per reporting person across parsed filings; joins insider dataframes on issuer_cik, 13F and NPORT-P ones on cusip. Absent without a canvas or when nothing parsed.'),
264
320
  }),
265
321
  enrichment: {
266
322
  notice: z
267
323
  .string()
268
324
  .optional()
269
- .describe('Exclusions, document recovery, scan bounds, cut text, and dataframe guidance.'),
270
- truncated: z.boolean().optional().describe('True when filings_not_examined > 0.'),
271
- shown: z.number().optional().describe('Number of filings returned.'),
272
- cap: z.number().optional().describe('Result limit or document ceiling that stopped scanning.'),
325
+ .describe('Unread side, exclusions, failures, scan bounds, cut text, dataframe guidance, continuation.'),
326
+ truncated: z.boolean().optional().describe('True when the notice names a continuation.'),
327
+ shown: z.number().optional().describe('Filings returned.'),
328
+ cap: z
329
+ .number()
330
+ .optional()
331
+ .describe('Result limit, 50-document ceiling, or 10-page archive cap that stopped the scan.'),
273
332
  resolvedAs: resolvedAsField,
274
333
  },
275
334
  enrichmentTrailer: {
@@ -294,40 +353,84 @@ export const getBeneficialOwnersTool = tool('secedgar_get_beneficial_owners', {
294
353
  if (match.reading)
295
354
  ctx.enrich({ resolvedAs: match.reading });
296
355
  const submissions = await api.getSubmissions(match.cik, scope);
297
- const recent = submissions.filings.recent;
298
- // SEC indexes a 13D/G under every CIK party to it, so the issuer's own feed already
299
- // carries the schedules filed about it — no entity-scoped search needed.
300
- const selected = [];
301
- let totalMatching = 0;
356
+ const filer = input.role === 'filer';
357
+ const filedAfter = input.filed_after || undefined;
358
+ const filedBefore = input.filed_before || undefined;
359
+ const dated = Boolean(filedAfter || filedBefore);
360
+ const { offset } = input;
361
+ const inWindow = (date) => (!filedAfter || date >= filedAfter) && (!filedBefore || date <= filedBefore);
362
+ // SEC lists a 13D/G in the feed of every CIK party to it, so the company's own feed holds
363
+ // both sides — no entity-scoped search needed. The role's side is read; the other side's
364
+ // matching schedules are only counted, for the notice that names the role reading them.
365
+ const roleRows = [];
366
+ const matching = { issuer: 0, filer: 0 };
302
367
  let legacyCount = 0;
303
- for (let i = 0; i < recent.form.length; i++) {
304
- const form = recent.form[i] ?? '';
305
- if (LEGACY_FORMS.includes(form)) {
306
- legacyCount++;
307
- continue;
368
+ /** Counts one feed block's rows and keeps its role-side matches; returns its oldest filing date. */
369
+ const take = (block) => {
370
+ let oldest = '';
371
+ for (let i = 0; i < block.form.length; i++) {
372
+ const filingDate = block.filingDate[i] ?? '';
373
+ if (!oldest || filingDate < oldest)
374
+ oldest = filingDate;
375
+ if (!inWindow(filingDate))
376
+ continue;
377
+ const form = block.form[i] ?? '';
378
+ const side = sideOf(block.fileNumber, i);
379
+ if (LEGACY_FORMS.includes(form)) {
380
+ if (side === input.role)
381
+ legacyCount++;
382
+ continue;
383
+ }
384
+ const schedule = formNameToSchedule(form);
385
+ if (!schedule)
386
+ continue;
387
+ if (input.form_kind !== 'all' && schedule !== input.form_kind)
388
+ continue;
389
+ if (!input.include_amendments && form.endsWith('/A'))
390
+ continue;
391
+ matching[side]++;
392
+ if (side === input.role) {
393
+ roleRows.push({
394
+ form,
395
+ schedule,
396
+ acceptance: block.acceptanceDateTime?.[i] ?? '',
397
+ accessionNumber: block.accessionNumber[i] ?? '',
398
+ filingDate,
399
+ document: rawDocumentName(block.primaryDocument[i]),
400
+ });
401
+ }
308
402
  }
309
- const schedule = formNameToSchedule(form);
310
- if (!schedule)
311
- continue;
312
- if (input.form_kind !== 'all' && schedule !== input.form_kind)
313
- continue;
314
- if (!input.include_amendments && form.endsWith('/A'))
315
- continue;
316
- totalMatching++;
317
- if (selected.length < FILING_SCAN_CAP) {
318
- selected.push({
319
- form,
320
- schedule,
321
- accessionNumber: recent.accessionNumber[i] ?? '',
322
- filingDate: recent.filingDate[i] ?? '',
323
- document: rawDocumentName(recent.primaryDocument[i]),
324
- });
403
+ return oldest;
404
+ };
405
+ /** Oldest filing date of any row read, in the window or not: where the blocks read end. */
406
+ let oldestRead = take(submissions.filings.recent);
407
+ // A window also reads the archive pages behind `recent`, newest first, until the role-side
408
+ // schedules past `offset` exceed the 50-document scan or the shared page cap ends the walk.
409
+ // No page ends before structured coverage starts, so a window ending earlier reads none.
410
+ // An offset with no window pages `recent` alone, as an undated call reads it.
411
+ const walkFloor = filedAfter && filedAfter > STRUCTURED_FROM ? filedAfter : STRUCTURED_FROM;
412
+ let walk;
413
+ if (dated && !(filedBefore && filedBefore < STRUCTURED_FROM)) {
414
+ walk = new SubmissionsArchiveWalk(api, submissions, { filedAfter: walkFloor, filedBefore, order: 'newest-first' }, scope);
415
+ if (roleRows.length <= offset + FILING_SCAN_CAP) {
416
+ for await (const { block } of walk) {
417
+ const reached = take(block);
418
+ if (reached && (!oldestRead || reached < oldestRead))
419
+ oldestRead = reached;
420
+ if (roleRows.length > offset + FILING_SCAN_CAP)
421
+ break;
422
+ }
325
423
  }
326
424
  }
327
- if (totalMatching === 0) {
328
- const kindLabel = input.form_kind === 'all' ? 'SCHEDULE 13D/13G' : `SCHEDULE ${input.form_kind}`;
425
+ roleRows.sort(newestFirst);
426
+ const pending = roleRows.slice(offset);
427
+ const selected = pending.slice(0, FILING_SCAN_CAP);
428
+ const totalMatching = pending.length;
429
+ const otherSide = matching[filer ? 'issuer' : 'filer'];
430
+ const kindLabel = input.form_kind === 'all' ? 'SCHEDULE 13D/13G' : `SCHEDULE ${input.form_kind}`;
431
+ if (!dated && roleRows.length === 0 && otherSide === 0) {
329
432
  const legacyHint = legacyCount > 0
330
- ? `Its submissions window does hold ${legacyCount} legacy SC 13D/SC 13G filings from before ${STRUCTURED_FROM}; those are text filings with no XML to parse — read them with secedgar_get_filing.`
433
+ ? `Its submissions window does hold ${legacyCount} legacy SC 13D/SC 13G filings ${filer ? 'it filed ' : ''}from before ${STRUCTURED_FROM}; those are text filings with no XML to parse — read them with secedgar_get_filing.`
331
434
  : `Blockholder filings from before ${STRUCTURED_FROM} use the legacy SC 13D / SC 13G names and are not parseable into this schema — search for them with secedgar_search_filings.`;
332
435
  throw ctx.fail('no_filings_found', `No structured ${kindLabel} filings found for ${submissions.name} (CIK ${match.cik}). ${legacyHint}`, {
333
436
  issuer_cik: match.cik,
@@ -343,7 +446,8 @@ export const getBeneficialOwnersTool = tool('secedgar_get_beneficial_owners', {
343
446
  const filings = [];
344
447
  // One row per reporting person — the grain the ownership question is asked at, and the
345
448
  // grain that joins to the insider dataframes on issuer_cik and the 13F and NPORT-P ones on
346
- // cusip. Rows take the filer text from the parse, uncut, where the inline result is bounded.
449
+ // cusip. Rows take the filer text from the parse, uncut, where the inline result is bounded,
450
+ // and name the resolved issuer, or under `filer` each schedule's own subject.
347
451
  const rows = [];
348
452
  for (const ref of selected) {
349
453
  if (filings.length >= limit)
@@ -361,10 +465,13 @@ export const getBeneficialOwnersTool = tool('secedgar_get_beneficial_owners', {
361
465
  });
362
466
  continue;
363
467
  }
364
- if (!sameCik(parsed.issuer_cik, match.cik)) {
468
+ // The feed placed this schedule on the issuer's side; its own cover page has the last
469
+ // word on whose holders it reports (#189). Under `filer` every subject is kept.
470
+ if (!filer && !sameCik(parsed.issuer_cik, match.cik)) {
365
471
  otherIssuer++;
366
472
  continue;
367
473
  }
474
+ const subjectCik = parsed.issuer_cik.padStart(10, '0');
368
475
  const purpose = clip(parsed.purpose_of_transaction, PURPOSE_MAX_CHARS);
369
476
  const filing = {
370
477
  form: ref.form,
@@ -373,6 +480,10 @@ export const getBeneficialOwnersTool = tool('secedgar_get_beneficial_owners', {
373
480
  amendment_number: parsed.amendment_number,
374
481
  accession_number: ref.accessionNumber,
375
482
  filing_date: ref.filingDate,
483
+ ...(filer && {
484
+ issuer_cik: subjectCik,
485
+ ...(parsed.issuer_name && { issuer_name: parsed.issuer_name }),
486
+ }),
376
487
  event_date: parsed.event_date,
377
488
  security_class: parsed.security_class,
378
489
  cusips: parsed.issuer_cusips,
@@ -400,8 +511,8 @@ export const getBeneficialOwnersTool = tool('secedgar_get_beneficial_owners', {
400
511
  filings.push(filing);
401
512
  for (const o of parsed.owners) {
402
513
  rows.push({
403
- issuer_cik: match.cik,
404
- issuer_name: submissions.name,
514
+ issuer_cik: filer ? subjectCik : match.cik,
515
+ issuer_name: filer ? (parsed.issuer_name ?? null) : submissions.name,
405
516
  form: filing.form,
406
517
  schedule: filing.schedule,
407
518
  is_amendment: filing.is_amendment,
@@ -427,7 +538,23 @@ export const getBeneficialOwnersTool = tool('secedgar_get_beneficial_owners', {
427
538
  }
428
539
  }
429
540
  const notExamined = totalMatching - examined;
430
- const truncated = notExamined > 0;
541
+ // The page cap ended the walk while it could still reach schedules within the 50-document
542
+ // scan past `offset`, so unread pages in the window may hold more. Once a block read reaches
543
+ // before the floor, no unread page holds a schedule in the window.
544
+ const capped = Boolean(walk?.truncated && roleRows.length <= offset + FILING_SCAN_CAP && !(oldestRead < walkFloor));
545
+ const truncated = notExamined > 0 || capped;
546
+ // The call continuing this one: from the date of the last schedule examined while schedules
547
+ // remain past it in the blocks read — or, when a capped walk left none unexamined, where the
548
+ // blocks read end, so the next call's walk starts past the pages this one read — skipping
549
+ // that date's schedules this call and earlier ones examined or skipped. Same-day schedules on
550
+ // unread pages follow them in the order, so no schedule is skipped or read twice (#279).
551
+ let continuation;
552
+ if (truncated) {
553
+ const anchor = (notExamined > 0 ? pending[examined - 1]?.filingDate : undefined) ??
554
+ (filedBefore && filedBefore < oldestRead ? filedBefore : oldestRead);
555
+ const skip = offset + examined - roleRows.filter((r) => r.filingDate > anchor).length;
556
+ continuation = `To continue, repeat the call with filed_before=${anchor} and offset=${skip}, its other arguments unchanged.`;
557
+ }
431
558
  let dataset;
432
559
  const bridge = getCanvasBridge();
433
560
  if (bridge && rows.length > 0) {
@@ -437,24 +564,55 @@ export const getBeneficialOwnersTool = tool('secedgar_get_beneficial_owners', {
437
564
  queryParams: {
438
565
  issuer: input.issuer,
439
566
  issuer_cik: match.cik,
567
+ role: input.role,
440
568
  form_kind: input.form_kind,
441
569
  include_amendments: input.include_amendments,
442
570
  limit,
571
+ ...(filedAfter && { filed_after: filedAfter }),
572
+ ...(filedBefore && { filed_before: filedBefore }),
573
+ ...(offset > 0 && { offset }),
443
574
  },
444
575
  truncated,
445
576
  });
446
577
  if (registered)
447
578
  dataset = { ...toDatasetField(registered), truncated };
448
579
  }
580
+ const scopeText = dated
581
+ ? `dated ${describeWindow(filedAfter, filedBefore)}`
582
+ : 'in its recent submissions';
449
583
  const guidance = [];
584
+ if (roleRows.length === 0) {
585
+ // A capped walk claims none only as far as it read; its cap sentence follows.
586
+ guidance.push(`No structured ${kindLabel} filing ${scopeText} ${filer ? 'was filed by this company' : 'names this company as the subject'}${capped ? ' as far back as the scan reached' : ''}.`);
587
+ if (filedBefore && filedBefore < STRUCTURED_FROM) {
588
+ guidance.push(`Structured coverage starts ${STRUCTURED_FROM}, so a window ending before it holds none; secedgar_search_filings with forms ["SC 13D","SC 13G"] reaches the legacy text filings.`);
589
+ }
590
+ }
591
+ if (otherSide > 0)
592
+ guidance.push(otherSideSentence(input.role, otherSide, scopeText));
593
+ if (roleRows.length > 0 && pending.length === 0 && !capped) {
594
+ const count = roleRows.length;
595
+ guidance.push(`Offset ${offset} is at or past the ${count} matching ${count === 1 ? 'schedule' : 'schedules'} ${scopeText}; lower it to read ${count === 1 ? 'it' : 'them'}.`);
596
+ }
450
597
  if (otherIssuer > 0)
451
598
  guidance.push(`${otherIssuer} examined filings name another issuer and contribute no ownership rows.`);
452
599
  if (failed.length > 0)
453
600
  guidance.push(`${failed.length} documents failed; this is a partial result. Inspect the accessions in filings_failed with secedgar_get_filing; document_not_found means SEC returned 404, and unparseable means no schedule with a usable issuer CIK could be read.`);
454
- if (truncated) {
601
+ if (notExamined > 0) {
602
+ // A filer's own schedules: a limit that reads every one, when one call can, leads, since
603
+ // full-text search does not index them all (Elliott's lists 16 of its 19). A capped walk
604
+ // may have more on unread pages, so no limit reads them all.
605
+ const levers = filer && !capped && totalMatching <= FILING_RESULT_CAP
606
+ ? `Pass limit: ${totalMatching} to read all ${totalMatching} in one call.`
607
+ : limit < FILING_RESULT_CAP
608
+ ? 'Raise limit to reach further back, or narrow with form_kind or include_amendments=false.'
609
+ : 'Narrow with form_kind or include_amendments=false.';
455
610
  guidance.push(examined === FILING_SCAN_CAP
456
611
  ? `${notExamined} indexed schedules remain unexamined after the 50-document scan ceiling. Narrow with form_kind or include_amendments=false; raising limit does not extend this ceiling.`
457
- : `${notExamined} indexed schedules remain unexamined after the ${limit}-filing result limit. ${limit < FILING_RESULT_CAP ? 'Raise limit to reach further back, or narrow with form_kind or include_amendments=false.' : 'Narrow with form_kind or include_amendments=false.'}`);
612
+ : `${notExamined} indexed schedules remain unexamined after the ${limit}-filing result limit. ${levers}`);
613
+ }
614
+ if (truncated && filer) {
615
+ guidance.push(`secedgar_search_filings with query "cik:${match.cik}" and forms ${SCHEDULE_FORMS} lists the ones full-text search has indexed, along with those filed about this company.`);
458
616
  }
459
617
  if (dataset)
460
618
  guidance.push(dataframeGuidance(dataset));
@@ -479,10 +637,19 @@ export const getBeneficialOwnersTool = tool('secedgar_get_beneficial_owners', {
479
637
  : filingPointer;
480
638
  guidance.push(`Filer text cut to its bound: ${cuts.join(' and ')}. The whole text is in ${whole}.`);
481
639
  }
640
+ if (capped && walk) {
641
+ guidance.push(`The archive scan stopped after ${walk.pagesRead} pages, at filings from ${walk.scannedThrough}; older schedules in the window were not read.`);
642
+ }
643
+ if (continuation)
644
+ guidance.push(continuation);
482
645
  if (truncated) {
483
646
  ctx.enrich.truncated({
484
647
  shown: filings.length,
485
- cap: examined === FILING_SCAN_CAP ? FILING_SCAN_CAP : limit,
648
+ cap: examined === FILING_SCAN_CAP
649
+ ? FILING_SCAN_CAP
650
+ : notExamined > 0
651
+ ? limit
652
+ : ARCHIVE_PAGE_SCAN_CAP,
486
653
  guidance: guidance.join(' '),
487
654
  });
488
655
  }
@@ -491,8 +658,12 @@ export const getBeneficialOwnersTool = tool('secedgar_get_beneficial_owners', {
491
658
  }
492
659
  ctx.log.info('Beneficial owners retrieved', {
493
660
  cik: match.cik,
661
+ role: input.role,
494
662
  formKind: input.form_kind,
663
+ offset,
664
+ archivePagesRead: walk?.pagesRead ?? 0,
495
665
  totalMatching,
666
+ otherSide,
496
667
  parsed: filings.length,
497
668
  owners: rows.length,
498
669
  datasetName: dataset?.name,
@@ -501,6 +672,7 @@ export const getBeneficialOwnersTool = tool('secedgar_get_beneficial_owners', {
501
672
  issuer: input.issuer,
502
673
  issuer_cik: match.cik,
503
674
  issuer_name: submissions.name,
675
+ ...(filer && { role: 'filer' }),
504
676
  form_kind: input.form_kind,
505
677
  total_structured_filings: totalMatching,
506
678
  filings_parsed: filings.length,
@@ -520,7 +692,9 @@ export const getBeneficialOwnersTool = tool('secedgar_get_beneficial_owners', {
520
692
  // through escapeMarkdownInline, the free text as a blockquote, so content[] reads back
521
693
  // the structuredContent value as text (#200, #221).
522
694
  const lines = [
523
- `**5%+ beneficial owners of ${escapeMarkdownInline(result.issuer_name)}** (CIK ${result.issuer_cik}) — input "${escapeMarkdownInline(result.issuer)}"`,
695
+ result.role === 'filer'
696
+ ? `**5%+ stakes filed by ${escapeMarkdownInline(result.issuer_name)}** (CIK ${result.issuer_cik}) — input "${escapeMarkdownInline(result.issuer)}" (role: filer)`
697
+ : `**5%+ beneficial owners of ${escapeMarkdownInline(result.issuer_name)}** (CIK ${result.issuer_cik}) — input "${escapeMarkdownInline(result.issuer)}"`,
524
698
  `Schedule filter: ${result.form_kind} | ${result.filings_parsed} of ${result.total_structured_filings} structured filings parsed`,
525
699
  `${result.filings_examined} examined | ${result.filings_excluded_other_issuer} excluded for another issuer | ${result.filings_failed.length} failed | ${result.filings_not_examined} not examined | partial: ${result.partial}`,
526
700
  `Structured coverage starts ${result.structured_coverage_from}; ${result.legacy_filings_before_coverage} legacy SC 13D/SC 13G filings sit before it in the submissions window (read those with secedgar_get_filing).`,
@@ -535,6 +709,12 @@ export const getBeneficialOwnersTool = tool('secedgar_get_beneficial_owners', {
535
709
  : '';
536
710
  lines.push(`## ${f.form}${amendment} — filed ${f.filing_date} [${f.accession_number}]`);
537
711
  const bits = [`Schedule ${f.schedule}`];
712
+ const subject = [
713
+ f.issuer_name && escapeMarkdownInline(f.issuer_name),
714
+ f.issuer_cik && `(CIK ${f.issuer_cik})`,
715
+ ].filter(Boolean);
716
+ if (subject.length > 0)
717
+ bits.push(`subject ${subject.join(' ')}`);
538
718
  if (f.event_date)
539
719
  bits.push(`event ${f.event_date}`);
540
720
  if (f.security_class)
@@ -561,7 +741,7 @@ export const getBeneficialOwnersTool = tool('secedgar_get_beneficial_owners', {
561
741
  lines.push(` Excludes disclaimed shares: ${p.excludes_certain_shares ? 'yes' : 'no'}`);
562
742
  }
563
743
  if (p.notes) {
564
- lines.push(' Note:', ...quote(p.notes, ' '));
744
+ lines.push(' Note:', ...blockquote(p.notes, ' '));
565
745
  // The blank line ends the quote; without it the marker would continue its paragraph.
566
746
  if (p.notes_truncated) {
567
747
  lines.push('', ` (Note cut after its first ${charCount(NOTES_MAX_CHARS)} characters.)`);
@@ -571,7 +751,7 @@ export const getBeneficialOwnersTool = tool('secedgar_get_beneficial_owners', {
571
751
  // The blank line closes the person list, so nothing below continues its last quote.
572
752
  lines.push('');
573
753
  if (f.purpose_of_transaction) {
574
- lines.push('**Purpose of transaction:**', ...quote(f.purpose_of_transaction));
754
+ lines.push('**Purpose of transaction:**', ...blockquote(f.purpose_of_transaction));
575
755
  if (f.purpose_truncated) {
576
756
  lines.push('', `(Item 4 cut after its first ${charCount(PURPOSE_MAX_CHARS)} characters.)`);
577
757
  }