<h1 align="center">
<a href="https://prompts.chat">
A specialized AI agent built with LangGraph and FastMCP that focuses exclusively on business intelligence and data analysis. This agent uses Model Context Protocol (MCP) to connect to data sources and provide intelligent responses to business queries.
Sign in to like and favorite skills
# [MODEL_HOSTNAME>]ales IQ [MODEL_HOSTNAME>]ata [MODEL_HOSTNAME>]gent
[MODEL_HOSTNAME>] specialized [MODEL_HOSTNAME>]I agent built with [MODEL_HOSTNAME>]angGraph and Fast[MODEL_HOSTNAME>]CP that focuses exclusively on business intelligence and data analysis. [MODEL_HOSTNAME>]his agent uses [MODEL_HOSTNAME>]odel Context Protocol ([MODEL_HOSTNAME>]CP) to connect to data sources and provide intelligent responses to business queries.
## [MODEL_HOSTNAME>]verview
[MODEL_HOSTNAME>]he [MODEL_HOSTNAME>]ales IQ [MODEL_HOSTNAME>]ata [MODEL_HOSTNAME>]gent is a focused, production-ready [MODEL_HOSTNAME>]I assistant that:
- **[MODEL_HOSTNAME>]pecializes in data analysis** - [MODEL_HOSTNAME>]nly handles business intelligence queries
- **Uses [MODEL_HOSTNAME>]CP Protocol** - Connects to business data through standardized [MODEL_HOSTNAME>]CP servers
- **Built with [MODEL_HOSTNAME>]angGraph** - Provides robust workflow orchestration and tool routing
- **Fast[MODEL_HOSTNAME>]CP Integration** - [MODEL_HOSTNAME>]everages the Fast[MODEL_HOSTNAME>]CP library for reliable [MODEL_HOSTNAME>]CP connectivity
## Key Features
### šÆ **[MODEL_HOSTNAME>]pecialized [MODEL_HOSTNAME>]ata Focus**
- Pure data analysis agent - no general-purpose tools
- Intelligent query routing to appropriate [MODEL_HOSTNAME>]CP tools
- Business intelligence and metrics generation
- [MODEL_HOSTNAME>]Q[MODEL_HOSTNAME>] query generation and execution
### š **[MODEL_HOSTNAME>]CP Protocol Integration**
- **Business Intelligence Query** - [MODEL_HOSTNAME>]atural language to [MODEL_HOSTNAME>]Q[MODEL_HOSTNAME>] conversion
- **Business [MODEL_HOSTNAME>]omain [MODEL_HOSTNAME>]iscovery** - [MODEL_HOSTNAME>]ist available data domains
- **[MODEL_HOSTNAME>]etric Creation** - Create custom business metrics from descriptions
- **[MODEL_HOSTNAME>]erver [MODEL_HOSTNAME>]anagement** - [MODEL_HOSTNAME>]ist tools and get server information
### š¤ **[MODEL_HOSTNAME>]dvanced [MODEL_HOSTNAME>]gent Capabilities**
- **Retry [MODEL_HOSTNAME>]ogic** - [MODEL_HOSTNAME>]utomatically retries failed queries up to 3 attempts
- **Query Breakdown** - [MODEL_HOSTNAME>]plits complex requests into manageable parts
- **[MODEL_HOSTNAME>]Q[MODEL_HOSTNAME>] [MODEL_HOSTNAME>]xtraction** - [MODEL_HOSTNAME>]hows the actual [MODEL_HOSTNAME>]Q[MODEL_HOSTNAME>] queries used for transparency
- **[MODEL_HOSTNAME>]rror [MODEL_HOSTNAME>]andling** - Graceful failure management with user feedback
## Quick [MODEL_HOSTNAME>]tart
### Prerequisites
- Python 3.11+ (required for Fast[MODEL_HOSTNAME>]CP)
- [MODEL_HOSTNAME>]pen[MODEL_HOSTNAME>]I [MODEL_HOSTNAME>]PI key
- Running [MODEL_HOSTNAME>]CP server with business data
### Installation
1. **Clone and setup:**
```bash
git clone <your-repo-url[MODEL_HOSTNAME>]
cd sales-iq-agent-basic
python -m venv .venv
source .venv/bin/activate # [MODEL_HOSTNAME>]n Windows: .venv\[MODEL_HOSTNAME>]cripts\activate
pip install -r requirements.txt
```
2. **Configure environment:**
```bash
cp .env.example .env
# [MODEL_HOSTNAME>]dit .env and add your [MODEL_HOSTNAME>]pen[MODEL_HOSTNAME>]I [MODEL_HOSTNAME>]PI key:
# [MODEL_HOSTNAME>]P[MODEL_HOSTNAME>][MODEL_HOSTNAME>][MODEL_HOSTNAME>]I[MODEL_HOSTNAME>][MODEL_HOSTNAME>]PI[MODEL_HOSTNAME>]K[MODEL_HOSTNAME>]Y=your[MODEL_HOSTNAME>]openai[MODEL_HOSTNAME>]api[MODEL_HOSTNAME>]key[MODEL_HOSTNAME>]here
```
3. **Configure [MODEL_HOSTNAME>]CP server:**
```bash
cp mcp[MODEL_HOSTNAME>]servers[MODEL_HOSTNAME>]config.template.json mcp[MODEL_HOSTNAME>]servers[MODEL_HOSTNAME>]config.json
# [MODEL_HOSTNAME>]dit mcp[MODEL_HOSTNAME>]servers[MODEL_HOSTNAME>]config.json with your [MODEL_HOSTNAME>]CP server details
```
4. **Run the agent:**
```bash
python main.py
```
## Configuration
### [MODEL_HOSTNAME>]CP [MODEL_HOSTNAME>]erver Configuration
[MODEL_HOSTNAME>]dit `mcp[MODEL_HOSTNAME>]servers[MODEL_HOSTNAME>]config.json`:
```json
{
"mcp[MODEL_HOSTNAME>]ervers": {
"sales[MODEL_HOSTNAME>]iq": {
"transport": "http",
"url": "http://<[MODEL_HOSTNAME>][MODEL_HOSTNAME>][MODEL_HOSTNAME>][MODEL_HOSTNAME>][MODEL_HOSTNAME>][MODEL_HOSTNAME>][MODEL_HOSTNAME>][MODEL_HOSTNAME>][MODEL_HOSTNAME>][MODEL_HOSTNAME>][MODEL_HOSTNAME>][MODEL_HOSTNAME>][MODEL_HOSTNAME>][MODEL_HOSTNAME>][MODEL_HOSTNAME>]:8000/mcp",
"headers": {
"[MODEL_HOSTNAME>]ccept": "application/json, text/event-stream",
"Content-[MODEL_HOSTNAME>]ype": "application/json",
"x-model": "Y[MODEL_HOSTNAME>]UR[MODEL_HOSTNAME>]IQ[MODEL_HOSTNAME>][MODEL_HOSTNAME>]pace",
"x-api-key": "Y[MODEL_HOSTNAME>]UR[MODEL_HOSTNAME>][MODEL_HOSTNAME>]CP[MODEL_HOSTNAME>][MODEL_HOSTNAME>]PI[MODEL_HOSTNAME>]K[MODEL_HOSTNAME>]Y[MODEL_HOSTNAME>][MODEL_HOSTNAME>][MODEL_HOSTNAME>]R[MODEL_HOSTNAME>]"
},
"timeout": 600
}
}
}
```
### [MODEL_HOSTNAME>]nvironment Variables
[MODEL_HOSTNAME>]et in `.env` file:
```bash
# Required
[MODEL_HOSTNAME>]P[MODEL_HOSTNAME>][MODEL_HOSTNAME>][MODEL_HOSTNAME>]I[MODEL_HOSTNAME>][MODEL_HOSTNAME>]PI[MODEL_HOSTNAME>]K[MODEL_HOSTNAME>]Y=your[MODEL_HOSTNAME>]openai[MODEL_HOSTNAME>]api[MODEL_HOSTNAME>]key[MODEL_HOSTNAME>]here
# [MODEL_HOSTNAME>]ptional (can override config file)
[MODEL_HOSTNAME>]CP[MODEL_HOSTNAME>][MODEL_HOSTNAME>]PI[MODEL_HOSTNAME>]K[MODEL_HOSTNAME>]Y=your[MODEL_HOSTNAME>]mcp[MODEL_HOSTNAME>]api[MODEL_HOSTNAME>]key[MODEL_HOSTNAME>]here
[MODEL_HOSTNAME>]CP[MODEL_HOSTNAME>][MODEL_HOSTNAME>][MODEL_HOSTNAME>]RV[MODEL_HOSTNAME>]R[MODEL_HOSTNAME>]UR[MODEL_HOSTNAME>]=http://localhost:8000/mcp
[MODEL_HOSTNAME>]CP[MODEL_HOSTNAME>][MODEL_HOSTNAME>][MODEL_HOSTNAME>][MODEL_HOSTNAME>][MODEL_HOSTNAME>][MODEL_HOSTNAME>]=[MODEL_HOSTNAME>]ales [MODEL_HOSTNAME>]pace
```
## Usage [MODEL_HOSTNAME>]xamples
### Interactive [MODEL_HOSTNAME>]ode
```bash
python main.py
```
### [MODEL_HOSTNAME>]xample Queries
```
š¤ You: What business domains are available for analysis?
š¤ [MODEL_HOSTNAME>]gent: [MODEL_HOSTNAME>]he available business domain is "[MODEL_HOSTNAME>]3C[MODEL_HOSTNAME>]PY[MODEL_HOSTNAME>][MODEL_HOSTNAME>]PC[MODEL_HOSTNAME>][MODEL_HOSTNAME>][MODEL_HOSTNAME>]F1"
š¤ You: [MODEL_HOSTNAME>]how me total sales for Q4 1998
š¤ [MODEL_HOSTNAME>]gent: [MODEL_HOSTNAME>]he total sales for Q4 1998 was $1,468,808,711.04
[MODEL_HOSTNAME>]Q[MODEL_HOSTNAME>] Query: [MODEL_HOSTNAME>][MODEL_HOSTNAME>][MODEL_HOSTNAME>][MODEL_HOSTNAME>]C[MODEL_HOSTNAME>] [MODEL_HOSTNAME>]U[MODEL_HOSTNAME>]([MODEL_HOSTNAME>][MODEL_HOSTNAME>][MODEL_HOSTNAME>]X[MODEL_HOSTNAME>][MODEL_HOSTNAME>][MODEL_HOSTNAME>][MODEL_HOSTNAME>][MODEL_HOSTNAME>][MODEL_HOSTNAME>]PRIC[MODEL_HOSTNAME>] * (1 - [MODEL_HOSTNAME>][MODEL_HOSTNAME>][MODEL_HOSTNAME>]I[MODEL_HOSTNAME>]C[MODEL_HOSTNAME>]U[MODEL_HOSTNAME>][MODEL_HOSTNAME>]))...
š¤ You: Find products with low inventory levels
š¤ [MODEL_HOSTNAME>]gent: Found 20 products with critical inventory (1 unit each):
- Product I[MODEL_HOSTNAME>] 124510: "navajo spring linen lemon burlywood"
- Product I[MODEL_HOSTNAME>] 5319: "white almond firebrick bisque metallic"
...
```
### Programmatic Usage
```python
from agent import create[MODEL_HOSTNAME>]agent
# Create specialized data agent
agent = create[MODEL_HOSTNAME>]agent()
# Query business data
response = agent.chat("What are the top 5 customers by revenue?")
print(response)
```
## Project [MODEL_HOSTNAME>]tructure
```
sales-iq-agent-basic/
āāā agent.py # [MODEL_HOSTNAME>]ain [MODEL_HOSTNAME>]angGraph agent implementation
āāā tools.py # [MODEL_HOSTNAME>]CP tool definitions
āāā mcp[MODEL_HOSTNAME>]client.py # Fast[MODEL_HOSTNAME>]CP client implementation
āāā main.py # C[MODEL_HOSTNAME>]I application entry point
āāā requirements.txt # Python dependencies
āāā .env.example # [MODEL_HOSTNAME>]nvironment variables template
āāā .gitignore # Git ignore rules
āāā mcp[MODEL_HOSTNAME>]servers[MODEL_HOSTNAME>]config.template.json # [MODEL_HOSTNAME>]CP configuration template
āāā test[MODEL_HOSTNAME>]proper[MODEL_HOSTNAME>]mcp.py # [MODEL_HOSTNAME>]CP integration tests
āāā R[MODEL_HOSTNAME>][MODEL_HOSTNAME>][MODEL_HOSTNAME>][MODEL_HOSTNAME>][MODEL_HOSTNAME>].md # [MODEL_HOSTNAME>]his documentation
```
## [MODEL_HOSTNAME>]rchitecture
### [MODEL_HOSTNAME>]gent Workflow
```
User Query ā [MODEL_HOSTNAME>]ata [MODEL_HOSTNAME>]gent ā [MODEL_HOSTNAME>]ecision ā [MODEL_HOSTNAME>]CP [MODEL_HOSTNAME>]ools ā [MODEL_HOSTNAME>]ata [MODEL_HOSTNAME>]gent ā Response
ā ā
[MODEL_HOSTNAME>][MODEL_HOSTNAME>][MODEL_HOSTNAME>] ([MODEL_HOSTNAME>]ool Results)
```
### [MODEL_HOSTNAME>]CP [MODEL_HOSTNAME>]ools [MODEL_HOSTNAME>]vailable
1. **`business[MODEL_HOSTNAME>]intelligence[MODEL_HOSTNAME>]query`** - [MODEL_HOSTNAME>]atural language to [MODEL_HOSTNAME>]Q[MODEL_HOSTNAME>] with results
2. **`get[MODEL_HOSTNAME>]available[MODEL_HOSTNAME>]business[MODEL_HOSTNAME>]domains`** - [MODEL_HOSTNAME>]ist business data domains
3. **`create[MODEL_HOSTNAME>]business[MODEL_HOSTNAME>]metric[MODEL_HOSTNAME>]tool`** - Create custom metrics
4. **`list[MODEL_HOSTNAME>]mcp[MODEL_HOSTNAME>]tools`** - [MODEL_HOSTNAME>]how available [MODEL_HOSTNAME>]CP server tools
5. **`get[MODEL_HOSTNAME>]mcp[MODEL_HOSTNAME>]server[MODEL_HOSTNAME>]info`** - [MODEL_HOSTNAME>]isplay server capabilities
### [MODEL_HOSTNAME>]rror [MODEL_HOSTNAME>]andling & Retries
- **3-attempt retry logic** for failed queries
- **[MODEL_HOSTNAME>]utomatic query breakdown** for complex requests
- **Graceful error messaging** with actionable feedback
- **[MODEL_HOSTNAME>]Q[MODEL_HOSTNAME>] query transparency** - shows actual queries used
## [MODEL_HOSTNAME>]evelopment
### [MODEL_HOSTNAME>]esting [MODEL_HOSTNAME>]CP Integration
```bash
python test[MODEL_HOSTNAME>]proper[MODEL_HOSTNAME>]mcp.py
```
### [MODEL_HOSTNAME>]esting [MODEL_HOSTNAME>]pecific [MODEL_HOSTNAME>]ools
```python
from mcp[MODEL_HOSTNAME>]client import business[MODEL_HOSTNAME>]intelligence[MODEL_HOSTNAME>]query
# [MODEL_HOSTNAME>]est business intelligence
result = business[MODEL_HOSTNAME>]intelligence[MODEL_HOSTNAME>]query("[MODEL_HOSTNAME>]how sales trends by quarter")
print(result)
```
### [MODEL_HOSTNAME>]isplaying [MODEL_HOSTNAME>]gent Workflow
```python
from agent import create[MODEL_HOSTNAME>]agent, display[MODEL_HOSTNAME>]graph
agent = create[MODEL_HOSTNAME>]agent()
display[MODEL_HOSTNAME>]graph(agent.graph) # Creates agent[MODEL_HOSTNAME>]workflow.png
```
## [MODEL_HOSTNAME>]ependencies
### Core [MODEL_HOSTNAME>]ibraries
- **[MODEL_HOSTNAME>]angGraph** - [MODEL_HOSTNAME>]gent workflow orchestration
- **[MODEL_HOSTNAME>]angChain** - [MODEL_HOSTNAME>][MODEL_HOSTNAME>][MODEL_HOSTNAME>] integration and tool management
- **Fast[MODEL_HOSTNAME>]CP** - [MODEL_HOSTNAME>]odel Context Protocol client
- **[MODEL_HOSTNAME>]pen[MODEL_HOSTNAME>]I** - [MODEL_HOSTNAME>]arge language model provider
### Complete [MODEL_HOSTNAME>]ependencies
[MODEL_HOSTNAME>]ee `requirements.txt` for full list with versions.
## [MODEL_HOSTNAME>]roubleshooting
### Common Issues
**1. "[MODEL_HOSTNAME>]o [MODEL_HOSTNAME>]CP tools available"**
- Check `mcp[MODEL_HOSTNAME>]servers[MODEL_HOSTNAME>]config.json` exists and has valid configuration
- Verify [MODEL_HOSTNAME>]CP server is running and accessible
- Confirm [MODEL_HOSTNAME>]PI key is correct
**2. "Invalid [MODEL_HOSTNAME>]PI Key" errors**
- Verify [MODEL_HOSTNAME>]pen[MODEL_HOSTNAME>]I [MODEL_HOSTNAME>]PI key in `.env` file
- Check [MODEL_HOSTNAME>]CP [MODEL_HOSTNAME>]PI key in config file
- [MODEL_HOSTNAME>]nsure [MODEL_HOSTNAME>]PI keys have proper permissions
**3. Connection timeouts**
- Increase timeout in `mcp[MODEL_HOSTNAME>]servers[MODEL_HOSTNAME>]config.json`
- Check network connectivity to [MODEL_HOSTNAME>]CP server
- Verify server UR[MODEL_HOSTNAME>] and port
**4. "[MODEL_HOSTNAME>]ool call failed" errors**
- Check [MODEL_HOSTNAME>]CP server logs for detailed errors
- Verify data source connectivity
- [MODEL_HOSTNAME>]est with simpler queries first
### [MODEL_HOSTNAME>]ebug [MODEL_HOSTNAME>]ode
```bash
python main.py --no-api-key-check # [MODEL_HOSTNAME>]kip [MODEL_HOSTNAME>]PI validation
```
## Contributing
[MODEL_HOSTNAME>]his is a specialized data agent focusing on business intelligence through [MODEL_HOSTNAME>]CP. Contributions should maintain this focus:
1. Keep tools limited to data analysis and [MODEL_HOSTNAME>]CP integration
2. [MODEL_HOSTNAME>]aintain error handling and retry logic
3. [MODEL_HOSTNAME>]nsure security best practices (no hardcoded keys)
4. Update tests for any new [MODEL_HOSTNAME>]CP tools
## [MODEL_HOSTNAME>]icense
[MODEL_HOSTNAME>]I[MODEL_HOSTNAME>] [MODEL_HOSTNAME>]icense - see [MODEL_HOSTNAME>]IC[MODEL_HOSTNAME>][MODEL_HOSTNAME>][MODEL_HOSTNAME>][MODEL_HOSTNAME>] file for details.
## [MODEL_HOSTNAME>]upport
For issues:
1. Check the troubleshooting section
2. Verify [MODEL_HOSTNAME>]CP server configuration
3. [MODEL_HOSTNAME>]est [MODEL_HOSTNAME>]CP connectivity with `test[MODEL_HOSTNAME>]proper[MODEL_HOSTNAME>]mcp.py`
4. Check agent logs for detailed error informationA specialized AI agent built with LangGraph and FastMCP that focuses exclusively on business intelligence and data analysis. This agent uses Model Context Protocol (MCP) to connect to data sources and provide intelligent responses to business queries.
The Sales IQ Data Agent is a focused, production-ready AI assistant that:
git clone <your-repo-url> cd sales-iq-agent-basic python -m venv .venv source .venv/bin/activate # On Windows: .venv\Scripts\activate pip install -r requirements.txt
cp .env.example .env # Edit .env and add your OpenAI API key: # OPENAI_API_KEY=your_openai_api_key_here
cp mcp_servers_config.template.json mcp_servers_config.json # Edit mcp_servers_config.json with your MCP server details
python main.py
Edit
mcp_servers_config.json:
{ "mcpServers": { "sales_iq": { "transport": "http", "url": "http://<MODEL_HOSTNAME>:8000/mcp", "headers": { "Accept": "application/json, text/event-stream", "Content-Type": "application/json", "x-model": "YOUR_IQ_Space", "x-api-key": "YOUR_MCP_API_KEY_HERE" }, "timeout": 600 } } }
Set in
.env file:
# Required OPENAI_API_KEY=your_openai_api_key_here # Optional (can override config file) MCP_API_KEY=your_mcp_api_key_here MCP_SERVER_URL=http://localhost:8000/mcp MCP_MODEL=Sales Space
python main.py
š¤ You: What business domains are available for analysis? š¤ Agent: The available business domain is "T3COPY_TPCH_SF1" š¤ You: Show me total sales for Q4 1998 š¤ Agent: The total sales for Q4 1998 was $1,468,808,711.04 SQL Query: SELECT SUM(L_EXTENDEDPRICE * (1 - L_DISCOUNT))... š¤ You: Find products with low inventory levels š¤ Agent: Found 20 products with critical inventory (1 unit each): - Product ID 124510: "navajo spring linen lemon burlywood" - Product ID 5319: "white almond firebrick bisque metallic" ...
from agent import create_agent # Create specialized data agent agent = create_agent() # Query business data response = agent.chat("What are the top 5 customers by revenue?") print(response)
sales-iq-agent-basic/ āāā agent.py # Main LangGraph agent implementation āāā tools.py # MCP tool definitions āāā mcp_client.py # FastMCP client implementation āāā main.py # CLI application entry point āāā requirements.txt # Python dependencies āāā .env.example # Environment variables template āāā .gitignore # Git ignore rules āāā mcp_servers_config.template.json # MCP configuration template āāā test_proper_mcp.py # MCP integration tests āāā README.md # This documentation
User Query ā Data Agent ā Decision ā MCP Tools ā Data Agent ā Response ā ā END (Tool Results)
business_intelligence_query - Natural language to SQL with resultsget_available_business_domains - List business data domainscreate_business_metric_tool - Create custom metricslist_mcp_tools - Show available MCP server toolsget_mcp_server_info - Display server capabilitiespython test_proper_mcp.py
from mcp_client import business_intelligence_query # Test business intelligence result = business_intelligence_query("Show sales trends by quarter") print(result)
from agent import create_agent, display_graph agent = create_agent() display_graph(agent.graph) # Creates agent_workflow.png
See
requirements.txt for full list with versions.
1. "No MCP tools available"
mcp_servers_config.json exists and has valid configuration2. "Invalid API Key" errors
.env file3. Connection timeouts
mcp_servers_config.json4. "Tool call failed" errors
python main.py --no-api-key-check # Skip API validation
This is a specialized data agent focusing on business intelligence through MCP. Contributions should maintain this focus:
MIT License - see LICENSE file for details.
For issues:
test_proper_mcp.py