@etsquare/mcp-server-sec 0.2.1 → 0.4.0

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.
@@ -2,7 +2,56 @@
2
2
  * ETSquare SEC Intelligence API client.
3
3
  * Wraps /api/v1/* endpoints with X-API-Key authentication.
4
4
  */
5
- import type { SearchInput, LookupCompanyInput, ExecuteMetricsInput, DiscoverMetricsInput, GetChunkInput, GetChunkContextInput } from './types.js';
5
+ import type { LookupCompanyInput, GetChunkInput, GetChunkContextInput } from './types.js';
6
+ /** Subset of SearchInput that the API v1 backend accepts (no MCP-layer fields). */
7
+ interface SearchApiInput {
8
+ query: string;
9
+ mode_lock: 'NARRATIVE' | 'HYBRID';
10
+ scope_lock: 'COMPANY' | 'INDUSTRY' | 'MACRO';
11
+ top_k?: number;
12
+ tickers?: string[];
13
+ sic_codes?: string[];
14
+ sector?: string;
15
+ doc_types?: string[];
16
+ }
17
+ /** Subset of ExecuteMetricsInput that the API v1 backend accepts. */
18
+ interface ExecuteMetricsApiInput {
19
+ template_id: string;
20
+ bind_params?: Record<string, unknown>;
21
+ row_limit?: number;
22
+ }
23
+ /** Financial statement request. */
24
+ interface FinancialStatementApiInput {
25
+ ticker: string;
26
+ statement_type: 'income_statement' | 'balance_sheet' | 'cash_flow';
27
+ period_mode?: 'latest_annual' | 'latest_quarterly' | 'last_n_annual' | 'last_n_quarterly';
28
+ n_periods?: number;
29
+ }
30
+ /** Institutional holdings request. */
31
+ interface InstitutionalHoldingsApiInput {
32
+ ticker: string;
33
+ quarters?: number;
34
+ }
35
+ /** Insider transactions request. */
36
+ interface InsiderTransactionsApiInput {
37
+ ticker: string;
38
+ days_back?: number;
39
+ transaction_types?: string[];
40
+ include_derivatives?: boolean;
41
+ }
42
+ /** Earnings actuals & guidance request. */
43
+ interface EarningsActualsApiInput {
44
+ ticker: string;
45
+ quarters?: number;
46
+ metrics?: string[];
47
+ }
48
+ /** Subset of DiscoverMetricsInput that the API v1 backend accepts. */
49
+ interface DiscoverMetricsApiInput {
50
+ question: string;
51
+ scenario?: 'snapshot' | 'trends' | 'peer_benchmark';
52
+ metric_family?: string;
53
+ max_results?: number;
54
+ }
6
55
  export interface ETSquareClientOptions {
7
56
  baseUrl: string;
8
57
  apiKey: string;
@@ -13,10 +62,17 @@ export declare class ETSquareClient {
13
62
  constructor(options: ETSquareClientOptions);
14
63
  private get headers();
15
64
  private handleResponse;
16
- search(input: SearchInput): Promise<Record<string, unknown>>;
65
+ private request;
66
+ search(input: SearchApiInput): Promise<Record<string, unknown>>;
17
67
  lookupCompany(input: LookupCompanyInput): Promise<Record<string, unknown>>;
18
- executeMetrics(input: ExecuteMetricsInput): Promise<Record<string, unknown>>;
19
- discoverMetrics(input: DiscoverMetricsInput): Promise<Record<string, unknown>>;
68
+ executeMetrics(input: ExecuteMetricsApiInput): Promise<Record<string, unknown>>;
69
+ getFinancialStatement(input: FinancialStatementApiInput): Promise<Record<string, unknown>>;
70
+ getInstitutionalHoldings(input: InstitutionalHoldingsApiInput): Promise<Record<string, unknown>>;
71
+ getInsiderTransactions(input: InsiderTransactionsApiInput): Promise<Record<string, unknown>>;
72
+ getEarningsActuals(input: EarningsActualsApiInput): Promise<Record<string, unknown>>;
73
+ discoverMetrics(input: DiscoverMetricsApiInput): Promise<Record<string, unknown>>;
20
74
  getChunk(input: GetChunkInput): Promise<Record<string, unknown>>;
21
75
  getChunkContext(input: GetChunkContextInput): Promise<Record<string, unknown>>;
76
+ weeklyBrief(): Promise<Record<string, unknown>>;
22
77
  }
78
+ export {};
@@ -29,6 +29,17 @@ export class ETSquareClient {
29
29
  }
30
30
  return (await res.json());
31
31
  }
