1- # AGENTS.md – Guidelines for the MCP Data Assistant Agent
1+ # AGENTS.md – Guidelines for the MCP Data Assistant Project
22
3- > ** Read this entire file before performing any action.** Failing to follow these rules may invalidate the task .
3+ > ** Read this entire file before performing any action.** This guide helps you navigate the codebase, run tests, and adhere to project standards .
44
55---
66
7- ## 1. Environment initialization
7+ ## 1. Codebase Navigation
88
9- Dependencies are automatically installed via the agent interface during the configuration phase.
10- The wheelhouse directory contains all required packages for offline installation.
9+ This project implements Model Context Protocol (MCP) tools for data analysis. Key areas:
1110
12- * Required environment variables:
13- - ` PYTHONPATH ` : Set to ` . `
14- - ` PROJECT_ROOT ` : Set to ` /workspace/mcp-data-assistant `
15-
16- * Optional secrets:
17- - ` OPENAI_API_KEY ` : Required only if using OpenAI models (not needed for Ollama)
11+ | Directory | Purpose | Key Files |
12+ | ---------- | ----------------------------------------------------- | ----------------------------- |
13+ | ` agent/ ` | LLM assistant logic and session management | ` assistant.py ` , ` session_manager.py ` |
14+ | ` tools/ ` | Core MCP tools (SQL, CSV, PDF) | ` sql_tool.py ` , ` csv_tool.py ` , ` pdf_tool.py ` |
15+ | ` tests/ ` | Unit and integration tests | Test files mirror source structure |
16+ | ` static/ ` | Static assets including MCP schema | ` schema.json ` (MCP tool definitions) |
17+ | ` data/ ` | Sample datasets for testing | ` sales.db ` , ` people.csv ` |
18+ | ` reports/ ` | Generated PDF reports output directory | Empty initially, populated during runtime |
19+
20+ Key entry points:
21+ - ` app.py ` : Main Gradio application
22+ - ` scripts/demo_cli.py ` : Command-line interface
1823
1924---
2025
21- ## 2. Quality gates (run in this order)
26+ ## 2. Development Environment Setup
2227
28+ ### Environment Variables
2329``` bash
24- pytest -q --cov=tools --cov=agent --cov-report=term-missing --cov-fail-under=85 # tests and coverage ≥ 85%
25- ruff check . # code formatting and linting
26- ruff format --check . # code formatting check
27- mypy tools/ agent/ tests/ --python-version 3.12 # strict typing
28- bandit -r tools/ agent/ -ll -x /tests/ # security scan
30+ export PYTHONPATH=" ."
31+ export PROJECT_ROOT=$( pwd)
2932```
3033
31- All commands must return exit code 0. Fix any failing gate ** before committing** .
34+ ### Dependencies
35+ All required packages are in ` requirements.txt ` . The ` wheelhouse/ ` directory contains pre-downloaded packages for offline installation:
3236
33- ---
37+ ``` bash
38+ pip install -r requirements.txt --find-links wheelhouse/
39+ ```
3440
35- ## 3. GitHub workflow compatibility
41+ ### Optional Secrets
42+ - ` OPENAI_API_KEY ` : Required only if using OpenAI models (not needed for Ollama)
3643
37- This project follows GitHub Actions CI/CD standards:
44+ ---
3845
39- * All PRs must pass automated checks
40- * CI pipeline runs the quality gates listed above
41- * Commits must follow conventional commit format
42- * Branch protection requires PR reviews before merging to ` main `
46+ ## 3. Testing and Quality Assurance
4347
44- ---
48+ Run these commands for testing and code quality:
4549
46- ## 4. Project structure
50+ ``` bash
51+ # Run tests
52+ pytest -v
4753
48- | Directory | Purpose |
49- | ---------- | ----------------------------------------------------- |
50- | ` agent/ ` | LLM assistant logic and session management |
51- | ` tools/ ` | Core MCP tools (SQL, CSV, PDF) |
52- | ` tests/ ` | Unit and integration tests |
53- | ` static/ ` | Static assets including MCP schema |
54- | ` data/ ` | Sample datasets for testing |
55- | ` reports/ ` | Generated PDF reports |
54+ # Code formatting and linting
55+ ruff check .
5656
57- ---
57+ # Code formatting check
58+ ruff format --check .
59+
60+ # Type checking (Python 3.12)
61+ mypy tools/ agent/ tests/ --python-version 3.12
5862
59- ## 5. Coding standards
63+ # Security scan (exclude tests)
64+ bandit -r tools/ agent/ -ll -x /tests/
65+ ```
6066
61- | Topic | Mandatory rules |
62- | ---------- | ------------------------------------------------------------------------------------- |
63- | Format | Use ** ruff format** (line length 120) and ** ruff check** . |
64- | Typing | Provide complete hints. ` mypy --strict ` must succeed without unjustified ignores. |
65- | Tests | Every bug fix or feature requires unit tests. Minimum 85% coverage required. |
66- | Logs | Use the ` logging ` module, never ` print ` . |
67- | Security | Avoid ` eval ` , plain secrets and unclean temp files. Follow OWASP guidelines. |
68- | Imports | Use absolute imports for project modules. |
69- | Docstrings | Google style docstrings for all public functions/classes. |
67+ ### Testing Best Practices
68+ - Write tests first (TDD approach encouraged)
69+ - Use pytest fixtures for common setup
70+ - Mock external services (OpenAI, Ollama)
71+ - Test both success and failure paths
72+ - Use parameterized tests for multiple scenarios
73+ - Ensure tests are deterministic
7074
7175---
7276
73- ## 6. MCP-specific guidelines
77+ ## 4. Standard Development Workflow
7478
75- * Maintain MCP schema in ` static/schema.json ` for all tool changes
76- * Follow Model Context Protocol standards for tool implementation
77- * Ensure tools are stateless and idempotent
78- * Implement proper error handling with meaningful MCP error responses
79+ 1 . ** Analyze** the issue or requirement
80+ 2 . ** Plan** your approach (files to modify, tests to write)
81+ 3 . ** Check** existing code patterns and tests
82+ 4 . ** Implement** in small, testable units
83+ 5 . ** Run** all tests and quality checks
84+ 6 . ** Commit** following the convention below
85+ 7 . ** Push** and ensure CI passes
7986
8087---
8188
82- ## 7 . Commit convention
89+ ## 5 . Commit Convention
8390
8491```
8592<type>(<scope>): <short summary>
@@ -89,55 +96,40 @@ This project follows GitHub Actions CI/CD standards:
8996BREAKING CHANGE: <explanation>
9097```
9198
92- * Allowed types* : ` feat ` , ` fix ` , ` perf ` , ` refactor ` , ` test ` , ` docs ` , ` chore ` , ` ci ` .
93- * Scope* should point to a module (e.g. ` agent ` , ` tools ` , ` sql ` , ` csv ` , ` pdf ` ).
94- Make commits atomic: one change, one green test.
95-
96- ---
99+ Types: ` feat ` , ` fix ` , ` perf ` , ` refactor ` , ` test ` , ` docs ` , ` chore ` , ` ci `
100+ Scope: module name (e.g., ` agent ` , ` tools ` , ` sql ` , ` csv ` , ` pdf ` )
97101
98- ## 8. Pull request rules
99-
100- 1 . Create a branch named ` feat/<issue-id>-slug ` or ` fix/<issue-id>-slug ` .
101- 2 . Open a PR to ` main ` and include:
102- * ** What** : short summary
103- * ** Why** : business need or bug
104- * ** How** : technical approach (include diagrams if useful)
105- * ** Test Plan** : commands and test cases covered
106- * ** MCP Impact** : schema changes or tool behavior changes
107- 3 . Ensure all quality gates pass ** before** requesting review.
108- 4 . Update ` CHANGELOG.md ` when needed; add a new ` ## [Unreleased] ` section.
109- 5 . Link the PR to the related issue.
110-
111- ---
112-
113- ## 9. Standard workflow
102+ Example:
103+ ```
104+ feat(sql): add support for PostgreSQL connections
114105
115- 1 . ** Analyze** the issue or description.
116- 2 . ** Plan** your work (files, steps) and post the plan as a comment in the issue.
117- 3 . ** Check** existing tests for context and patterns.
118- 4 . ** Implement** in small units (functions < 30 lines).
119- 5 . Run all quality gates locally (section 2).
120- 6 . Commit following the convention (section 7).
121- 7 . Push the branch, open the PR and ensure CI is green.
122- 8 . Request review once all checks pass.
106+ - Implement PostgreSQL connection handler
107+ - Add tests for connection types
108+ - Update schema.json with new parameters
109+ ```
123110
124111---
125112
126- ## 10 . Tool development checklist
113+ ## 6 . Tool Development Guidelines
127114
128115When developing MCP tools:
129116
130117- [ ] Tool inherits from appropriate base class
131118- [ ] Implements required MCP protocol methods
132119- [ ] Returns properly formatted JSON responses
133120- [ ] Handles edge cases gracefully
134- - [ ] Includes comprehensive test coverage
135- - [ ] Updates schema.json if adding new tool
136- - [ ] Add tool documentation to README.md
121+ - [ ] Includes comprehensive tests
122+ - [ ] Updates ` static/schema.json ` if adding new tool
123+ - [ ] Adds tool documentation to README.md
124+
125+ MCP tools must be:
126+ - Stateless and idempotent
127+ - Properly error-handled with meaningful error responses
128+ - Well-documented with examples
137129
138130---
139131
140- ## 11 . Assistant development
132+ ## 7 . Assistant Module Guidelines
141133
142134When working on the Assistant module:
143135
@@ -150,39 +142,48 @@ When working on the Assistant module:
150142
151143---
152144
153- ## 12 . Quick troubleshooting
145+ ## 8 . Quick Troubleshooting
154146
155- | Failure | Immediate action |
156- | --------------------------- | ---------------------------------------------------------- |
157- | ImportError | Check if package is in requirements.txt and wheelhouse/ |
158- | Coverage < 85% | Add missing tests or justify the drop in the PR. |
159- | mypy errors | Add type hints or refactor the code. |
160- | Tool execution fails | Check schema.json alignment with implementation. |
161- | Assistant connection errors | Verify OPENAI_API_KEY or Ollama service status. |
162- | CI pipeline fails | Check GitHub Actions logs and fix locally first. |
147+ | Issue | Solution |
148+ | --------------------------- | -------------------------------------------------- |
149+ | ImportError | Check requirements.txt and wheelhouse/ directory |
150+ | mypy errors | Add type hints or refactor the code |
151+ | Tool execution fails | Check schema.json alignment with implementation |
152+ | Assistant connection errors | Verify OPENAI_API_KEY or Ollama service status |
153+ | CI pipeline fails | Check GitHub Actions logs and fix locally first |
163154
164155---
165156
166- ## 13. Testing guidelines
157+ ## 9. Important Technical Details
158+
159+ ### Database Support
160+ - SQLite (default) and PostgreSQL support
161+ - Connection strings handled via SQL tool
162+
163+ ### UI Framework
164+ - Gradio 5.29+ for web interface
165+ - Session-based state management
167166
168- * Write tests first (TDD approach encouraged)
169- * Use pytest fixtures for common setup
170- * Mock external services (OpenAI, Ollama)
171- * Test both success and failure paths
172- * Use parameterized tests for multiple scenarios
173- * Ensure tests are deterministic
167+ ### PDF Generation
168+ - ReportLab for PDF creation
169+ - Matplotlib for charts/visualizations
170+
171+ ### Model Support
172+ - OpenAI API integration
173+ - Ollama for local models
174+ - Dynamic model switching
174175
175176---
176177
177- ## 14. Environment considerations
178+ ## 10. CI/CD Pipeline
179+
180+ The project uses GitHub Actions for continuous integration:
178181
179- * The project supports Python 3.12+
180- * SQLite and PostgreSQL database support
181- * Gradio 5.29+ for UI
182- * ReportLab for PDF generation
183- * Ollama integration for local models
184- * All dependencies pre-downloaded in wheelhouse/
182+ - All PRs must pass automated checks
183+ - Quality gates run automatically
184+ - Branch protection requires PR reviews
185+ - Commits must follow conventional format
185186
186187---
187188
188- ** Remember:** * Clean , tested, documented code; no shortcuts . MCP tools must be reliable and stateless. Always ensure GitHub workflow compliance. *
189+ ** Remember:** Write clean , tested, documented code. MCP tools must be reliable and stateless. Prioritize code readability and maintainability.
0 commit comments