Skip to content

Use in Claude Code

Deprecated: MCP-for-Stata's built-in agent mode is marked with FutureWarning since v1.16.x and will be removed in a future release. New workflows should use MCP server mode (stata-mcp server or stata-mcp install -c <client>) and rely on the host AI client's native agent capabilities instead.

We are very excited to write this document about Claude Code with MCP-for-Stata. At my daily research, Claude Code is one of the tools I use most often.

If you have not installed it, you can visit Claude Code to install it.

Requirements:
- Stata 17+
- uv or python 3.11+
- Claude Code

Quickly Start

First, check whether MCP-for-Stata is compatible with your device by verifying each requirement.

uvx stata-mcp doctor

Then, create your project. We suggest creating all the projects in the same directory. For example, we use ~/Documents/StataProjects as the project directory.

cd ~/Documents/StataProjects
claude mcp add stata-mcp --env STATA_MCP__CWD=$(pwd) --scope project -- uvx --directory $(pwd) stata-mcp

Advice: Please make sure the directory without any special characters like whitespace, emoji or Chinese characters.

Now the project has been created successfully. The project structure is as follows:

my_first_project/            # Project directory
├── .statamcp/               # All the files generated by MCP-for-Stata
│   ├── stata-mcp-dofile/    # do-files
│   ├── stata-mcp-log/       # log files
│   ├── stata-mcp-result/    # Some command (like `outreg2`) results saved here
│   └── stata-mcp-tmp/       # Temporary files, like data info description
│   └── .gitignore           # git ignore file
└── CLAUDE.md                # The global instructions to limit the project