Full MCP documentation:
docs/MCP_DOCUMENTATION.mddocs/INTEGRATION_GUIDE.md(for third-party integrators)docs/ENGINEERING_REVIEW.md(review findings + refactor notes)docs/MCP_IMPLEMENTATION_CHECKLIST.md(checklist compliance status)
This repo is organized into 3 clean parts:
application/- real application layer with SQLite database and seed datamcp_server/- MCP server layer exposing toolsui/+scripts/- UI testing and CLI smoke tests
Each part has a clear responsibility:
applicationcan be tested directly without MCP.mcp_serverdoes not contain business tables; it callsapplication.scriptsprovides CLI smoke tests and MCP prompt checklist.
application/db.py: create SQLite tables and seed sample dataapplication/service.py: application business reads (account/lead/search)application/summary.py: simple rule-based 360 summary logicmcp_server/server.py: MCP tools (health_check,search_entities,get_account_360,get_lead_360)scripts/smoke_test.py: end-to-end smoke test (AI agent simulation)scripts/agent_orchestrator.py: deterministic AI agent orchestration examplescripts/mcp_prompts.md: prompts for MCP client demoui/: React + Tailwind testing UI
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
cp .env.example .envThe application layer is SQLite-based (application/) and is auto-initialized by the MCP server.
If DB file does not exist, it is created and seeded automatically.
Default database:
application/data/abc_crm.db(orAPP_DB_PATHfrom env)
Optional: inspect seeded data manually from SQLite:
sqlite3 application/data/abc_crm.db "SELECT id, name FROM accounts;"
sqlite3 application/data/abc_crm.db "SELECT id, name, status FROM leads;"Start MCP server (stdio transport):
PYTHONPATH=. python -m mcp_server.serverAvailable tools:
health_checksearch_entities(query, entity_type)get_account_360(account_id)get_lead_360(lead_id)
What each tool does:
health_check: confirms server is up and DB path is configuredsearch_entities: resolves user text to account/lead IDsget_account_360: returns structured account summary with risks/actions/sourcesget_lead_360: returns structured lead summary with risks/actions/sources
Run end-to-end local usage script:
PYTHONPATH=. python scripts/smoke_test.pyRun deterministic AI-agent orchestration example:
PYTHONPATH=. python scripts/agent_orchestrator.pyThis script simulates AI-agent style usage:
- Agent checks
health_check - Agent resolves entity id with
search_entities - Agent calls
get_account_360orget_lead_360 - Agent reads
open_risks,next_actions, andsourcesfor grounded response
Use prompts from:
scripts/mcp_prompts.md
Suggested order:
- Run
health_check - Search for account/lead IDs
- Fetch 360 summary
- Validate output fields and source references
- Response has required schema fields:
entity,summary,status,health,open_risks,recent_activity,next_actions,sources
next_actionscontains at least 3 actionssourcesincludes record IDs used to ground output- Invalid input returns safe error format (no traceback)
PYTHONPATH=. python -m unittest discover -s tests -p "test_*.py"- Setup completes without errors (
venv, install,.env) - DB file is created at
application/data/abc_crm.db - MCP server starts successfully
scripts/smoke_test.pyprints all 4 steps with valid JSON- Unit tests pass
- MCP prompts in
scripts/mcp_prompts.mdwork in client
This repo includes a basic UI for manual testing:
ui/(React + Tailwind + Vite)
From project root:
PYTHONPATH=. uvicorn application.test_api:app --reload --port 8000In a second terminal:
cd ui
npm install
npm run devOpen the local URL shown by Vite (usually http://127.0.0.1:5173).
From repo root:
./be.sh # backend API
./fe.sh # frontend UI
./mcp.sh # MCP server (stdio)
./all.sh # run all three together (with logs)all.sh writes logs to .run_logs/.
- Click
Run health_check - Run
search_entitiesfor account/lead - Run
get_account_360 - Run
get_lead_360 - Open
Test Statustab and clickRun Unit TestsandRun Smoke Test - Validate JSON includes:
entity,summary,status,health,open_risks,recent_activity,next_actions,sources