pi-auto
Integrates with OpenAI's Codex backend to provide usage data and automated provider switching based on load-balancing or high-availability strategies.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@pi-autoswitch to high-availability strategy"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
pi-auto
pi-auto is a Pi package that provides the pi-auto MCP server and a Skill for pi-coding-agent: usage data from @ccusage/pi and tools to switch the active provider by strategy — load-balancing (equalize usage across backends) or high-availability (fixed priority order).
Prerequisites
Install the following (globally) before using pi-auto:
Dependency | Description |
Pi CLI and coding agent (required for | |
Pi-agent usage tracking; used by the MCP server for usage data. | |
Alias | Shortcut to run |
MCP adapter for Pi (required to run MCP servers). | |
Cursor provider for Pi (optional; for CursorAI backend in usage/strategy). |
Example: install all globally and set the ccusage alias
# 1. Pi Coding Agent
npm install -g @mariozechner/pi-coding-agent
# 2. Usage tracking (for pi-auto)
npm install -g @ccusage/pi
# 3. Alias for ccusage (pick one: bash or zsh)
echo "alias ccusage='npx @ccusage/pi@latest'" >> ~/.bashrc
# echo "alias ccusage='npx @ccusage/pi@latest'" >> ~/.zshrc
# 4. Pi MCP adapter (run after Pi is installed)
pi install npm:pi-mcp-adapter
# 5. Cursor provider for Pi (optional)
pi install npm:@netandreus/pi-cursor-providerThen reload your shell (e.g. source ~/.bashrc or source ~/.zshrc) so ccusage is available.
Related MCP server: OpenAI Token Manager MCP
Install (Pi)
Prerequisite: Install the MCP adapter in Pi so it can run MCP servers:
pi install npm:pi-mcp-adapterInstall the pi-auto package (Skill is loaded automatically):
pi install npm:@netandreus/pi-autoOr from git:
pi install git:github.com/netandreus/pi-autoMCP config: Add the MCP server to pi’s config so the agent can call the tools.
~/.pi/agent/mcp.json (or your pi MCP config path):
If you installed via pi install npm:@netandreus/pi-auto, pi uses global npm; point to the installed package. Using the binary name (after a global npm install of the package):
{
"mcpServers": {
"pi-auto": {
"command": "pi-auto-mcp",
"lifecycle": "keep-alive",
"directTools": true
}
}
}Or with explicit path (replace GLOBAL_NPM_ROOT with the output of npm root -g):
{
"mcpServers": {
"pi-auto": {
"command": "node",
"args": ["GLOBAL_NPM_ROOT/@netandreus/pi-auto/dist/index.js"],
"lifecycle": "keep-alive",
"directTools": true
}
}
}Exposed tools: mcp_pi-auto_pi_get_usage, mcp_pi-auto_pi_suggest_provider, mcp_pi-auto_pi_set_provider, mcp_pi-auto_pi_get_provider, mcp_pi-auto_pi_get_strategy, mcp_pi-auto_pi_set_strategy, mcp_pi-auto_pi_get_priority, mcp_pi-auto_pi_set_priority.
Skill: The Skill is loaded automatically when the package is installed. Invoke with /skill:pi-auto or ask about usage, balancing cost, or switching provider.
MCP in Cursor Agent
To use the pi-auto MCP server from Cursor Agent (not only from Pi), connect the server, enable it, and allow its tools.
1. Connect MCP server to agent
Add the pi-auto MCP server to Cursor’s MCP config (e.g. ~/.cursor/mcp.json):
{
"mcpServers": {
"pi-auto": {
"command": "pi-auto-mcp",
"lifecycle": "keep-alive",
"directTools": true
}
}
}2. Enable the MCP server
The server may appear as “not loaded (needs approval)”. Enable and approve it:
agent mcp list
# pi-auto: not loaded (needs approval)
agent mcp enable pi-auto
# ✓ Enabled and approved MCP server: pi-autoCheck that tools are available:
agent mcp list-tools pi-auto
# Tools for pi-auto (8):
# - pi_get_priority ()
# - pi_get_provider (scope, projectPath)
# - pi_get_strategy ()
# - pi_get_usage (period)
# - pi_set_priority (priority)
# - pi_set_provider (provider, model, scope, projectPath)
# - pi_set_strategy (strategy)
# - pi_suggest_provider (period)3. Allow tools from this MCP
Ensure Cursor Agent is allowed to call pi-auto MCP tools. In ~/.cursor/cli-config.json, under permissions.allow, include:
"permissions": {
"allow": [
"Shell(ls)",
"Mcp(pi-auto:*)"
],
"deny": []
}Features
Tool | Description |
pi_get_usage | Current usage (tokens/cost) per backend (Claude Code, OpenAI Codex, CursorAI) for a given period (e.g. daily). |
pi_suggest_provider | Recommends |
pi_set_provider | Writes pi’s |
pi_get_provider | Reads current pi default provider and model. |
pi_get_strategy / pi_set_strategy | Get or set strategy: |
pi_get_priority / pi_set_priority | Get or set the HA priority order (e.g. |
Configuration
Requirements: Node 18+, and (for usage data) @ccusage/pi available via npx.
Environment
Variable | Description |
| Override pi-agent sessions directory (used when calling |
| Override path to pi’s global settings file (default: |
Server config
Strategy and priority are stored in ~/.pi/agent/pi-auto.json.
Example:
{
"strategy": "load-balancing",
"priority": ["codex", "claude-code", "cursorai"],
"defaultModels": {
"claude-code": { "provider": "anthropic", "model": "claude-sonnet-4-20250514" },
"codex": { "provider": "openai", "model": "gpt-4o" },
"cursorai": { "provider": "cursor", "model": "auto" }
}
}Field | Description |
strategy |
|
priority | Ordered list of backend ids for HA; first is preferred. Valid ids: |
defaultModels | Optional overrides for provider/model per backend (must match your installed pi providers). |
Usage strategies
Load-balancing —
pi_suggest_providerpicks the backend with the lowest current usage (total tokens). Usepi_get_usageto see per-backend totals; then callpi_suggest_providerand optionallypi_set_providerto switch.High-availability —
pi_suggest_providerreturns the first backend inpriority(and its default model). Usepi_set_priorityto change the order (e.g. prefer Codex, then Claude, then CursorAI).
When you need to balance cost or ensure a preferred provider, use the pi-auto tools: get/set strategy and priority, get current provider, get usage, suggest a provider, and set it with pi_set_provider.
Backend mapping
Usage from @ccusage/pi (with --json --breakdown) is mapped to three backends:
Backend | Source |
Claude Code |
|
OpenAI Codex |
|
CursorAI |
|
You can override mapping and default models in ~/.pi/agent/pi-auto.json if your setup differs.
Publishing (npm)
To publish to npmjs.com:
Log in:
npm login(use an account with access to the@netandreusscope).Bump version in
package.json(e.g.0.1.0→0.1.1).Build and publish:
npm publish
(runsprepublishOnly→yarn build, then publishes; scoped package is published as public viapublishConfig.access.)
To see what will be included: npm pack --dry-run.
License
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/netandreus/pi-auto'
If you have feedback or need assistance with the MCP directory API, please join our Discord server