Spaces:
Runtime error
Runtime error
Upload app.py
Browse files
app.py
CHANGED
|
@@ -151,11 +151,13 @@ def advanced_search_company(company_input: str) -> dict:
|
|
| 151 |
return result
|
| 152 |
|
| 153 |
|
| 154 |
-
# Mount MCP server
|
|
|
|
|
|
|
| 155 |
@app.post("/sse")
|
| 156 |
@app.get("/sse")
|
| 157 |
-
async def
|
| 158 |
-
"""MCP
|
| 159 |
try:
|
| 160 |
# For POST requests, get JSON body
|
| 161 |
if request.method == "POST":
|
|
@@ -237,7 +239,7 @@ async def mcp_sse_endpoint(request: Request):
|
|
| 237 |
return JSONResponse({
|
| 238 |
"service": "SEC Financial Data MCP Server",
|
| 239 |
"protocol": "MCP 2024-11-05",
|
| 240 |
-
"transport": "
|
| 241 |
"status": "online"
|
| 242 |
})
|
| 243 |
|
|
@@ -299,9 +301,9 @@ HTML_CONTENT = """
|
|
| 299 |
|
| 300 |
<h2>π MCP Endpoint</h2>
|
| 301 |
<div class="endpoint">
|
| 302 |
-
https://jc321-easyreportsmcpserver.hf.space/
|
| 303 |
</div>
|
| 304 |
-
<p><span class="badge badge-info">Protocol: MCP 2024-11-05</span> <span class="badge badge-info">Transport:
|
| 305 |
<p style="text-align: center; margin: 20px 0;">
|
| 306 |
<a href="/test" style="display: inline-block; padding: 12px 24px; background: #2563eb; color: white; text-decoration: none; border-radius: 6px; font-weight: bold;">π§ͺ Test MCP Server Live</a>
|
| 307 |
</p>
|
|
@@ -521,8 +523,8 @@ HTML_CONTENT = """
|
|
| 521 |
<div class="code"><pre>{
|
| 522 |
"mcpServers": {
|
| 523 |
"sec-financial-data": {
|
| 524 |
-
"url": "https://jc321-easyreportsmcpserver.hf.space/
|
| 525 |
-
"transport": "
|
| 526 |
}
|
| 527 |
}
|
| 528 |
}</pre></div>
|
|
@@ -535,7 +537,7 @@ HTML_CONTENT = """
|
|
| 535 |
|
| 536 |
<h3>Option 2: Direct API Call</h3>
|
| 537 |
<p><strong>List Available Tools:</strong></p>
|
| 538 |
-
<div class="code"><pre>curl -X POST https://jc321-easyreportsmcpserver.hf.space/
|
| 539 |
-H "Content-Type: application/json" \\
|
| 540 |
-d '{
|
| 541 |
"jsonrpc": "2.0",
|
|
@@ -544,7 +546,7 @@ HTML_CONTENT = """
|
|
| 544 |
}'</pre></div>
|
| 545 |
|
| 546 |
<p><strong>Search Company (Tesla):</strong></p>
|
| 547 |
-
<div class="code"><pre>curl -X POST https://jc321-easyreportsmcpserver.hf.space/
|
| 548 |
-H "Content-Type: application/json" \\
|
| 549 |
-d '{
|
| 550 |
"jsonrpc": "2.0",
|
|
@@ -557,7 +559,7 @@ HTML_CONTENT = """
|
|
| 557 |
}'</pre></div>
|
| 558 |
|
| 559 |
<p><strong>Get 3-Year Financial Trends:</strong></p>
|
| 560 |
-
<div class="code"><pre>curl -X POST https://jc321-easyreportsmcpserver.hf.space/
|
| 561 |
-H "Content-Type: application/json" \\
|
| 562 |
-d '{
|
| 563 |
"jsonrpc": "2.0",
|
|
@@ -592,7 +594,7 @@ HTML_CONTENT = """
|
|
| 592 |
<table>
|
| 593 |
<tr><th>Version</th><td>1.0.0 (FastMCP)</td></tr>
|
| 594 |
<tr><th>Protocol</th><td>Model Context Protocol (MCP) 2024-11-05</td></tr>
|
| 595 |
-
<tr><th>Transport</th><td>
|
| 596 |
<tr><th>Data Source</th><td>SEC EDGAR Database</td></tr>
|
| 597 |
<tr><th>Framework</th><td>Anthropic FastMCP SDK</td></tr>
|
| 598 |
<tr><th>Maintained by</th><td>Juntao Peng (jtyxabc@gmail.com)</td></tr>
|
|
@@ -630,7 +632,7 @@ HTML_CONTENT = """
|
|
| 630 |
button.disabled = true;
|
| 631 |
|
| 632 |
try {
|
| 633 |
-
const response = await fetch('/
|
| 634 |
method: 'POST',
|
| 635 |
headers: { 'Content-Type': 'application/json' },
|
| 636 |
body: JSON.stringify({
|
|
@@ -726,7 +728,7 @@ async def test_page():
|
|
| 726 |
</head>
|
| 727 |
<body>
|
| 728 |
<h1>π§ͺ MCP Server Live Test</h1>
|
| 729 |
-
<p>Test the MCP server at: <code>https://jc321-easyreportsmcpserver.hf.space/
|
| 730 |
|
| 731 |
<div>
|
| 732 |
<button onclick="testToolsList()">π Test: List Tools</button>
|
|
@@ -738,7 +740,7 @@ async def test_page():
|
|
| 738 |
<div id="result"></div>
|
| 739 |
|
| 740 |
<script>
|
| 741 |
-
const endpoint = '/
|
| 742 |
|
| 743 |
function showStatus(msg, isError) {
|
| 744 |
document.getElementById('status').innerHTML =
|
|
|
|
| 151 |
return result
|
| 152 |
|
| 153 |
|
| 154 |
+
# Mount MCP server HTTP endpoint (support both /mcp and /sse for backward compatibility)
|
| 155 |
+
@app.post("/mcp")
|
| 156 |
+
@app.get("/mcp")
|
| 157 |
@app.post("/sse")
|
| 158 |
@app.get("/sse")
|
| 159 |
+
async def mcp_http_endpoint(request: Request):
|
| 160 |
+
"""MCP HTTP endpoint - handle both GET and POST (accessible via /mcp or /sse)"""
|
| 161 |
try:
|
| 162 |
# For POST requests, get JSON body
|
| 163 |
if request.method == "POST":
|
|
|
|
| 239 |
return JSONResponse({
|
| 240 |
"service": "SEC Financial Data MCP Server",
|
| 241 |
"protocol": "MCP 2024-11-05",
|
| 242 |
+
"transport": "HTTP",
|
| 243 |
"status": "online"
|
| 244 |
})
|
| 245 |
|
|
|
|
| 301 |
|
| 302 |
<h2>π MCP Endpoint</h2>
|
| 303 |
<div class="endpoint">
|
| 304 |
+
https://jc321-easyreportsmcpserver.hf.space/mcp
|
| 305 |
</div>
|
| 306 |
+
<p><span class="badge badge-info">Protocol: MCP 2024-11-05</span> <span class="badge badge-info">Transport: HTTP</span></p>
|
| 307 |
<p style="text-align: center; margin: 20px 0;">
|
| 308 |
<a href="/test" style="display: inline-block; padding: 12px 24px; background: #2563eb; color: white; text-decoration: none; border-radius: 6px; font-weight: bold;">π§ͺ Test MCP Server Live</a>
|
| 309 |
</p>
|
|
|
|
| 523 |
<div class="code"><pre>{
|
| 524 |
"mcpServers": {
|
| 525 |
"sec-financial-data": {
|
| 526 |
+
"url": "https://jc321-easyreportsmcpserver.hf.space/mcp",
|
| 527 |
+
"transport": "http"
|
| 528 |
}
|
| 529 |
}
|
| 530 |
}</pre></div>
|
|
|
|
| 537 |
|
| 538 |
<h3>Option 2: Direct API Call</h3>
|
| 539 |
<p><strong>List Available Tools:</strong></p>
|
| 540 |
+
<div class="code"><pre>curl -X POST https://jc321-easyreportsmcpserver.hf.space/mcp \\
|
| 541 |
-H "Content-Type: application/json" \\
|
| 542 |
-d '{
|
| 543 |
"jsonrpc": "2.0",
|
|
|
|
| 546 |
}'</pre></div>
|
| 547 |
|
| 548 |
<p><strong>Search Company (Tesla):</strong></p>
|
| 549 |
+
<div class="code"><pre>curl -X POST https://jc321-easyreportsmcpserver.hf.space/mcp \\
|
| 550 |
-H "Content-Type: application/json" \\
|
| 551 |
-d '{
|
| 552 |
"jsonrpc": "2.0",
|
|
|
|
| 559 |
}'</pre></div>
|
| 560 |
|
| 561 |
<p><strong>Get 3-Year Financial Trends:</strong></p>
|
| 562 |
+
<div class="code"><pre>curl -X POST https://jc321-easyreportsmcpserver.hf.space/mcp \\
|
| 563 |
-H "Content-Type: application/json" \\
|
| 564 |
-d '{
|
| 565 |
"jsonrpc": "2.0",
|
|
|
|
| 594 |
<table>
|
| 595 |
<tr><th>Version</th><td>1.0.0 (FastMCP)</td></tr>
|
| 596 |
<tr><th>Protocol</th><td>Model Context Protocol (MCP) 2024-11-05</td></tr>
|
| 597 |
+
<tr><th>Transport</th><td>HTTP (Stateless)</td></tr>
|
| 598 |
<tr><th>Data Source</th><td>SEC EDGAR Database</td></tr>
|
| 599 |
<tr><th>Framework</th><td>Anthropic FastMCP SDK</td></tr>
|
| 600 |
<tr><th>Maintained by</th><td>Juntao Peng (jtyxabc@gmail.com)</td></tr>
|
|
|
|
| 632 |
button.disabled = true;
|
| 633 |
|
| 634 |
try {
|
| 635 |
+
const response = await fetch('/mcp', {
|
| 636 |
method: 'POST',
|
| 637 |
headers: { 'Content-Type': 'application/json' },
|
| 638 |
body: JSON.stringify({
|
|
|
|
| 728 |
</head>
|
| 729 |
<body>
|
| 730 |
<h1>π§ͺ MCP Server Live Test</h1>
|
| 731 |
+
<p>Test the MCP server at: <code>https://jc321-easyreportsmcpserver.hf.space/mcp</code></p>
|
| 732 |
|
| 733 |
<div>
|
| 734 |
<button onclick="testToolsList()">π Test: List Tools</button>
|
|
|
|
| 740 |
<div id="result"></div>
|
| 741 |
|
| 742 |
<script>
|
| 743 |
+
const endpoint = '/mcp'; // Use relative path for same-origin requests
|
| 744 |
|
| 745 |
function showStatus(msg, isError) {
|
| 746 |
document.getElementById('status').innerHTML =
|