Skip to content

amanxarma-x71dev/multi-agent-analytics-assistant

Repository files navigation

Multi-Agent Analytics Assistant

CrewAI + Ollama + local MCP server + Streamlit. Built to spec: 3 agents, 15 local function tools, a 10-tool analytics_mcp_server, and a chat UI with an activity timeline.

Quick start

# 1. Ollama (local LLM)
ollama pull llama3.1        # default model - change in app_config.py if needed
ollama serve

# 2. Python deps
pip install -r requirements.txt

# 3. Run
streamlit run streamlit_app.py

Open the printed local URL, pick a dataset from data/sample_datasets/, and ask something like:

Analyze the sales_transactions.csv file. Profile the dataset, find data quality issues, suggest KPIs and a dashboard, recommend ML use cases, and suggest feature engineering ideas.

What's inside

Path What
streamlit_app.py Chat UI, activity timeline, sidebar (spec section 11)
crew_orchestrator.py Builds the crew, connects the MCP adapter, runs tasks
app_config.py Ollama model / context window / safety config (edit here)
config/agents.yaml, config/tasks.yaml Agent & task definitions
agents/ Supervisor, Data Analyst, Data Scientist agent builders
function_tools/ 15 local tools, 5 per agent
mcp_server/ analytics_mcp_server — 10 MCP tools over stdio (FastMCP)
core/data_profiling_core.py Shared profiling/data-quality logic (used by both tool layers)
data/sample_datasets/ 3 generated sample datasets with intentional data-quality issues
tests/ pytest suite for core logic, function tools, MCP tools, agent construction
docs/ architecture diagram, MCP tool catalog, demo script

Agents (spec section 5)

  1. Supervisor Agent — classifies requests, delegates, validates the final response structure, tracks context usage.
  2. Data Analyst Agent — profiles data, suggests KPIs/dashboards, validates SQL, explains trends.
  3. Data Scientist Agent — recommends ML problem types/use cases, feature engineering, evaluation metrics, and pipeline plans.

Function tools (15 total, spec section 6)

  • Supervisor (5): classify_user_request, create_agent_work_plan, summarize_chat_history, validate_final_response_structure, estimate_context_usage
  • Data Analyst (5): profile_dataframe, suggest_kpi_metrics, generate_dashboard_layout, validate_sql_safety, explain_query_result
  • Data Scientist (5): recommend_ml_problem_type, suggest_feature_engineering, detect_ml_data_risks, recommend_evaluation_metrics, create_ml_pipeline_plan

MCP tools (10 total, spec section 8)

See docs/mcp_tool_catalog.md for the full table. Names: mcp_profile_csv, mcp_run_duckdb_query, mcp_validate_sql, mcp_detect_data_quality_issues, mcp_generate_kpi_catalog, mcp_recommend_ml_use_cases, mcp_feature_engineering_suggestions, mcp_anomaly_detection_summary, mcp_create_data_dictionary, mcp_generate_report_markdown.

Run the MCP server on its own:

python run_mcp_server.py

Safety guardrails (spec section 14)

  • SQL tools allow only SELECT; block DELETE/UPDATE/DROP/ALTER/INSERT/ MERGE/TRUNCATE/CREATE.
  • All file access is restricted to data/sample_datasets/ (path traversal blocked, file-size limited, extension allow-list enforced).
  • No shell commands are ever executed from user input.
  • Raw stack traces are shown only inside an expandable "Debug details" section in the UI, never directly to the user.

Tests

pytest

Covers: core profiling/data-quality logic, all 15 function tools, all 10 MCP tools (called directly, bypassing the protocol layer), and agent construction (tools attach correctly without needing a live LLM call).

Swapping the Ollama model

Edit app_config.py:

OLLAMA_MODEL = "llama3.1"   # change to any model you've pulled

or set the OLLAMA_MODEL environment variable before launching.

About

Multi-Agent Analytics Assistant built using CrewAI, Ollama, Streamlit and Local MCP Server.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages