Spaces:
Sleeping
Sleeping
Upload 3 files
Browse files- README.md +16 -6
- app.py +15 -7
- index.html +16 -2
README.md
CHANGED
|
@@ -44,22 +44,32 @@ This MCP server provides three powerful tools:
|
|
| 44 |
|
| 45 |
### For MCP Client Integration
|
| 46 |
|
| 47 |
-
|
| 48 |
|
| 49 |
-
1.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
|
| 51 |
```json
|
| 52 |
{
|
| 53 |
"mcpServers": {
|
| 54 |
-
"finnhub": {
|
| 55 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
}
|
| 57 |
}
|
| 58 |
}
|
| 59 |
```
|
| 60 |
|
| 61 |
-
2. Configure your Finnhub API key in the web interface or set the `FINNHUB_API_KEY` environment variable
|
| 62 |
-
|
| 63 |
## 🛠️ Available MCP Tools
|
| 64 |
|
| 65 |
### get_quote
|
|
|
|
| 44 |
|
| 45 |
### For MCP Client Integration
|
| 46 |
|
| 47 |
+
**Note:** The current version (Gradio 4.44.x) provides a Gradio UI for testing. For MCP client integration, you can:
|
| 48 |
|
| 49 |
+
1. **Use the tools via Gradio UI** - Test and interact with tools through the web interface
|
| 50 |
+
2. **Run MCP server locally** - For local MCP client connections:
|
| 51 |
+
|
| 52 |
+
```bash
|
| 53 |
+
# Run the MCP server
|
| 54 |
+
python app.py --mcp
|
| 55 |
+
```
|
| 56 |
+
|
| 57 |
+
Then configure your MCP client:
|
| 58 |
|
| 59 |
```json
|
| 60 |
{
|
| 61 |
"mcpServers": {
|
| 62 |
+
"finnhub-local": {
|
| 63 |
+
"command": "python",
|
| 64 |
+
"args": ["path/to/app.py", "--mcp"],
|
| 65 |
+
"env": {
|
| 66 |
+
"FINNHUB_API_KEY": "your_api_key_here"
|
| 67 |
+
}
|
| 68 |
}
|
| 69 |
}
|
| 70 |
}
|
| 71 |
```
|
| 72 |
|
|
|
|
|
|
|
| 73 |
## 🛠️ Available MCP Tools
|
| 74 |
|
| 75 |
### get_quote
|
app.py
CHANGED
|
@@ -511,6 +511,8 @@ with gr.Blocks(title="Finnhub Market Info MCP Server", theme=gr.themes.Soft()) a
|
|
| 511 |
|
| 512 |
|
| 513 |
if __name__ == "__main__":
|
|
|
|
|
|
|
| 514 |
# Check for API key in environment variable
|
| 515 |
env_api_key = os.getenv("FINNHUB_API_KEY")
|
| 516 |
if env_api_key:
|
|
@@ -521,10 +523,16 @@ if __name__ == "__main__":
|
|
| 521 |
port = int(os.getenv("PORT", "7860"))
|
| 522 |
host = os.getenv("HOST", "0.0.0.0")
|
| 523 |
|
| 524 |
-
#
|
| 525 |
-
|
| 526 |
-
|
| 527 |
-
|
| 528 |
-
|
| 529 |
-
|
| 530 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 511 |
|
| 512 |
|
| 513 |
if __name__ == "__main__":
|
| 514 |
+
import sys
|
| 515 |
+
|
| 516 |
# Check for API key in environment variable
|
| 517 |
env_api_key = os.getenv("FINNHUB_API_KEY")
|
| 518 |
if env_api_key:
|
|
|
|
| 523 |
port = int(os.getenv("PORT", "7860"))
|
| 524 |
host = os.getenv("HOST", "0.0.0.0")
|
| 525 |
|
| 526 |
+
# Check if running as MCP server or Gradio UI
|
| 527 |
+
if "--mcp" in sys.argv or os.getenv("RUN_MCP_SERVER") == "true":
|
| 528 |
+
# Run as MCP server
|
| 529 |
+
print("▶️ Starting MCP Server...")
|
| 530 |
+
mcp.run(transport="sse")
|
| 531 |
+
else:
|
| 532 |
+
# Launch Gradio interface (default for HF Space)
|
| 533 |
+
print("▶️ Starting Gradio Interface...")
|
| 534 |
+
demo.launch(
|
| 535 |
+
server_name=host,
|
| 536 |
+
server_port=port,
|
| 537 |
+
share=False
|
| 538 |
+
)
|
index.html
CHANGED
|
@@ -295,19 +295,33 @@
|
|
| 295 |
|
| 296 |
<h2>🔌 MCP Client Integration</h2>
|
| 297 |
|
| 298 |
-
<p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 299 |
|
| 300 |
<h3>Configuration:</h3>
|
| 301 |
<div class="example">
|
| 302 |
{
|
| 303 |
"mcpServers": {
|
| 304 |
"finnhub": {
|
| 305 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
| 306 |
}
|
| 307 |
}
|
| 308 |
}
|
| 309 |
</div>
|
| 310 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 311 |
<h3>Example Queries:</h3>
|
| 312 |
<ul>
|
| 313 |
<li>"What's the current price of Apple stock?"</li>
|
|
|
|
| 295 |
|
| 296 |
<h2>🔌 MCP Client Integration</h2>
|
| 297 |
|
| 298 |
+
<p>For local MCP client integration (Claude Desktop, Cursor, Cline, etc.):</p>
|
| 299 |
+
|
| 300 |
+
<h3>Run MCP Server:</h3>
|
| 301 |
+
<div class="example">
|
| 302 |
+
python app.py --mcp
|
| 303 |
+
</div>
|
| 304 |
|
| 305 |
<h3>Configuration:</h3>
|
| 306 |
<div class="example">
|
| 307 |
{
|
| 308 |
"mcpServers": {
|
| 309 |
"finnhub": {
|
| 310 |
+
"command": "python",
|
| 311 |
+
"args": ["path/to/app.py", "--mcp"],
|
| 312 |
+
"env": {
|
| 313 |
+
"FINNHUB_API_KEY": "your_api_key_here"
|
| 314 |
+
}
|
| 315 |
}
|
| 316 |
}
|
| 317 |
}
|
| 318 |
</div>
|
| 319 |
|
| 320 |
+
<div class="alert">
|
| 321 |
+
<h4>ℹ️ Note</h4>
|
| 322 |
+
<p>This Hugging Face Space provides the <strong>Gradio UI</strong> for testing tools. For MCP client integration, clone the repository and run the MCP server locally.</p>
|
| 323 |
+
</div>
|
| 324 |
+
|
| 325 |
<h3>Example Queries:</h3>
|
| 326 |
<ul>
|
| 327 |
<li>"What's the current price of Apple stock?"</li>
|