32
+ async request(path, init) {
33
+ const url = `${this.baseUrl}${path}`;
34
+ try {
35
+ const res = await fetch(url, init);
36
+ return this.handleResponse(res);
37
+ }
38
+ catch (error) {
39
+ const message = error instanceof Error ? error.message : 'Unknown error';
40
+ throw new Error(`ETSquare API fetch failed (${url}): ${message}`);
41
+ }
42
+ }
32
43
  async search(input) {
33
44
  const body = {
34
45
  query: input.query,
@@ -42,23 +53,23 @@ export class ETSquareClient {
42
53
  body.tickers = input.tickers;
43
54
  if (input.sic_codes)
44
55
  body.sic_codes = input.sic_codes;
56
+ if (input.sector)
57
+ body.sector = input.sector;
45
58
  if (input.doc_types)
46
59
  body.doc_types = input.doc_types;
47
- const res = await fetch(`${this.baseUrl}/api/v1/search`, {
60
+ return this.request('/api/v1/search', {
48
61
  method: 'POST',
49
62
  headers: this.headers,
50
63
  body: JSON.stringify(body),
51
64
  });
52
- return this.handleResponse(res);
53
65
  }
54
66
  async lookupCompany(input) {
55
67
  const params = new URLSearchParams({ query: input.query });
56
68
  if (input.limit)
57
69
  params.set('limit', String(input.limit));
58
- const res = await fetch(`${this.baseUrl}/api/v1/companies/lookup?${params}`, {
70
+ return this.request(`/api/v1/companies/lookup?${params}`, {
59
71
  headers: this.headers,
60
72
  });
61
- return this.handleResponse(res);
62
73
  }
63
74
  async executeMetrics(input) {
64
75
  const body = {
@@ -67,12 +78,63 @@ export class ETSquareClient {
67
78
  };
68
79
  if (input.row_limit)
69
80
  body.row_limit = input.row_limit;
70
- const res = await fetch(`${this.baseUrl}/api/v1/metrics/execute`, {
81
+ return this.request('/api/v1/metrics/execute', {
82
+ method: 'POST',
83
+ headers: this.headers,
84
+ body: JSON.stringify(body),
85
+ });
86
+ }
87
+ async getFinancialStatement(input) {
88
+ const body = {
89
+ ticker: input.ticker,
90
+ statement_type: input.statement_type,
91
+ period_mode: input.period_mode || 'last_n_annual',
92
+ n_periods: input.n_periods || 5,
93
+ };
94
+ return this.request('/api/v1/financials', {
95
+ method: 'POST',
96
+ headers: this.headers,
97
+ body: JSON.stringify(body),
98
+ });
99
+ }
100
+ async getInstitutionalHoldings(input) {
101
+ const body = {
102
+ ticker: input.ticker,
103
+ quarters: input.quarters || 2,
104
+ };
105
+ return this.request('/api/v1/institutional/holdings', {
106
+ method: 'POST',
107
+ headers: this.headers,
108
+ body: JSON.stringify(body),
109
+ });
110
+ }
111
+ async getInsiderTransactions(input) {
112
+ const body = {
113
+ ticker: input.ticker,
114
+ days_back: input.days_back || 90,
115
+ };
116
+ if (input.transaction_types)
117
+ body.transaction_types = input.transaction_types;
118
+ if (input.include_derivatives !== undefined)
119
+ body.include_derivatives = input.include_derivatives;
120
+ return this.request('/api/v1/insider/transactions', {
121
+ method: 'POST',
122
+ headers: this.headers,
123
+ body: JSON.stringify(body),
124
+ });
125
+ }
126
+ async getEarningsActuals(input) {
127
+ const body = {
128
+ ticker: input.ticker,
129
+ quarters: input.quarters || 4,
130
+ };
131
+ if (input.metrics)
132
+ body.metrics = input.metrics;
133
+ return this.request('/api/v1/earnings/actuals', {
71
134
  method: 'POST',
72
135
  headers: this.headers,
73
136
  body: JSON.stringify(body),
74
137
  });
75
- return this.handleResponse(res);
76
138
  }
77
139
  async discoverMetrics(input) {
78
140
  const body = {
@@ -84,19 +146,17 @@ export class ETSquareClient {
84
146
  body.metric_family = input.metric_family;
85
147
  if (input.max_results)
86
148
  body.max_results = input.max_results;
87
- const res = await fetch(`${this.baseUrl}/api/v1/metrics/discover`, {
149
+ return this.request('/api/v1/metrics/discover', {
88
150
  method: 'POST',
89
151
  headers: this.headers,
90
152
  body: JSON.stringify(body),
91
153
  });
92
- return this.handleResponse(res);
93
154
  }
94
155
  async getChunk(input) {
95
156
  const params = new URLSearchParams({ execution_id: input.execution_id });
96
- const res = await fetch(`${this.baseUrl}/api/v1/chunk/${input.chunk_id}?${params}`, {
157
+ return this.request(`/api/v1/chunk/${input.chunk_id}?${params}`, {
97
158
  headers: this.headers,
98
159
  });
99
- return this.handleResponse(res);
100
160
  }
101
161
  async getChunkContext(input) {
102
162
  const params = new URLSearchParams();
@@ -106,9 +166,13 @@ export class ETSquareClient {
106
166
  params.set('window', String(input.window));
107
167
  const query = params.toString();
108
168
  const suffix = query ? `?${query}` : '';
109
- const res = await fetch(`${this.baseUrl}/api/v1/chunks/${input.chunk_id}/context${suffix}`, {
169
+ return this.request(`/api/v1/chunks/${input.chunk_id}/context${suffix}`, {
170
+ headers: this.headers,
171
+ });
172
+ }
173
+ async weeklyBrief() {
174
+ return this.request('/api/sec-intelligence/weekly-brief', {
110
175
  headers: this.headers,
111
176
  });
112
- return this.handleResponse(res);
113
177
  }
114
178
  }