Add streamable-http and SSE transport support via CLI args
This commit is contained in:
@@ -86,6 +86,36 @@ TradingView session cookies enable real-time data. Priority:
|
||||
2. `set_session` tool (in-memory)
|
||||
3. `TV_SESSION_ID` environment variable (loaded from `.env` via `python-dotenv`)
|
||||
|
||||
## NanoClaw Integration
|
||||
|
||||
Add to your NanoClaw group's `.mcp.json`:
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"tradingview-screener": {
|
||||
"command": "/path/to/.venv/bin/python3",
|
||||
"args": ["/path/to/server.py"],
|
||||
"env": {
|
||||
"TV_SESSION_ID": "${TV_SESSION_ID}"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
For streamable HTTP (server runs externally):
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"tradingview-screener": {
|
||||
"url": "http://host.docker.internal:8000/mcp"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Setup
|
||||
|
||||
```bash
|
||||
@@ -99,7 +129,14 @@ cp .env.example .env
|
||||
## Run
|
||||
|
||||
```bash
|
||||
# STDIO transport (default — for Claude Desktop, NanoClaw, etc.)
|
||||
python server.py
|
||||
|
||||
# Streamable HTTP transport
|
||||
python server.py --transport streamable-http --host 0.0.0.0 --port 8000
|
||||
|
||||
# SSE transport
|
||||
python server.py --transport sse --host 127.0.0.1 --port 8000
|
||||
```
|
||||
|
||||
## Tests
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import os
|
||||
from typing import Any, cast
|
||||
|
||||
@@ -519,4 +520,18 @@ def clear_session() -> str:
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
mcp.run(transport="stdio")
|
||||
parser = argparse.ArgumentParser(description="TradingView Screener MCP Server")
|
||||
parser.add_argument(
|
||||
"--transport",
|
||||
choices=["stdio", "sse", "streamable-http"],
|
||||
default="stdio",
|
||||
help="Transport protocol (default: stdio)",
|
||||
)
|
||||
parser.add_argument("--host", default=None, help="Host to bind (default: 127.0.0.1)")
|
||||
parser.add_argument("--port", type=int, default=None, help="Port to bind (default: 8000)")
|
||||
args = parser.parse_args()
|
||||
if args.host:
|
||||
mcp.settings.host = args.host
|
||||
if args.port:
|
||||
mcp.settings.port = args.port
|
||||
mcp.run(transport=args.transport)
|
||||
|
||||
Reference in New Issue
Block a user