Spaces:
Runtime error
Runtime error
Upload mcp_server.py
Browse files- mcp_server.py +116 -12
mcp_server.py
CHANGED
|
@@ -143,23 +143,127 @@ class MetricsListResponse(BaseModel):
|
|
| 143 |
# API Endpoints
|
| 144 |
@app.get("/")
|
| 145 |
async def root():
|
| 146 |
-
"""Root endpoint with API information"""
|
| 147 |
return {
|
| 148 |
"service": "SEC Financial Report MCP Server",
|
| 149 |
"version": "1.0.0",
|
| 150 |
-
"description": "MCP Server for querying SEC EDGAR financial data",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 151 |
"endpoints": {
|
| 152 |
-
"
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 161 |
},
|
| 162 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 163 |
}
|
| 164 |
|
| 165 |
|
|
|
|
| 143 |
# API Endpoints
|
| 144 |
@app.get("/")
|
| 145 |
async def root():
|
| 146 |
+
"""Root endpoint with API information and usage guide"""
|
| 147 |
return {
|
| 148 |
"service": "SEC Financial Report MCP Server",
|
| 149 |
"version": "1.0.0",
|
| 150 |
+
"description": "MCP Server for querying SEC EDGAR financial data - A tool-ready API for AI agents and applications",
|
| 151 |
+
"status": "operational",
|
| 152 |
+
"user_agent": "Juntao Peng (jtyxabc@gmail.com)",
|
| 153 |
+
|
| 154 |
+
"quick_start": {
|
| 155 |
+
"interactive_docs": "/docs",
|
| 156 |
+
"api_documentation": "/redoc",
|
| 157 |
+
"health_check": "/health",
|
| 158 |
+
"example_usage": {
|
| 159 |
+
"step_1": "Search company: POST /api/advanced_search with {\"company_input\": \"NVIDIA\"}",
|
| 160 |
+
"step_2": "Get latest data: POST /api/get_latest_financial_data with {\"cik\": \"0001045810\"}",
|
| 161 |
+
"step_3": "Get trends: POST /api/extract_financial_metrics with {\"cik\": \"0001045810\", \"years\": 3}"
|
| 162 |
+
}
|
| 163 |
+
},
|
| 164 |
+
|
| 165 |
"endpoints": {
|
| 166 |
+
"basic_tools": {
|
| 167 |
+
"search_company": {
|
| 168 |
+
"path": "/api/search_company",
|
| 169 |
+
"method": "POST",
|
| 170 |
+
"description": "Search company by name only",
|
| 171 |
+
"input": {"company_name": "string"}
|
| 172 |
+
},
|
| 173 |
+
"get_company_info": {
|
| 174 |
+
"path": "/api/get_company_info",
|
| 175 |
+
"method": "POST",
|
| 176 |
+
"description": "Get company information by CIK",
|
| 177 |
+
"input": {"cik": "string"}
|
| 178 |
+
},
|
| 179 |
+
"get_company_filings": {
|
| 180 |
+
"path": "/api/get_company_filings",
|
| 181 |
+
"method": "POST",
|
| 182 |
+
"description": "Get company SEC filings (10-K, 10-Q, 20-F)",
|
| 183 |
+
"input": {"cik": "string", "form_types": "array or null"}
|
| 184 |
+
},
|
| 185 |
+
"get_company_facts": {
|
| 186 |
+
"path": "/api/get_company_facts",
|
| 187 |
+
"method": "POST",
|
| 188 |
+
"description": "Get complete XBRL financial facts",
|
| 189 |
+
"input": {"cik": "string"}
|
| 190 |
+
},
|
| 191 |
+
"get_financial_data": {
|
| 192 |
+
"path": "/api/get_financial_data",
|
| 193 |
+
"method": "POST",
|
| 194 |
+
"description": "Get financial data for specific period",
|
| 195 |
+
"input": {"cik": "string", "period": "YYYY or YYYYQX"}
|
| 196 |
+
},
|
| 197 |
+
"health": {
|
| 198 |
+
"path": "/health",
|
| 199 |
+
"method": "GET",
|
| 200 |
+
"description": "Server health check"
|
| 201 |
+
}
|
| 202 |
+
},
|
| 203 |
+
|
| 204 |
+
"advanced_tools": {
|
| 205 |
+
"advanced_search": {
|
| 206 |
+
"path": "/api/advanced_search",
|
| 207 |
+
"method": "POST",
|
| 208 |
+
"description": "Smart search - accepts company name OR CIK",
|
| 209 |
+
"input": {"company_input": "string"},
|
| 210 |
+
"recommended": true
|
| 211 |
+
},
|
| 212 |
+
"extract_financial_metrics": {
|
| 213 |
+
"path": "/api/extract_financial_metrics",
|
| 214 |
+
"method": "POST",
|
| 215 |
+
"description": "Extract multi-year metrics (annual + quarterly)",
|
| 216 |
+
"input": {"cik": "string", "years": "integer (1-10)"},
|
| 217 |
+
"recommended": true
|
| 218 |
+
},
|
| 219 |
+
"get_latest_financial_data": {
|
| 220 |
+
"path": "/api/get_latest_financial_data",
|
| 221 |
+
"method": "POST",
|
| 222 |
+
"description": "Get most recent annual financial data automatically",
|
| 223 |
+
"input": {"cik": "string"},
|
| 224 |
+
"recommended": true
|
| 225 |
+
}
|
| 226 |
+
}
|
| 227 |
},
|
| 228 |
+
|
| 229 |
+
"usage_guide": {
|
| 230 |
+
"for_ai_agents": "Use advanced_search → get_latest_financial_data for quick queries. Use extract_financial_metrics for trend analysis.",
|
| 231 |
+
"for_developers": "Visit /docs for interactive API testing with Swagger UI",
|
| 232 |
+
"data_source": "US SEC EDGAR system (real-time)",
|
| 233 |
+
"supported_forms": ["10-K (annual)", "10-Q (quarterly)", "20-F (foreign annual)"],
|
| 234 |
+
"rate_limit": "Follow SEC guidelines: 10 requests/second"
|
| 235 |
+
},
|
| 236 |
+
|
| 237 |
+
"example_workflows": [
|
| 238 |
+
{
|
| 239 |
+
"name": "Get Latest Company Financials",
|
| 240 |
+
"steps": [
|
| 241 |
+
"POST /api/advanced_search {\"company_input\": \"Apple\"}",
|
| 242 |
+
"POST /api/get_latest_financial_data {\"cik\": \"<from_step_1>\"}"
|
| 243 |
+
]
|
| 244 |
+
},
|
| 245 |
+
{
|
| 246 |
+
"name": "Analyze 5-Year Trends",
|
| 247 |
+
"steps": [
|
| 248 |
+
"POST /api/advanced_search {\"company_input\": \"TSMC\"}",
|
| 249 |
+
"POST /api/extract_financial_metrics {\"cik\": \"<from_step_1>\", \"years\": 5}"
|
| 250 |
+
]
|
| 251 |
+
},
|
| 252 |
+
{
|
| 253 |
+
"name": "Get Specific Quarter Data",
|
| 254 |
+
"steps": [
|
| 255 |
+
"POST /api/advanced_search {\"company_input\": \"NVIDIA\"}",
|
| 256 |
+
"POST /api/get_financial_data {\"cik\": \"<from_step_1>\", \"period\": \"2024Q3\"}"
|
| 257 |
+
]
|
| 258 |
+
}
|
| 259 |
+
],
|
| 260 |
+
|
| 261 |
+
"links": {
|
| 262 |
+
"interactive_docs": "/docs",
|
| 263 |
+
"redoc": "/redoc",
|
| 264 |
+
"github": "https://github.com/JC321/EasyReportDateMCP",
|
| 265 |
+
"huggingface_space": "https://huggingface.co/spaces/JC321/EasyReportDateMCP"
|
| 266 |
+
}
|
| 267 |
}
|
| 268 |
|
| 269 |
|