Model Context Protocol

Use Copilot from Claude, Cursor, Codex, Grok…

The Bantuity MCP server connects coding tools to your Copilot projects: upload data, generate do-files, and run licensed local Stata with the same pipeline as the desktop application.

What MCP gives you

Coding agents stay in the IDE. Stata still runs only on your machine via the desktop connector.

Full project access

Projects, datasets, do-files, Bantuity Check, cleaning, executions, and pipeline history through MCP tools in your IDE.

Local Stata execution

Start the Stata service in Bantuity Studio Light. Analysis runs only on your licensed Stata; jobs wait if the service is offline.

Automatic recovery

Failed runs can diagnose common issues, patch the do-file, and re-run. Use get_pipeline to review the trail.

Install the MCP server

One-time setup on the machine that runs your coding tool.

  1. Clone or open the stata-copilot repo (folder mcp/).
  2. Install with Python 3.10+:
    cd path\to\stata-copilot\mcp
    python -m pip install -e .
  3. Confirm:
    bantuity-mcp
    # or: python -m bantuity_mcp
    The process waits on stdio — that is correct for MCP hosts.

Optional environment variables in mcp/.env: BANTUITY_API_URL, BANTUITY_ADMIN_KEY, and BANTUITY_PROJECT_ID. See the package README for production values.

Connect your coding tool

After pip install -e ., use the short form. Without install, use the Python + cwd form below.

Claude Code / Claude Desktop / Cursor

Add to .mcp.json, Claude Desktop config, or Cursor MCP settings:

{
  "mcpServers": {
    "bantuity": {
      "command": "bantuity-mcp",
      "env": {
        "BANTUITY_API_URL": "https://stata-copilot-api.onrender.com",
        "BANTUITY_ADMIN_KEY": "123456"
      }
    }
  }
}

Project template also ships as stata-copilot/.mcp.json and mcp/examples/*.json.

Grok, Codex, other stdio hosts

Same idea — command + env. Fallback without global install:

{
  "mcpServers": {
    "bantuity": {
      "command": "python",
      "args": ["-m", "bantuity_mcp"],
      "cwd": "C:\\Users\\YOU\\Desktop\\stata-copilot\\mcp",
      "env": {
        "PYTHONPATH": "src",
        "BANTUITY_API_URL": "https://stata-copilot-api.onrender.com",
        "BANTUITY_ADMIN_KEY": "123456"
      }
    }
  }
}

Set cwd to your real stata-copilot\\mcp path.

How to use it (agent flow)

  1. Start Stata — open Studio Light → Start the local Stata service.
  2. Check — agent calls connector_status (online?).
  3. Dataupload_dataset with a local CSV/DTA path, or use an existing project.
  4. Analyzebantuity_check, or chat(prompt=…, run=true, wait=true), or run_stata_code.
  5. Inspectget_execution / get_pipeline for logs, interpretation, and recovery attempts.

One-shot helper: analyze_workflow(prompt, file_path, run=true) uploads (optional), chats, and waits for Stata + recovery.

Tools reference

Full list and env vars: mcp/README.md

Connect

  • health
  • whoami
  • connector_status

Projects & data

  • list_projects
  • create_project
  • ensure_project
  • upload_dataset
  • list_datasets
  • activate_dataset

Analyze on local Stata

  • chat
  • run_stata_code
  • bantuity_check
  • clean_dataset
  • analyze_workflow

Runs & recovery

  • get_execution
  • wait_execution
  • list_executions
  • get_pipeline
  • read_project_file
  • dashboard_recent

Ready?

Install MCP for your IDE, keep the desktop Stata service running for live runs, or use the browser workspace for the same pipeline.