JC321 commited on
Commit
01b3cb7
·
verified ·
1 Parent(s): e8a9f1b

Upload mcp_server_fastmcp.py

Browse files
Files changed (1) hide show
  1. mcp_server_fastmcp.py +2 -36
mcp_server_fastmcp.py CHANGED
@@ -213,18 +213,7 @@ def extract_financial_metrics(cik: str, years: int = 3) -> dict:
213
  if years < 1 or years > 10:
214
  return {"error": "Years parameter must be between 1 and 10"}
215
 
216
- # Check if company has filings (use tuple for caching)
217
- filings_10k = edgar_client.get_company_filings(cik, ('10-K',))
218
- filings_20f = edgar_client.get_company_filings(cik, ('20-F',))
219
- total_filings = len(filings_10k) + len(filings_20f)
220
-
221
- if total_filings == 0:
222
- return {
223
- "error": f"No annual filings found for CIK: {cik}",
224
- "suggestion": "Please check if the CIK is correct"
225
- }
226
-
227
- # Extract metrics
228
  metrics = financial_analyzer.extract_financial_metrics(cik, years)
229
 
230
  if metrics:
@@ -234,30 +223,7 @@ def extract_financial_metrics(cik: str, years: int = 3) -> dict:
234
  "data": formatted
235
  }
236
  else:
237
- # Return debug info
238
- debug_info = {
239
- "error": f"No financial metrics extracted for CIK: {cik}",
240
- "debug": {
241
- "cik": cik,
242
- "years_requested": years,
243
- "filings_found": {
244
- "10-K": len(filings_10k),
245
- "20-F": len(filings_20f)
246
- },
247
- "latest_filings": []
248
- },
249
- "suggestion": "Try using get_latest_financial_data or get_financial_data with a specific period"
250
- }
251
-
252
- # Add latest filing dates
253
- all_filings = filings_10k + filings_20f
254
- for filing in all_filings[:5]:
255
- debug_info["debug"]["latest_filings"].append({
256
- "form": filing.get("form_type"),
257
- "date": filing.get("filing_date")
258
- })
259
-
260
- return debug_info
261
 
262
 
263
  @mcp.tool()
 
213
  if years < 1 or years > 10:
214
  return {"error": "Years parameter must be between 1 and 10"}
215
 
216
+ # Extract metrics (removed pre-check to allow extract_financial_metrics to handle all cases)
 
 
 
 
 
 
 
 
 
 
 
217
  metrics = financial_analyzer.extract_financial_metrics(cik, years)
218
 
219
  if metrics:
 
223
  "data": formatted
224
  }
225
  else:
226
+ return {"error": f"No financial metrics extracted for CIK: {cik}"}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
227
 
228
 
229
  @mcp.tool()