# Work with an AI agent

Claude Code, Cursor, and Codex know MainPath's rules and talk to the platform directly through the agent plugin.

> Source: https://www.mainpath.ai/en/docs/work-with-ai-agents/

In a platform project, an AI agent such as Claude Code, Cursor, or Codex follows the rules from the agent plugin and talks to MainPath through MCP. Always open it in the parent project folder `~/Documents/MainPath/<organization>/<project>/` so that it sees all repositories.

## Install the agent plugin

Skills, rules, and MCP ship inside the mp CLI, not as an npm package. The only prerequisite is the CLI:

```bash
curl -fsSL https://www.application-platform.com/install.sh | sh
mp agent install
mp login
```

On Windows, in PowerShell: `irm https://www.application-platform.com/install.ps1 | iex`. `mp login`, `mp doctor`, and a CLI update run `agent install` as well. The CLI places the plugin with Cursor, Claude Code, and Codex and writes the **absolute path** to `mp` into the user MCP file. Afterwards you reload the editor or restart the agent.

The plugin brings the skills `setup-and-login`, `create-project`, `import-existing-project`, `run-local`, `git-and-pipelines`, and `report-blocker`, slash commands such as `/create-project`, and the MCP server `application-platform` via `mp mcp serve`. Details are in [CLI and agent plugin]({{< relref "cli-and-agent-plugin" >}}).

## What you can ask the agent

- "Import this project into my MainPath account." The agent detects the stack, creates the project, and pushes your code, see [Bring in an existing project]({{< relref "import-existing-project" >}}).
- "Create a new MainPath project with a Next.js app and a NestJS backend and clone it." The agent creates the project from a template, waits for the setup, and clones it.
- "Start the backend locally." The agent runs `mp run-local` in the backend repository.

## Which rules the agent follows

The plugin requires starting applications with `mp run-local`, never editing `.gitlab-ci.yml` and `env/*.generated.env` by hand, writing your own values to `env/*.custom.env`, never committing or printing secrets, working in the application repository instead of `local-configuration`, taking runtimes from `.tool-versions`, and storing backend uploads under `./upload`.

After finishing the work, the agent commits and pushes on `main` or a feature branch (`feat/…`, `fix/…`, `chore/…`) and waits with `platform_pipelines_wait` for the pipeline of **that** commit.

## Add your own rules

Project-specific rules, such as preferred libraries, go in an `AGENTS.md` in the application repository, not in the `local-configuration` MainPath generates. See [Your own rules for AI agents]({{< relref "ai-instructions" >}}).

## Limits

The MCP server runs locally through the mp CLI, so cloud agents cannot use it; if the agent reports that you are not signed in, type `mp login`. If creating or importing fails, the agent does not work around the error with its own Git commands. If it is blocked by the platform, it calls `platform_agent_report`.

You [save and publish]({{< relref "save-and-publish" >}}) the agent's changes.

