financial-data-mcp-server
Uses LangChain's MCP adapters to connect the AI agent to the financial data MCP server tools.
Uses LangGraph to orchestrate the financial agent's tool selection and workflow.
Uses OpenAI's LLM to power the AI financial assistant agent that understands user questions and generates responses.
Provides a chat-based user interface for interacting with financial data through natural language.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
π Chat with Financial Data
An AI-powered financial data assistant that uses LLM agents, LangGraph, and Model Context Protocol (MCP) to answer questions about stocks and financial markets using real-time financial data tools.
π Overview
Chat with Financial Data is an AI-powered financial assistant designed to help users explore and analyze stock market information through natural language.
Instead of manually searching financial websites or running separate queries, users can simply ask questions such as:
"Give me information about ASII stock."
"What are the financial metrics of BBCA?"
"Show me the historical prices of TLKM."
"What is the P/E ratio of ASII?"
"Tell me about Astra International."
The application uses an AI agent to understand the user's question and dynamically select only the financial data tools needed to answer it.
The project uses Model Context Protocol (MCP) to provide a standardized interface between the AI agent and financial data tools.
Related MCP server: yahoo-finance-mcp-server
β¨ Features
π€ AI-Powered Financial Assistant
Users can interact with financial data using natural language instead of manually calling APIs or writing queries.
π MCP-Based Tool Integration
Financial data capabilities are exposed through an MCP server, allowing the AI agent to discover and use available tools dynamically.
π§ Intelligent Tool Selection
The AI agent determines which tools are required based on the user's question.
For example:
User:
"Give me information about ASII stock."
β
βΌ
AI Agent
β
βββ search_stock_tool
β
βββ stock_info
β
βΌ
Human-readable responseThe agent does not need to execute every available tool for every question.
π Financial Data Tools
The current MCP server provides the following tools:
Tool | Description |
| Searches for a stock ticker and company |
| Retrieves basic company information |
| Retrieves historical stock price data |
| Retrieves key financial metrics |
| Checks MCP server availability |
π¬ Streamlit Chat Interface
The project provides a user-friendly Streamlit interface with:
Chat-style conversation
Persistent chat history during the session
Natural language questions
Loading indicators
Human-readable AI responses
Financial data analysis through MCP tools
π Chat Logging
Chat interactions can be logged for monitoring and analysis.
The log can include:
Timestamp
User question
AI response
Runtime
Tools used
Token usage
Estimated API cost
Example:
Timestamp | Question | Answer | Runtime | Tools Used | Cost |
2026-08-03 | Give me information about ASII | ... | 4.21 sec | stock_info | $0.002 |
2026-08-03 | What is ASII P/E ratio? | ... | 3.15 sec | financial_metrics | $0.001 |
Chat logs are stored locally and are excluded from GitHub using .gitignore.
ποΈ System Architecture
ββββββββββββββββββββββββ
β User Question β
ββββββββββββ¬ββββββββββββ
β
βΌ
ββββββββββββββββββββββββ
β Streamlit UI β
ββββββββββββ¬ββββββββββββ
β
βΌ
ββββββββββββββββββββββββ
β Financial Agent β
β LangGraph β
ββββββββββββ¬ββββββββββββ
β
Selects required tools
β
βΌ
ββββββββββββββββββββββββββββββββ
β LangChain MCP Adapter β
ββββββββββββββββ¬ββββββββββββββββ
β
βΌ
ββββββββββββββββββββββββββββββββ
β Financial Data MCP Server β
β β
β ββββββββββββββββββββββββββ β
β β search_stock_tool β β
β β stock_info β β
β β historical_prices β β
β β financial_metrics β β
β β ping β β
β ββββββββββββββββββββββββββ β
ββββββββββββββββ¬ββββββββββββββββ
β
βΌ
Financial Data Source
β
βΌ
AI-generated Response
β
ββββββββββββββββ΄ββββββββββββββββ
βΌ βΌ
Streamlit UI Chat Logger
β
βΌ
Local CSV Logπ§© Technology Stack
AI & Agent
Python
OpenAI
LangChain
LangGraph
MCP
Model Context Protocol
MCP Python SDK
LangChain MCP Adapters
Financial Data
Yahoo Finance data source
Application
Streamlit
Python AsyncIO
Logging
CSV-based chat history
Runtime tracking
Token usage tracking
Estimated API cost tracking
π Project Structure
chat-with-financial-data/
β
βββ app/
β βββ __init__.py
β β
β βββ agent/
β β βββ __init__.py
β β βββ agent.py
β β βββ graph.py
β β βββ mcp_client.py
β β
β βββ mcp_servers/
β β βββ __init__.py
β β β
β β βββ financial_data/
β β βββ __init__.py
β β βββ server.py
β β βββ tools.py
β β
β βββ logging/
β βββ __init__.py
β βββ chat_logger.py
β
βββ logs/
β βββ .gitkeep
β
βββ tests/
β βββ test_agent.py
β βββ test_financial_tools.py
β βββ test_financial_mcp.py
β βββ test_langchain_mcp.py
β
βββ .env.example
βββ .gitignore
βββ LICENSE
βββ README.md
βββ requirements.txt
βββ streamlit_app.pyβοΈ Installation
1. Clone the Repository
git clone https://github.com/fifah123/chat-with-financial-data.git
cd chat-with-financial-data2. Create a Virtual Environment
Windows
python -m venv .venvActivate the environment:
.venv\Scripts\Activate.ps1If PowerShell blocks script execution, you can activate using:
.venv\Scripts\activate3. Install Dependencies
pip install -r requirements.txt4. Configure Environment Variables
Create a .env file in the project root:
OPENAI_API_KEY=your_openai_api_keyYou can use .env.example as a template.
β οΈ Never commit your
.envfile or expose your API key publicly.
βΆοΈ Running the Application
Start the Streamlit application:
streamlit run streamlit_app.pyThe application will open in your browser.
You can then ask questions such as:
Give me information about ASII stock.What are the financial metrics of BBCA?Show me the historical prices of TLKM.What is the P/E ratio of ASII?π Running the MCP Server
The Financial Data MCP server can be started with:
python -m app.mcp_servers.financial_data.serverThe MCP server communicates through stdio, so it may not display a visible response when started directly.
The server is designed to be launched and consumed by the MCP client.
π§ͺ Testing
Test Financial Tools
python tests/test_financial_tools.pyTest MCP Server
python tests/test_financial_mcp.pyTest LangChain MCP Integration
python tests/test_langchain_mcp.pyTest Financial Agent
python tests/test_agent.pyπ Example Workflow
Suppose the user asks:
Give me information about ASII stock.The system processes the request as follows:
Step 1 β User Input
Give me information about ASII stock.Step 2 β AI Agent Understands the Question
The agent identifies that the user is asking for basic stock information.
Step 3 β Agent Selects Required MCP Tools
The agent may call:
search_stock_tool
stock_infoIt does not need to call:
historical_prices
financial_metricsunless the question requires them.
Step 4 β MCP Server Executes the Tools
The MCP server retrieves the requested financial data.
Step 5 β AI Generates a Human-Friendly Answer
The raw tool output is converted into a natural-language response.
Example:
Astra International Tbk (ASII.JK) is an Indonesian company
listed on the Indonesia Stock Exchange.
Sector: Industrials
Industry: Conglomerates
Currency: IDR
Country: Indonesia
Exchange: Jakarta Stock Exchangeπ Example Financial Metrics
For example, the financial_metrics tool may return:
Ticker: ASII.JK
Market Cap: 203,323,869,233,152
P/E Ratio: 6.47
Forward P/E: 6.61
Price-to-Book: 0.87
Dividend Yield: 7.65%
Return on Equity: 11.98%
Profit Margin: 9.35%
Debt-to-Equity: 41.13The AI agent can then transform this raw data into an understandable financial summary.
π Chat Logging
The application records chat interactions locally.
Example log structure:
logs/
βββ chat_history.csvTypical information captured includes:
timestamp
question
answer
runtime_seconds
tools_used
input_tokens
output_tokens
total_tokens
estimated_cost_usdThe log file is intentionally excluded from GitHub to prevent personal conversation data and potentially sensitive information from being committed.
β οΈ Disclaimer
This project is intended for educational and informational purposes only.
The financial information provided by the application may be delayed, incomplete, or inaccurate. Nothing in this application should be considered financial, investment, or trading advice.
Always conduct your own research and consult a qualified financial professional before making investment decisions.
β Acknowledgements
This project uses open-source technologies including:
OpenAI
LangChain
LangGraph
Model Context Protocol (MCP)
Streamlit
Yahoo Finance
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelogβ¦
This server cannot be deployed
Maintenance
Related MCP Connectors
Financial data MCP server for Claude, ChatGPT, Cursor and Codex. Real-time stock quotes, financial statements, options flow, SEC filings, insider trades, 13F holdings, macro data and market news from gloom.sh, the open-source Bloomberg Terminal alternative.
Official Intrinio MCP server. US stock prices, options and fundamentals for AI agents.
MCP server exposing the Backtest360 engine API as tools for AI agents.
MCP server for Financial Modeling Prep API with 250+ financial data tools
Related MCP Servers
- FlicenseNot gradedqualityBmaintenanceA Model Context Protocol server built with FastMCP that provides financial data tools for AI agents, enabling them to access and analyze stock market information from Yahoo Finance through natural language queries.2-
- AlicenseAqualityCmaintenanceAn MCP server that exposes comprehensive Yahoo Finance data (quotes, financials, options, news, and more) to AI agents via the yfinance library, requiring no API key.24MIT
- AlicenseBqualityBmaintenanceA Model Context Protocol (MCP) server for agentic retrieval of financial data from Yahoo Finance, enabling stock information, historical data, analyst data, and more.71125 PyPI6AGPL 3.0
- AlicenseAqualityBmaintenanceMCP server that exposes Yahoo Finance data through tools for searching instruments, fetching quotes, history, company info, financials, dividends, news, recommendations, and options. Enables AI assistants to answer market-data questions using natural language.242,315 PyPI2MIT