Spaces:
Runtime error
Runtime error
Upload 3 files
Browse files- README.md +18 -0
- app.py +13 -4
- index_simple.html +2 -1
README.md
CHANGED
|
@@ -171,6 +171,24 @@ Use similar command-based configuration with:
|
|
| 171 |
- `args`: ["path/to/app.py", "--mcp"]
|
| 172 |
- `env`: Set FINNHUB_API_KEY
|
| 173 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 174 |
#### 7️⃣ Restart Your MCP Client
|
| 175 |
|
| 176 |
Restart Claude Desktop / Cursor to load the new server configuration.
|
|
|
|
| 171 |
- `args`: ["path/to/app.py", "--mcp"]
|
| 172 |
- `env`: Set FINNHUB_API_KEY
|
| 173 |
|
| 174 |
+
**For URL-based Access (HF Space or Remote Server):**
|
| 175 |
+
|
| 176 |
+
If the server is deployed on Hugging Face Space or a remote server:
|
| 177 |
+
```json
|
| 178 |
+
{
|
| 179 |
+
"mcpServers": {
|
| 180 |
+
"finnhub-remote": {
|
| 181 |
+
"url": "https://jc321-marketandstockmcp.hf.space/mcp"
|
| 182 |
+
}
|
| 183 |
+
}
|
| 184 |
+
}
|
| 185 |
+
```
|
| 186 |
+
|
| 187 |
+
**Note:**
|
| 188 |
+
- URL-based access requires the API key to be configured on the server side (via `FINNHUB_API_KEY` environment variable)
|
| 189 |
+
- The `/mcp` endpoint is automatically available when running the Gradio UI (`python app.py`)
|
| 190 |
+
- For HF Space deployment, set the API key in Space secrets
|
| 191 |
+
|
| 192 |
#### 7️⃣ Restart Your MCP Client
|
| 193 |
|
| 194 |
Restart Claude Desktop / Cursor to load the new server configuration.
|
app.py
CHANGED
|
@@ -605,12 +605,21 @@ if __name__ == "__main__":
|
|
| 605 |
|
| 606 |
# Check if running as MCP server or Gradio UI
|
| 607 |
if "--mcp" in sys.argv or os.getenv("RUN_MCP_SERVER") == "true":
|
| 608 |
-
# Run as MCP server
|
| 609 |
-
print("▶️ Starting MCP Server...")
|
| 610 |
mcp.run(transport="sse")
|
| 611 |
else:
|
| 612 |
-
# Launch Gradio interface
|
| 613 |
-
print("▶️ Starting Gradio Interface...")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 614 |
demo.launch(
|
| 615 |
server_name=host,
|
| 616 |
server_port=port,
|
|
|
|
| 605 |
|
| 606 |
# Check if running as MCP server or Gradio UI
|
| 607 |
if "--mcp" in sys.argv or os.getenv("RUN_MCP_SERVER") == "true":
|
| 608 |
+
# Run as MCP server (standalone mode)
|
| 609 |
+
print("▶️ Starting MCP Server (standalone mode)...")
|
| 610 |
mcp.run(transport="sse")
|
| 611 |
else:
|
| 612 |
+
# Launch Gradio interface with MCP endpoint mounted
|
| 613 |
+
print("▶️ Starting Gradio Interface with MCP endpoint...")
|
| 614 |
+
|
| 615 |
+
# Mount MCP server to Gradio app at /mcp path
|
| 616 |
+
# This allows both UI and MCP protocol access
|
| 617 |
+
mcp_app = mcp.get_asgi_app()
|
| 618 |
+
demo.mount_app(path="/mcp", app=mcp_app)
|
| 619 |
+
|
| 620 |
+
print("📡 MCP endpoint available at: /mcp")
|
| 621 |
+
print("🌐 Gradio UI available at: /")
|
| 622 |
+
|
| 623 |
demo.launch(
|
| 624 |
server_name=host,
|
| 625 |
server_port=port,
|
index_simple.html
CHANGED
|
@@ -31,7 +31,8 @@ strong { color: #1f2937; }
|
|
| 31 |
<h2>How to Use</h2>
|
| 32 |
<ul>
|
| 33 |
<li>Configure your Finnhub API key in the <strong>"🔑 API Key Config"</strong> tab</li>
|
| 34 |
-
<li>Use tools through your MCP client (e.g., Claude Desktop, Cursor)</li>
|
|
|
|
| 35 |
<li>Check server connectivity in the <strong>"🩺 Health Check"</strong> tab if needed</li>
|
| 36 |
</ul>
|
| 37 |
<div class="note">
|
|
|
|
| 31 |
<h2>How to Use</h2>
|
| 32 |
<ul>
|
| 33 |
<li>Configure your Finnhub API key in the <strong>"🔑 API Key Config"</strong> tab</li>
|
| 34 |
+
<li><strong>Option 1:</strong> Use tools through your MCP client (e.g., Claude Desktop, Cursor)</li>
|
| 35 |
+
<li><strong>Option 2:</strong> Access via URL: <code>https://jc321-marketandstockmcp.hf.space/mcp</code></li>
|
| 36 |
<li>Check server connectivity in the <strong>"🩺 Health Check"</strong> tab if needed</li>
|
| 37 |
</ul>
|
| 38 |
<div class="note">
|