loading…
Search for a command to run...
loading…
Provides real-time stock analysis tools including price lookup, comprehensive investment scoring, and company-to-ticker conversion through a MCP interface.
Provides real-time stock analysis tools including price lookup, comprehensive investment scoring, and company-to-ticker conversion through a MCP interface.
A cloud-hosted Model Context Protocol (MCP) server for real-time stock analysis, built with Modal and FastAPI.
This MCP server provides stock analysis tools through a RESTful API, demonstrating how to implement the Model Context Protocol in a distributed, cloud-native architecture.
get_stock_price - Retrieve current stock price and basic company informationanalyze_stock_comprehensive - Complete investment analysis with scoring algorithmsmart_ticker_search - Convert company names to ticker symbolsClone the repository
git clone <your-repo-url>
cd modal-mcp-server
Install Modal CLI
pip install modal
Authenticate with Modal
modal token new
Deploy the MCP server
modal deploy modal_mcp_complete.py
https://koyeliaghoshroy1--mcp-stock-analysis-server-web-app.modal.run
curl https://koyeliaghoshroy1--mcp-stock-analysis-server-web-app.modal.run/
curl https://koyeliaghoshroy1--mcp-stock-analysis-server-web-app.modal.run/health
curl https://koyeliaghoshroy1--mcp-stock-analysis-server-web-app.modal.run/tools
curl -X POST https://koyeliaghoshroy1--mcp-stock-analysis-server-web-app.modal.run/call \
-H "Content-Type: application/json" \
-d '{"name": "TOOL_NAME", "arguments": {"key": "value"}}'
curl -X POST https://koyeliaghoshroy1--mcp-stock-analysis-server-web-app.modal.run/call \
-H "Content-Type: application/json" \
-d '{"name": "get_stock_price", "arguments": {"symbol": "AAPL"}}'
Response:
{
"success": true,
"tool": "get_stock_price",
"result": [{
"symbol": "TSLA",
"company_name": "Tesla, Inc.",
"current_price": 248.50,
"market_cap": 790000000000,
"sector": "Consumer Cyclical"
}],
"timestamp": "2025-06-10T..."
}
curl -X POST https://koyeliaghoshroy1--mcp-stock-analysis-server-web-app.modal.run/call \
-H "Content-Type: application/json" \
-d '{"name": "analyze_stock_comprehensive", "arguments": {"symbol": "AAPL"}
}'
Response:
{
"success": true,
"tool": "analyze_stock_comprehensive",
"result": [{
"symbol": "AAPL",
"company_name": "Apple Inc.",
"current_price": 185.50,
"ytd_return": 12.5,
"pe_ratio": 28.5,
"investment_score": 75,
"recommendation": "Buy",
"sector": "Technology"
}],
"timestamp": "2025-06-10T..."
}
curl -X POST https://koyeliaghoshroy1--mcp-stock-analysis-server-web-app.modal.run/call \
-H "Content-Type: application/json" \
-d '{
"name": "smart_ticker_search",
"arguments": {"query": "microsoft"}
}'
MCP_SERVER_SECRET - Optional server secret for authenticationThe server can optionally use Modal secrets for configuration:
stock_secrets = modal.Secret.from_name("Stock-api-config")
modal-mcp-server/
├── modal_mcp_complete.py # Main MCP server implementation
├── README.md # This file
└── requirements.txt # Dependencies (handled by Modal)
The comprehensive analysis uses a proprietary scoring algorithm:
score = 50 # Base score
if ytd_return > 15: score += 25
elif ytd_return > 5: score += 15
elif ytd_return > 0: score += 5
if 10 < pe_ratio < 25: score += 15
# Final score: 0-100
recommendation = "Buy" if score >= 70 else "Hold" if score >= 50 else "Sell"
# Test health endpoint
curl http://localhost:8000/health
# Test tools discovery
curl http://localhost:8000/tools
# Test tool execution
curl -X POST http://localhost:8000/call \
-H "Content-Type: application/json" \
-d '{"name": "get_stock_price", "arguments": {"symbol": "AAPL"}}'
# Deploy to Modal
modal deploy modal_mcp_complete.py
# Check deployment status
modal app list
# View logs
modal logs <app-id>
Monitor server health via the /health endpoint:
curl https://koyeliaghoshroy1--mcp-stock-analysis-server-web-app.modal.run/health
The server provides detailed error responses:
{
"error": "No data available for INVALID",
"success": false,
"timestamp": "2025-06-10T..."
}
This server implements the Model Context Protocol specification:
GET /tools returns available MCP toolsPOST /call executes tools with proper request/response formatimport requests
def call_mcp_tool(tool_name, arguments):
response = requests.post(
"https://your-modal-url/call",
json={"name": tool_name, "arguments": arguments}
)
return response.json()
# Get stock price
result = call_mcp_tool("get_stock_price", {"symbol": "AAPL"})
async function callMCPTool(toolName, arguments) {
const response = await fetch('https://your-modal-url/call', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ name: toolName, arguments })
});
return response.json();
}
// Analyze stock
const analysis = await callMCPTool('analyze_stock_comprehensive', { symbol: 'TSLA' });
MIT License - see LICENSE file for details.
Built for the Hugging Face Gradio MCP Hackathon 🚀
Run in your terminal:
claude mcp add modal-mcp-stock-analysis-server -- npx Security
Low riskAutomated heuristic from public metadata — not a security guarantee.