Spaces:
Runtime error
Runtime error
Upload 2 files
Browse files- app.py +188 -370
- requirements.txt +0 -1
app.py
CHANGED
|
@@ -1,409 +1,227 @@
|
|
| 1 |
"""
|
| 2 |
-
|
| 3 |
-
|
| 4 |
"""
|
| 5 |
-
|
|
|
|
| 6 |
import subprocess
|
| 7 |
-
import
|
|
|
|
| 8 |
|
| 9 |
-
|
| 10 |
-
mcp_process = None
|
| 11 |
|
|
|
|
| 12 |
def start_mcp_server():
|
| 13 |
-
""
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
#
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
"mcpServers": {
|
| 60 |
"sec-financial-data": {
|
| 61 |
"url": "https://jc321-easyreportsmcpserver.hf.space/sse",
|
| 62 |
"transport": "sse"
|
| 63 |
}
|
| 64 |
}
|
| 65 |
-
}
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
```bash
|
| 78 |
-
curl -X POST https://jc321-easyreportsmcpserver.hf.space/sse \\
|
| 79 |
-H "Content-Type: application/json" \\
|
| 80 |
-d '{
|
| 81 |
"jsonrpc": "2.0",
|
| 82 |
"method": "tools/list",
|
| 83 |
"id": 1
|
| 84 |
-
}'
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
```bash
|
| 90 |
-
curl -X POST https://jc321-easyreportsmcpserver.hf.space/sse \\
|
| 91 |
-H "Content-Type: application/json" \\
|
| 92 |
-d '{
|
| 93 |
"jsonrpc": "2.0",
|
| 94 |
"method": "tools/call",
|
| 95 |
"params": {
|
| 96 |
"name": "search_company",
|
| 97 |
-
"arguments": {
|
| 98 |
-
"company_name": "Tesla"
|
| 99 |
-
}
|
| 100 |
},
|
| 101 |
"id": 2
|
| 102 |
-
}'
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
```bash
|
| 108 |
-
curl -X POST https://jc321-easyreportsmcpserver.hf.space/sse \\
|
| 109 |
-H "Content-Type: application/json" \\
|
| 110 |
-d '{
|
| 111 |
"jsonrpc": "2.0",
|
| 112 |
"method": "tools/call",
|
| 113 |
"params": {
|
| 114 |
"name": "extract_financial_metrics",
|
| 115 |
-
"arguments": {
|
| 116 |
-
"cik": "0001318605",
|
| 117 |
-
"years": 3
|
| 118 |
-
}
|
| 119 |
},
|
| 120 |
"id": 3
|
| 121 |
-
}'
|
| 122 |
-
```
|
| 123 |
-
|
| 124 |
-
---
|
| 125 |
-
|
| 126 |
-
## 🔑 Key Features
|
| 127 |
-
|
| 128 |
-
- ✅ **Pure JSON responses** - No emoji or formatting, easy to parse
|
| 129 |
-
- ✅ **Chronological ordering** - Data sorted newest first (FY → Q4 → Q3 → Q2 → Q1)
|
| 130 |
-
- ✅ **Comprehensive metrics** - Revenue, Net Income, EPS, Operating Expenses, Cash Flow
|
| 131 |
-
- ✅ **Real-time data** - Direct access to SEC EDGAR database
|
| 132 |
-
- ✅ **7 powerful tools** - Search, analyze, and extract financial data
|
| 133 |
-
|
| 134 |
-
---
|
| 135 |
-
|
| 136 |
-
## 📚 Tool Reference
|
| 137 |
-
|
| 138 |
-
### 1. search_company
|
| 139 |
-
Search for a company by name.
|
| 140 |
-
|
| 141 |
-
**Parameters:**
|
| 142 |
-
- `company_name` (string): Company name (e.g., "Microsoft", "Apple")
|
| 143 |
-
|
| 144 |
-
**Returns:** Company CIK, name, tickers, SIC code
|
| 145 |
-
|
| 146 |
-
### 2. get_company_info
|
| 147 |
-
Get detailed company information.
|
| 148 |
-
|
| 149 |
-
**Parameters:**
|
| 150 |
-
- `cik` (string): Company CIK code (10-digit format)
|
| 151 |
-
|
| 152 |
-
**Returns:** Full company details
|
| 153 |
-
|
| 154 |
-
### 3. get_company_filings
|
| 155 |
-
Get list of SEC filings.
|
| 156 |
-
|
| 157 |
-
**Parameters:**
|
| 158 |
-
- `cik` (string): Company CIK code
|
| 159 |
-
- `form_types` (array, optional): Filter by form types (e.g., ["10-K", "10-Q"])
|
| 160 |
-
|
| 161 |
-
**Returns:** List of filings with dates and links (max 20)
|
| 162 |
-
|
| 163 |
-
### 4. get_financial_data
|
| 164 |
-
Get financial data for a specific period.
|
| 165 |
-
|
| 166 |
-
**Parameters:**
|
| 167 |
-
- `cik` (string): Company CIK code
|
| 168 |
-
- `period` (string): Period in format "YYYY" or "YYYYQX" (e.g., "2024", "2024Q3")
|
| 169 |
-
|
| 170 |
-
**Returns:** Financial data for the period
|
| 171 |
-
|
| 172 |
-
### 5. extract_financial_metrics
|
| 173 |
-
Extract comprehensive financial metrics for multiple years.
|
| 174 |
-
|
| 175 |
-
**Parameters:**
|
| 176 |
-
- `cik` (string): Company CIK code
|
| 177 |
-
- `years` (integer): Number of recent years (1-10, default: 3)
|
| 178 |
-
|
| 179 |
-
**Returns:** Multi-year financial data with both annual and quarterly metrics
|
| 180 |
-
|
| 181 |
-
### 6. get_latest_financial_data
|
| 182 |
-
Get the most recent financial data available.
|
| 183 |
-
|
| 184 |
-
**Parameters:**
|
| 185 |
-
- `cik` (string): Company CIK code
|
| 186 |
-
|
| 187 |
-
**Returns:** Latest available financial data
|
| 188 |
-
|
| 189 |
-
### 7. advanced_search_company
|
| 190 |
-
Advanced search supporting both company name and CIK code.
|
| 191 |
-
|
| 192 |
-
**Parameters:**
|
| 193 |
-
- `company_input` (string): Company name, ticker, or CIK code
|
| 194 |
-
|
| 195 |
-
**Returns:** Company information
|
| 196 |
-
|
| 197 |
-
---
|
| 198 |
-
|
| 199 |
-
## 🌐 Data Source
|
| 200 |
-
|
| 201 |
-
All data is sourced from the **SEC EDGAR database** - the official financial disclosure system of the U.S. Securities and Exchange Commission.
|
| 202 |
-
|
| 203 |
-
## 📞 Support
|
| 204 |
-
|
| 205 |
-
For issues or questions, visit: [GitHub Repository](https://github.com/yourusername/EasyReportDateMCP)
|
| 206 |
-
|
| 207 |
-
---
|
| 208 |
-
|
| 209 |
-
**Status:** 🟢 Server Running | **Protocol:** MCP 2024-11-05 | **Transport:** SSE
|
| 210 |
-
"""
|
| 211 |
-
|
| 212 |
-
EXAMPLE_CODE = """
|
| 213 |
-
# Python Example using MCP SDK
|
| 214 |
-
|
| 215 |
-
```python
|
| 216 |
-
from mcp import ClientSession, StdioServerParameters
|
| 217 |
-
from mcp.client.stdio import stdio_client
|
| 218 |
-
|
| 219 |
-
# Connect to MCP server
|
| 220 |
-
server_params = StdioServerParameters(
|
| 221 |
-
command="curl",
|
| 222 |
-
args=[
|
| 223 |
-
"-X", "POST",
|
| 224 |
-
"https://jc321-easyreportsmcpserver.hf.space/sse",
|
| 225 |
-
"-H", "Content-Type: application/json",
|
| 226 |
-
"-d", "@-"
|
| 227 |
-
]
|
| 228 |
-
)
|
| 229 |
-
|
| 230 |
-
async with stdio_client(server_params) as (read, write):
|
| 231 |
-
async with ClientSession(read, write) as session:
|
| 232 |
-
# List available tools
|
| 233 |
-
tools = await session.list_tools()
|
| 234 |
-
print(f"Available tools: {tools}")
|
| 235 |
|
| 236 |
-
|
| 237 |
-
|
| 238 |
-
|
| 239 |
-
|
| 240 |
-
|
| 241 |
-
|
| 242 |
|
| 243 |
-
|
| 244 |
-
|
| 245 |
-
|
| 246 |
-
|
| 247 |
-
|
| 248 |
-
|
| 249 |
-
|
| 250 |
-
|
| 251 |
-
|
| 252 |
-
|
| 253 |
-
|
| 254 |
-
// Using SSE client
|
| 255 |
-
const evtSource = new EventSource(
|
| 256 |
-
'https://jc321-easyreportsmcpserver.hf.space/sse'
|
| 257 |
-
);
|
| 258 |
-
|
| 259 |
-
// Send request
|
| 260 |
-
fetch('https://jc321-easyreportsmcpserver.hf.space/sse', {
|
| 261 |
-
method: 'POST',
|
| 262 |
-
headers: { 'Content-Type': 'application/json' },
|
| 263 |
-
body: JSON.stringify({
|
| 264 |
-
jsonrpc: '2.0',
|
| 265 |
-
method: 'tools/call',
|
| 266 |
-
params: {
|
| 267 |
-
name: 'search_company',
|
| 268 |
-
arguments: { company_name: 'Apple' }
|
| 269 |
-
},
|
| 270 |
-
id: 1
|
| 271 |
-
})
|
| 272 |
-
})
|
| 273 |
-
.then(response => response.json())
|
| 274 |
-
.then(data => console.log(data));
|
| 275 |
-
```
|
| 276 |
-
"""
|
| 277 |
-
|
| 278 |
-
# Create Gradio interface
|
| 279 |
-
with gr.Blocks(title="SEC Financial Data MCP Server", theme=gr.themes.Soft()) as demo:
|
| 280 |
-
gr.Markdown("# 📊 SEC Financial Data MCP Server")
|
| 281 |
-
gr.Markdown("### Access real-time SEC EDGAR financial data via Model Context Protocol")
|
| 282 |
-
|
| 283 |
-
with gr.Tabs():
|
| 284 |
-
with gr.Tab("📖 Usage Guide"):
|
| 285 |
-
gr.Markdown(USAGE_GUIDE)
|
| 286 |
-
|
| 287 |
-
with gr.Tab("💻 Code Examples"):
|
| 288 |
-
gr.Markdown(EXAMPLE_CODE)
|
| 289 |
|
| 290 |
-
|
| 291 |
-
|
| 292 |
-
|
| 293 |
-
|
| 294 |
-
|
| 295 |
-
|
| 296 |
-
|
| 297 |
-
|
| 298 |
-
|
| 299 |
-
)
|
| 300 |
-
company_name = gr.Textbox(
|
| 301 |
-
label="Company Name (for search_company)",
|
| 302 |
-
value="Tesla",
|
| 303 |
-
visible=True
|
| 304 |
-
)
|
| 305 |
-
cik_input = gr.Textbox(
|
| 306 |
-
label="CIK (for extract_financial_metrics)",
|
| 307 |
-
value="0001318605",
|
| 308 |
-
visible=False
|
| 309 |
-
)
|
| 310 |
-
years_input = gr.Number(
|
| 311 |
-
label="Years (for extract_financial_metrics)",
|
| 312 |
-
value=3,
|
| 313 |
-
visible=False
|
| 314 |
-
)
|
| 315 |
-
test_btn = gr.Button("🚀 Test", variant="primary")
|
| 316 |
-
|
| 317 |
-
with gr.Column():
|
| 318 |
-
result_output = gr.JSON(label="Response")
|
| 319 |
-
|
| 320 |
-
def update_inputs(method):
|
| 321 |
-
if method == "tools/list":
|
| 322 |
-
return gr.update(visible=False), gr.update(visible=False), gr.update(visible=False)
|
| 323 |
-
elif method == "search_company":
|
| 324 |
-
return gr.update(visible=True), gr.update(visible=False), gr.update(visible=False)
|
| 325 |
-
else: # extract_financial_metrics
|
| 326 |
-
return gr.update(visible=False), gr.update(visible=True), gr.update(visible=True)
|
| 327 |
-
|
| 328 |
-
test_method.change(
|
| 329 |
-
update_inputs,
|
| 330 |
-
inputs=[test_method],
|
| 331 |
-
outputs=[company_name, cik_input, years_input]
|
| 332 |
-
)
|
| 333 |
-
|
| 334 |
-
def test_mcp_call(method, company, cik, years):
|
| 335 |
-
import requests
|
| 336 |
-
import json
|
| 337 |
-
|
| 338 |
-
url = "https://jc321-easyreportsmcpserver.hf.space/sse"
|
| 339 |
-
|
| 340 |
-
if method == "tools/list":
|
| 341 |
-
payload = {
|
| 342 |
-
"jsonrpc": "2.0",
|
| 343 |
-
"method": "tools/list",
|
| 344 |
-
"id": 1
|
| 345 |
-
}
|
| 346 |
-
elif method == "search_company":
|
| 347 |
-
payload = {
|
| 348 |
-
"jsonrpc": "2.0",
|
| 349 |
-
"method": "tools/call",
|
| 350 |
-
"params": {
|
| 351 |
-
"name": "search_company",
|
| 352 |
-
"arguments": {"company_name": company}
|
| 353 |
-
},
|
| 354 |
-
"id": 2
|
| 355 |
-
}
|
| 356 |
-
else: # extract_financial_metrics
|
| 357 |
-
payload = {
|
| 358 |
-
"jsonrpc": "2.0",
|
| 359 |
-
"method": "tools/call",
|
| 360 |
-
"params": {
|
| 361 |
-
"name": "extract_financial_metrics",
|
| 362 |
-
"arguments": {"cik": cik, "years": int(years)}
|
| 363 |
-
},
|
| 364 |
-
"id": 3
|
| 365 |
-
}
|
| 366 |
-
|
| 367 |
-
try:
|
| 368 |
-
response = requests.post(url, json=payload, timeout=10)
|
| 369 |
-
return response.json()
|
| 370 |
-
except Exception as e:
|
| 371 |
-
return {"error": str(e)}
|
| 372 |
-
|
| 373 |
-
test_btn.click(
|
| 374 |
-
test_mcp_call,
|
| 375 |
-
inputs=[test_method, company_name, cik_input, years_input],
|
| 376 |
-
outputs=[result_output]
|
| 377 |
-
)
|
| 378 |
|
| 379 |
-
|
| 380 |
-
|
| 381 |
-
|
| 382 |
-
|
| 383 |
-
|
| 384 |
-
|
| 385 |
-
|
| 386 |
-
|
| 387 |
-
|
| 388 |
-
|
| 389 |
-
|
| 390 |
-
|
| 391 |
-
- **Deployment:** Hugging Face Spaces
|
| 392 |
-
|
| 393 |
-
### Features
|
| 394 |
-
- ✅ 7 financial data tools
|
| 395 |
-
- ✅ Real-time SEC EDGAR access
|
| 396 |
-
- ✅ Pure JSON responses
|
| 397 |
-
- ✅ Chronological data ordering
|
| 398 |
-
- ✅ Comprehensive financial metrics
|
| 399 |
-
|
| 400 |
-
### Maintained by
|
| 401 |
-
Juntao Peng (jtyxabc@gmail.com)
|
| 402 |
-
|
| 403 |
-
### License
|
| 404 |
-
MIT License
|
| 405 |
-
""")
|
| 406 |
|
| 407 |
-
# Launch the interface
|
| 408 |
if __name__ == "__main__":
|
| 409 |
-
|
|
|
|
| 1 |
"""
|
| 2 |
+
Simple FastAPI web interface for MCP Server usage guide
|
| 3 |
+
Runs alongside MCP server
|
| 4 |
"""
|
| 5 |
+
from fastapi import FastAPI
|
| 6 |
+
from fastapi.responses import HTMLResponse
|
| 7 |
import subprocess
|
| 8 |
+
import threading
|
| 9 |
+
import uvicorn
|
| 10 |
|
| 11 |
+
app = FastAPI(title="SEC Financial Data MCP Server")
|
|
|
|
| 12 |
|
| 13 |
+
# Start MCP server in background thread
|
| 14 |
def start_mcp_server():
|
| 15 |
+
subprocess.Popen(["python", "mcp_server_fastmcp.py"])
|
| 16 |
+
|
| 17 |
+
threading.Thread(target=start_mcp_server, daemon=True).start()
|
| 18 |
+
|
| 19 |
+
HTML_CONTENT = """
|
| 20 |
+
<!DOCTYPE html>
|
| 21 |
+
<html lang="en">
|
| 22 |
+
<head>
|
| 23 |
+
<meta charset="UTF-8">
|
| 24 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 25 |
+
<title>SEC Financial Data MCP Server</title>
|
| 26 |
+
<style>
|
| 27 |
+
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; max-width: 1200px; margin: 0 auto; padding: 20px; background: #f5f5f5; }
|
| 28 |
+
.container { background: white; border-radius: 8px; padding: 30px; box-shadow: 0 2px 4px rgba(0,0,0,0.1); }
|
| 29 |
+
h1 { color: #2563eb; border-bottom: 3px solid #2563eb; padding-bottom: 10px; }
|
| 30 |
+
h2 { color: #1e40af; margin-top: 30px; }
|
| 31 |
+
h3 { color: #1e3a8a; }
|
| 32 |
+
.endpoint { background: #e0e7ff; padding: 15px; border-radius: 5px; margin: 15px 0; font-family: monospace; }
|
| 33 |
+
.tool { background: #f0f9ff; border-left: 4px solid #2563eb; padding: 15px; margin: 10px 0; }
|
| 34 |
+
.tool-name { font-weight: bold; color: #1e40af; font-size: 18px; }
|
| 35 |
+
.code { background: #1e293b; color: #e2e8f0; padding: 15px; border-radius: 5px; overflow-x: auto; margin: 10px 0; }
|
| 36 |
+
.code pre { margin: 0; }
|
| 37 |
+
.badge { display: inline-block; padding: 4px 12px; border-radius: 12px; font-size: 12px; font-weight: bold; }
|
| 38 |
+
.badge-success { background: #dcfce7; color: #166534; }
|
| 39 |
+
.badge-info { background: #dbeafe; color: #1e40af; }
|
| 40 |
+
.feature { display: inline-block; margin: 5px; padding: 8px 15px; background: #e0e7ff; border-radius: 5px; }
|
| 41 |
+
table { width: 100%; border-collapse: collapse; margin: 15px 0; }
|
| 42 |
+
th, td { padding: 12px; text-align: left; border-bottom: 1px solid #e5e7eb; }
|
| 43 |
+
th { background: #f3f4f6; font-weight: 600; }
|
| 44 |
+
.status { position: fixed; top: 20px; right: 20px; background: #22c55e; color: white; padding: 10px 20px; border-radius: 20px; }
|
| 45 |
+
</style>
|
| 46 |
+
</head>
|
| 47 |
+
<body>
|
| 48 |
+
<div class="status">🟢 Server Running</div>
|
| 49 |
+
<div class="container">
|
| 50 |
+
<h1>📊 SEC Financial Data MCP Server</h1>
|
| 51 |
+
<p style="font-size: 18px; color: #64748b;">Access real-time SEC EDGAR financial data via Model Context Protocol</p>
|
| 52 |
+
|
| 53 |
+
<h2>🔗 MCP Endpoint</h2>
|
| 54 |
+
<div class="endpoint">
|
| 55 |
+
https://jc321-easyreportsmcpserver.hf.space/sse
|
| 56 |
+
</div>
|
| 57 |
+
<p><span class="badge badge-info">Protocol: MCP 2024-11-05</span> <span class="badge badge-info">Transport: SSE</span></p>
|
| 58 |
+
|
| 59 |
+
<h2>🛠️ Available Tools (7)</h2>
|
| 60 |
+
|
| 61 |
+
<div class="tool">
|
| 62 |
+
<div class="tool-name">1. search_company</div>
|
| 63 |
+
<p>Search for a company by name</p>
|
| 64 |
+
<strong>Parameters:</strong>
|
| 65 |
+
<ul>
|
| 66 |
+
<li><code>company_name</code> (string): Company name (e.g., "Tesla", "Apple")</li>
|
| 67 |
+
</ul>
|
| 68 |
+
<strong>Returns:</strong> Company CIK, name, tickers, SIC code
|
| 69 |
+
</div>
|
| 70 |
+
|
| 71 |
+
<div class="tool">
|
| 72 |
+
<div class="tool-name">2. get_company_info</div>
|
| 73 |
+
<p>Get detailed company information</p>
|
| 74 |
+
<strong>Parameters:</strong>
|
| 75 |
+
<ul>
|
| 76 |
+
<li><code>cik</code> (string): Company CIK code (10-digit format)</li>
|
| 77 |
+
</ul>
|
| 78 |
+
</div>
|
| 79 |
+
|
| 80 |
+
<div class="tool">
|
| 81 |
+
<div class="tool-name">3. get_company_filings</div>
|
| 82 |
+
<p>Get list of SEC filings (10-K, 10-Q, etc.)</p>
|
| 83 |
+
<strong>Parameters:</strong>
|
| 84 |
+
<ul>
|
| 85 |
+
<li><code>cik</code> (string): Company CIK code</li>
|
| 86 |
+
<li><code>form_types</code> (array, optional): Filter by form types</li>
|
| 87 |
+
</ul>
|
| 88 |
+
</div>
|
| 89 |
+
|
| 90 |
+
<div class="tool">
|
| 91 |
+
<div class="tool-name">4. get_financial_data</div>
|
| 92 |
+
<p>Get financial data for a specific period</p>
|
| 93 |
+
<strong>Parameters:</strong>
|
| 94 |
+
<ul>
|
| 95 |
+
<li><code>cik</code> (string): Company CIK code</li>
|
| 96 |
+
<li><code>period</code> (string): Period format "YYYY" or "YYYYQX"</li>
|
| 97 |
+
</ul>
|
| 98 |
+
</div>
|
| 99 |
+
|
| 100 |
+
<div class="tool">
|
| 101 |
+
<div class="tool-name">5. extract_financial_metrics ⭐</div>
|
| 102 |
+
<p>Extract comprehensive financial metrics for multiple years (annual + quarterly)</p>
|
| 103 |
+
<strong>Parameters:</strong>
|
| 104 |
+
<ul>
|
| 105 |
+
<li><code>cik</code> (string): Company CIK code</li>
|
| 106 |
+
<li><code>years</code> (integer): Number of years (1-10, default: 3)</li>
|
| 107 |
+
</ul>
|
| 108 |
+
<strong>Returns:</strong> Multi-year data sorted newest first (FY → Q4 → Q3 → Q2 → Q1)
|
| 109 |
+
</div>
|
| 110 |
+
|
| 111 |
+
<div class="tool">
|
| 112 |
+
<div class="tool-name">6. get_latest_financial_data</div>
|
| 113 |
+
<p>Get the most recent financial data available</p>
|
| 114 |
+
<strong>Parameters:</strong>
|
| 115 |
+
<ul>
|
| 116 |
+
<li><code>cik</code> (string): Company CIK code</li>
|
| 117 |
+
</ul>
|
| 118 |
+
</div>
|
| 119 |
+
|
| 120 |
+
<div class="tool">
|
| 121 |
+
<div class="tool-name">7. advanced_search_company</div>
|
| 122 |
+
<p>Advanced search supporting both company name and CIK code</p>
|
| 123 |
+
<strong>Parameters:</strong>
|
| 124 |
+
<ul>
|
| 125 |
+
<li><code>company_input</code> (string): Company name, ticker, or CIK</li>
|
| 126 |
+
</ul>
|
| 127 |
+
</div>
|
| 128 |
+
|
| 129 |
+
<h2>📝 How to Use</h2>
|
| 130 |
+
|
| 131 |
+
<h3>Option 1: Claude Desktop (Recommended)</h3>
|
| 132 |
+
<p>Add to your <code>claude_desktop_config.json</code>:</p>
|
| 133 |
+
<div class="code"><pre>{
|
| 134 |
"mcpServers": {
|
| 135 |
"sec-financial-data": {
|
| 136 |
"url": "https://jc321-easyreportsmcpserver.hf.space/sse",
|
| 137 |
"transport": "sse"
|
| 138 |
}
|
| 139 |
}
|
| 140 |
+
}</pre></div>
|
| 141 |
+
<p><strong>Then ask Claude:</strong></p>
|
| 142 |
+
<ul>
|
| 143 |
+
<li>"Search for Tesla's financial information"</li>
|
| 144 |
+
<li>"Get Apple's latest financial data"</li>
|
| 145 |
+
<li>"Show me Microsoft's revenue trends for the last 3 years"</li>
|
| 146 |
+
</ul>
|
| 147 |
+
|
| 148 |
+
<h3>Option 2: Direct API Call</h3>
|
| 149 |
+
<p><strong>List Available Tools:</strong></p>
|
| 150 |
+
<div class="code"><pre>curl -X POST https://jc321-easyreportsmcpserver.hf.space/sse \\
|
|
|
|
|
|
|
|
|
|
| 151 |
-H "Content-Type: application/json" \\
|
| 152 |
-d '{
|
| 153 |
"jsonrpc": "2.0",
|
| 154 |
"method": "tools/list",
|
| 155 |
"id": 1
|
| 156 |
+
}'</pre></div>
|
| 157 |
+
|
| 158 |
+
<p><strong>Search Company (Tesla):</strong></p>
|
| 159 |
+
<div class="code"><pre>curl -X POST https://jc321-easyreportsmcpserver.hf.space/sse \\
|
|
|
|
|
|
|
|
|
|
| 160 |
-H "Content-Type: application/json" \\
|
| 161 |
-d '{
|
| 162 |
"jsonrpc": "2.0",
|
| 163 |
"method": "tools/call",
|
| 164 |
"params": {
|
| 165 |
"name": "search_company",
|
| 166 |
+
"arguments": {"company_name": "Tesla"}
|
|
|
|
|
|
|
| 167 |
},
|
| 168 |
"id": 2
|
| 169 |
+
}'</pre></div>
|
| 170 |
+
|
| 171 |
+
<p><strong>Get 3-Year Financial Trends:</strong></p>
|
| 172 |
+
<div class="code"><pre>curl -X POST https://jc321-easyreportsmcpserver.hf.space/sse \\
|
|
|
|
|
|
|
|
|
|
| 173 |
-H "Content-Type: application/json" \\
|
| 174 |
-d '{
|
| 175 |
"jsonrpc": "2.0",
|
| 176 |
"method": "tools/call",
|
| 177 |
"params": {
|
| 178 |
"name": "extract_financial_metrics",
|
| 179 |
+
"arguments": {"cik": "0001318605", "years": 3}
|
|
|
|
|
|
|
|
|
|
| 180 |
},
|
| 181 |
"id": 3
|
| 182 |
+
}'</pre></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 183 |
|
| 184 |
+
<h2>🔑 Key Features</h2>
|
| 185 |
+
<div class="feature">✅ Pure JSON responses</div>
|
| 186 |
+
<div class="feature">✅ Chronological ordering</div>
|
| 187 |
+
<div class="feature">✅ Comprehensive metrics</div>
|
| 188 |
+
<div class="feature">✅ Real-time SEC EDGAR data</div>
|
| 189 |
+
<div class="feature">✅ 7 powerful tools</div>
|
| 190 |
|
| 191 |
+
<h2>📊 Response Example</h2>
|
| 192 |
+
<div class="code"><pre>{
|
| 193 |
+
"jsonrpc": "2.0",
|
| 194 |
+
"id": 2,
|
| 195 |
+
"result": {
|
| 196 |
+
"content": [{
|
| 197 |
+
"type": "text",
|
| 198 |
+
"text": "{\\"cik\\":\\"0001318605\\",\\"name\\":\\"TESLA, INC.\\",\\"tickers\\":[\\"TSLA\\"]}"
|
| 199 |
+
}]
|
| 200 |
+
}
|
| 201 |
+
}</pre></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 202 |
|
| 203 |
+
<h2>ℹ️ About</h2>
|
| 204 |
+
<table>
|
| 205 |
+
<tr><th>Version</th><td>1.0.0 (FastMCP)</td></tr>
|
| 206 |
+
<tr><th>Protocol</th><td>Model Context Protocol (MCP) 2024-11-05</td></tr>
|
| 207 |
+
<tr><th>Transport</th><td>Server-Sent Events (SSE)</td></tr>
|
| 208 |
+
<tr><th>Data Source</th><td>SEC EDGAR Database</td></tr>
|
| 209 |
+
<tr><th>Framework</th><td>Anthropic FastMCP SDK</td></tr>
|
| 210 |
+
<tr><th>Maintained by</th><td>Juntao Peng (jtyxabc@gmail.com)</td></tr>
|
| 211 |
+
</table>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 212 |
|
| 213 |
+
<p style="text-align: center; color: #64748b; margin-top: 40px;">
|
| 214 |
+
<strong>Status:</strong> <span class="badge badge-success">Online</span> |
|
| 215 |
+
<strong>Uptime:</strong> Always-On
|
| 216 |
+
</p>
|
| 217 |
+
</div>
|
| 218 |
+
</body>
|
| 219 |
+
</html>
|
| 220 |
+
"""
|
| 221 |
+
|
| 222 |
+
@app.get("/", response_class=HTMLResponse)
|
| 223 |
+
async def root():
|
| 224 |
+
return HTML_CONTENT
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 225 |
|
|
|
|
| 226 |
if __name__ == "__main__":
|
| 227 |
+
uvicorn.run(app, host="0.0.0.0", port=7860)
|
requirements.txt
CHANGED
|
@@ -4,4 +4,3 @@ uvicorn[standard]>=0.30
|
|
| 4 |
pydantic>=2.10.1
|
| 5 |
sec-edgar-api==1.1.0
|
| 6 |
requests==2.31.0
|
| 7 |
-
gradio>=5.0.0
|
|
|
|
| 4 |
pydantic>=2.10.1
|
| 5 |
sec-edgar-api==1.1.0
|
| 6 |
requests==2.31.0
|
|
|