opencode-catpaw-auth
v1.3.2
Published
CatPaw AI provider plugin for OpenCode - Auto-auth from mcopilot-cli config
Downloads
33
Maintainers
Readme
@zu1k/opencode-catpaw-auth
CatPaw AI provider plugin for OpenCode - Auto-auth from mcopilot-cli config
Features
- Zero-config auth: Automatically loads API key from
~/.config/mcopilot-cli/.config.yaml - Multi-model support: LongCat-Flash-Chat, kimi-k2.5, glm-5, MiniMax-M2.5, claude-sonnet-4.5
- Auto header injection: Automatically injects
x-api-keyandx-working-dirheaders - OpenAI compatible: Uses
@ai-sdk/openai-compatibleadapter
Installation
Method 1: npm (Recommended)
Add the plugin to your OpenCode configuration:
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["@zu1k/opencode-catpaw-auth"]
}Method 2: Local Development
git clone https://github.com/zu1k/opencode-catpaw-auth.git
cd opencode-catpaw-auth
bun installThen use file:// protocol:
{
"plugin": ["file:///absolute/path/to/opencode-catpaw-auth"]
}Configuration
1. Ensure mcopilot-cli config exists
The plugin automatically reads the AUTHORIZATION field from ~/.config/mcopilot-cli/.config.yaml:
# ~/.config/mcopilot-cli/.config.yaml
AUTHORIZATION: "your-api-key-here"
# other configurations...2. Connect Provider
Start OpenCode:
opencodeRun the connect command:
/connectSelect CatPaw AI provider, then choose "Auto-config from mcopilot-cli" auth method.
3. Select Model
/modelsChoose from CatPaw AI models:
- LongCat Flash Chat - Fast response
- Kimi K2.5 - Long context support (256K)
- GLM-5 - Zhipu AI model
- MiniMax M2.5 - MiniMax model
- Claude Sonnet 4.5 - Anthropic Claude (200K context)
Supported Models
| Model ID | Name | Context Length | Output Length |
|---------|------|---------------|---------------|
| LongCat-Flash-Chat | LongCat Flash Chat | 128K | 8K |
| kimi-k2.5 | Kimi K2.5 | 256K | 8K |
| glm-5 | GLM-5 | 128K | 8K |
| MiniMax-M2.5 | MiniMax M2.5 | 128K | 8K |
| claude-sonnet-4.5 | Claude Sonnet 4.5 | 200K | 8K |
Troubleshooting
1. Check config file
Ensure the config file exists and contains AUTHORIZATION:
cat ~/.config/mcopilot-cli/.config.yaml2. Check plugin loading
View logs when starting OpenCode:
opencode --verbose3. Test API manually
curl https://mcli.sankuai.com/v1/models \
-H "x-api-key: $(grep AUTHORIZATION ~/.config/mcopilot-cli/.config.yaml | awk '{print $2}')" \
-H "x-working-dir: $HOME"Common Issues
Q: Plugin shows "Failed to load API key"
- Check if
~/.config/mcopilot-cli/.config.yamlexists - Check if file contains
AUTHORIZATIONfield - Check file permissions
Q: Empty model list
- Ensure
/connectwas run and CatPaw AI was selected - Check network connection
Q: 401/403 errors
- API key may be expired, try updating config file
- Check if
x-working-dirheader is correct
Development
Project Structure
opencode-catpaw-auth/
├── index.ts # Plugin entry
├── package.json # Dependencies
├── tsconfig.json # TypeScript config
├── src/
│ ├── plugin.ts # Core plugin logic
│ ├── config.ts # Config file reading
│ ├── request.ts # Request handling
│ └── types.ts # Type definitions
└── README.mdLocal Testing
- Install dependencies:
bun install- Type check:
bun run check- Use
file://protocol in OpenCode config to reference local path
Scripts
bun run dev # Development mode with watch
bun run check # TypeScript type check
bun run clean # Clean dependenciesHow It Works
This plugin follows the OpenCode plugin architecture:
- Config Hook: Registers CatPaw as a provider with model definitions
- Auth Loader: Reads API key from mcopilot-cli config file
- Custom Fetch: Intercepts requests to
mcli.sankuai.comand injects required headers
Inspired by opencode-gemini-auth.
License
MIT © zu1k
