The Stock Analysis MCP Server provides comprehensive tools for accessing and analyzing stock market data through various endpoints, making it easier to obtain financial information, stock performance metrics, and market sentiment indicators.
Before installing the Stock Analysis MCP Server, ensure you have Python installed on your system.
git clone <repository_url>
cd mcp_stock
It's recommended to use a virtual environment to avoid dependency conflicts:
python -m venv venv
Activate the virtual environment:
On Linux/macOS:
source venv/bin/activate
On Windows:
venv\Scripts\activate
Install the required packages:
pip install -r requirements.txt
playwright install
Some tools require API keys. Create a .env
file in the project root directory with the following content:
TAVILY_API_KEY=your_tavily_api_key_here
Start the MCP server using the following command:
fastmcp run server.py --transport=sse --port=8000 --host=0.0.0.0
You can specify a different port by changing the --port
parameter:
fastmcp run server.py --transport=sse --port=9000 --host=0.0.0.0
Once the server is running, you can access the various stock analysis tools through their respective endpoints. All endpoints are prefixed with /mcp
.
Access information about stock concept sectors, fund flows, and price changes:
/mcp/stock
Retrieve stock financial indicators and company information:
/mcp/finance
Get detailed F10 information about stocks:
/mcp/f10
Analyze A-share market sentiment indicators:
/mcp/market
Get lists of continuous limit-up stocks:
/mcp/stockUp
Perform web searches related to stocks:
/mcp/websearch
You can make requests to the API endpoints using any HTTP client. For example, using curl
:
curl http://localhost:8000/mcp/finance
Or in Python using the requests
library:
import requests
response = requests.get("http://localhost:8000/mcp/stock")
data = response.json()
print(data)
Each endpoint may require specific parameters for different operations. Refer to the server's API documentation for detailed information about each endpoint's required parameters and response format.
To add this MCP server to Claude Code, run this command in your terminal:
claude mcp add-json "mcp-stock" '{"command":"fastmcp","args":["run","server.py","--transport=sse","--port=8000","--host=0.0.0.0"]}'
See the official Claude Code MCP documentation for more details.
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"mcp-stock": {
"command": "fastmcp",
"args": [
"run",
"server.py",
"--transport=sse",
"--port=8000",
"--host=0.0.0.0"
]
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.
To add this MCP server to Claude Desktop:
1. Find your configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
~/.config/Claude/claude_desktop_config.json
2. Add this to your configuration file:
{
"mcpServers": {
"mcp-stock": {
"command": "fastmcp",
"args": [
"run",
"server.py",
"--transport=sse",
"--port=8000",
"--host=0.0.0.0"
]
}
}
}
3. Restart Claude Desktop for the changes to take effect