JC321 commited on
Commit
05c5d55
·
verified ·
1 Parent(s): f40d269

Upload 2 files

Browse files
Files changed (2) hide show
  1. README.md +1 -1
  2. app.py +19 -9
README.md CHANGED
@@ -49,7 +49,7 @@ license: mit
49
  {
50
  "mcpServers": {
51
  "sec-financial-data": {
52
- "url": "https://jc321-easyreportsmcpserver.hf.space/sse",
53
  "transport": "sse"
54
  }
55
  }
 
49
  {
50
  "mcpServers": {
51
  "sec-financial-data": {
52
+ "url": "https://jc321-easyreportdatemcp.hf.space/sse",
53
  "transport": "sse"
54
  }
55
  }
app.py CHANGED
@@ -81,35 +81,45 @@ def advanced_search_company(company_input: str) -> dict:
81
  # Gradio wrapper functions
82
  def gradio_search_company(company_name: str):
83
  """Gradio wrapper for search_company"""
 
 
84
  try:
85
- result = search_company(company_name)
86
  return json.dumps(result, indent=2)
87
  except Exception as e:
88
- return json.dumps({"error": str(e)}, indent=2)
89
 
90
  def gradio_get_company_info(cik: str):
91
  """Gradio wrapper for get_company_info"""
 
 
92
  try:
93
- result = get_company_info(cik)
94
  return json.dumps(result, indent=2)
95
  except Exception as e:
96
- return json.dumps({"error": str(e)}, indent=2)
97
 
98
- def gradio_extract_metrics(cik: str, years: int):
99
  """Gradio wrapper for extract_financial_metrics"""
 
 
100
  try:
101
- result = extract_financial_metrics(cik, years)
 
 
102
  return json.dumps(result, indent=2)
103
  except Exception as e:
104
- return json.dumps({"error": str(e)}, indent=2)
105
 
106
  def gradio_get_latest(cik: str):
107
  """Gradio wrapper for get_latest_financial_data"""
 
 
108
  try:
109
- result = get_latest_financial_data(cik)
110
  return json.dumps(result, indent=2)
111
  except Exception as e:
112
- return json.dumps({"error": str(e)}, indent=2)
113
 
114
  # Create Gradio interface
115
  with gr.Blocks(title="SEC Financial Data MCP Server", theme=gr.themes.Soft()) as demo:
 
81
  # Gradio wrapper functions
82
  def gradio_search_company(company_name: str):
83
  """Gradio wrapper for search_company"""
84
+ if not company_name or not company_name.strip():
85
+ return json.dumps({"error": "Company name cannot be empty"}, indent=2)
86
  try:
87
+ result = search_company(company_name.strip())
88
  return json.dumps(result, indent=2)
89
  except Exception as e:
90
+ return json.dumps({"error": f"Exception: {str(e)}"}, indent=2)
91
 
92
  def gradio_get_company_info(cik: str):
93
  """Gradio wrapper for get_company_info"""
94
+ if not cik or not cik.strip():
95
+ return json.dumps({"error": "CIK cannot be empty"}, indent=2)
96
  try:
97
+ result = get_company_info(cik.strip())
98
  return json.dumps(result, indent=2)
99
  except Exception as e:
100
+ return json.dumps({"error": f"Exception: {str(e)}"}, indent=2)
101
 
102
+ def gradio_extract_metrics(cik: str, years: float):
103
  """Gradio wrapper for extract_financial_metrics"""
104
+ if not cik or not cik.strip():
105
+ return json.dumps({"error": "CIK cannot be empty"}, indent=2)
106
  try:
107
+ # Convert float slider value to int
108
+ years_int = int(years)
109
+ result = extract_financial_metrics(cik.strip(), years_int)
110
  return json.dumps(result, indent=2)
111
  except Exception as e:
112
+ return json.dumps({"error": f"Exception: {str(e)}"}, indent=2)
113
 
114
  def gradio_get_latest(cik: str):
115
  """Gradio wrapper for get_latest_financial_data"""
116
+ if not cik or not cik.strip():
117
+ return json.dumps({"error": "CIK cannot be empty"}, indent=2)
118
  try:
119
+ result = get_latest_financial_data(cik.strip())
120
  return json.dumps(result, indent=2)
121
  except Exception as e:
122
+ return json.dumps({"error": f"Exception: {str(e)}"}, indent=2)
123
 
124
  # Create Gradio interface
125
  with gr.Blocks(title="SEC Financial Data MCP Server", theme=gr.themes.Soft()) as demo: