pal-mcp-server-multi-model-orchestration
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChinesePAL MCP Server: Multi-Model AI Orchestration
PAL MCP Server:多模型AI编排
Skill by ara.so — MCP Skills collection.
PAL MCP (Provider Abstraction Layer) is an MCP server that enables AI coding assistants like Claude Code, Cursor, and Codex CLI to orchestrate multiple AI models within a single workflow. It provides conversation continuity across models, CLI-to-CLI bridging, and specialized workflows for code review, debugging, planning, and security auditing.
由ara.so开发的Skill — MCP Skills合集。
PAL MCP(Provider Abstraction Layer,提供商抽象层)是一款MCP服务器,可让Claude Code、Cursor和Codex CLI等AI代码助手在单一工作流中编排多个AI模型。它支持跨模型的对话上下文延续、CLI到CLI的桥接功能,以及针对代码审查、调试、规划和安全审计的专用工作流。
What PAL MCP Does
PAL MCP的功能
- Multi-Model Orchestration: Coordinate Gemini, OpenAI, Anthropic, Grok, Azure, Ollama, and OpenRouter models in one conversation
- Conversation Threading: Full context flows across tools and models - later models remember what earlier ones said
- CLI Bridging (): Spawn isolated CLI instances (Gemini CLI, Codex CLI, Claude Code) as subagents with specialized roles
clink - Context Isolation: Run separate investigations without polluting your primary workspace
- Extended Context Windows: Delegate to models with larger context (Gemini's 1M tokens, O3's 200K tokens)
- Specialized Workflows: Built-in tools for code review, debugging, planning, security audits, and pre-commit checks
- 多模型编排:在一次对话中协调Gemini、OpenAI、Anthropic、Grok、Azure、Ollama和OpenRouter模型
- 对话上下文延续:完整上下文在工具和模型间流转——后续模型能记住之前模型的对话内容
- CLI桥接():生成独立的CLI实例(Gemini CLI、Codex CLI、Claude Code)作为具有特定角色的子代理
clink - 上下文隔离:运行独立的调查任务,不会污染你的主工作区
- 扩展上下文窗口:将任务委托给具有更大上下文窗口的模型(Gemini的100万token、O3的20万token)
- 专用工作流:内置代码审查、调试、规划、安全审计和提交前检查工具
Installation
安装
Prerequisites
前置要求
- Python 3.10+
- Git
- uv package manager
- Python 3.10+
- Git
- uv包管理器
Option A: Clone and Automatic Setup (Recommended)
选项A:克隆并自动设置(推荐)
bash
git clone https://github.com/BeehiveInnovations/pal-mcp-server.git
cd pal-mcp-serverbash
git clone https://github.com/BeehiveInnovations/pal-mcp-server.git
cd pal-mcp-serverHandles setup, config, API keys from environment
处理设置、配置、从环境变量读取API密钥
Auto-configures Claude Desktop, Claude Code, Gemini CLI, Codex CLI
自动配置Claude Desktop、Claude Code、Gemini CLI、Codex CLI
./run-server.sh
undefined./run-server.sh
undefinedOption B: Instant Setup with uvx
选项B:使用uvx快速设置
Add to or :
~/.claude/settings.json.mcp.jsonjson
{
"mcpServers": {
"pal": {
"command": "bash",
"args": ["-c", "for p in $(which uvx 2>/dev/null) $HOME/.local/bin/uvx /opt/homebrew/bin/uvx /usr/local/bin/uvx uvx; do [ -x \"$p\" ] && exec \"$p\" --from git+https://github.com/BeehiveInnovations/pal-mcp-server.git pal-mcp-server; done; echo 'uvx not found' >&2; exit 1"],
"env": {
"PATH": "/usr/local/bin:/usr/bin:/bin:/opt/homebrew/bin:~/.local/bin",
"GEMINI_API_KEY": "",
"OPENAI_API_KEY": "",
"XAI_API_KEY": "",
"OPENROUTER_API_KEY": "",
"DISABLED_TOOLS": "analyze,refactor,testgen,secaudit,docgen,tracer",
"DEFAULT_MODEL": "auto"
}
}
}
}添加到或:
~/.claude/settings.json.mcp.jsonjson
{
"mcpServers": {
"pal": {
"command": "bash",
"args": ["-c", "for p in $(which uvx 2>/dev/null) $HOME/.local/bin/uvx /opt/homebrew/bin/uvx /usr/local/bin/uvx uvx; do [ -x \"$p\" ] && exec \"$p\" --from git+https://github.com/BeehiveInnovations/pal-mcp-server.git pal-mcp-server; done; echo 'uvx not found' >&2; exit 1"],
"env": {
"PATH": "/usr/local/bin:/usr/bin:/bin:/opt/homebrew/bin:~/.local/bin",
"GEMINI_API_KEY": "",
"OPENAI_API_KEY": "",
"XAI_API_KEY": "",
"OPENROUTER_API_KEY": "",
"DISABLED_TOOLS": "analyze,refactor,testgen,secaudit,docgen,tracer",
"DEFAULT_MODEL": "auto"
}
}
}
}Required API Keys
所需API密钥
Set at least one provider's API key as environment variables or in :
.envbash
undefined至少设置一个提供商的API密钥作为环境变量或在文件中:
.envbash
undefinedChoose one or more providers
选择一个或多个提供商
export GEMINI_API_KEY=your_key_here
export OPENAI_API_KEY=your_key_here
export OPENROUTER_API_KEY=your_key_here
export XAI_API_KEY=your_key_here
export AZURE_OPENAI_KEY=your_key_here
export GEMINI_API_KEY=your_key_here
export OPENAI_API_KEY=your_key_here
export OPENROUTER_API_KEY=your_key_here
export XAI_API_KEY=your_key_here
export AZURE_OPENAI_KEY=your_key_here
For local models - no key needed
本地模型无需密钥
Just run: ollama serve
只需运行:ollama serve
undefinedundefinedCore Tools
核心工具
pal
- Multi-Model Orchestration
palpal
- 多模型编排
palThe main tool for querying multiple AI models with conversation continuity.
python
undefined用于查询多个AI模型并保持对话上下文延续的主工具。
python
undefinedBasic usage - auto model selection
基础用法 - 自动选择模型
"Use pal to analyze this authentication code for security issues"
"Use pal to analyze this authentication code for security issues"
Specific model
指定模型
"Use pal with gemini-pro to review the API design"
"Use pal with gemini-pro to review the API design"
Multiple models for consensus
多模型达成共识
"Get consensus using pal with gpt-5 and gemini-pro: should we use REST or GraphQL?"
"Get consensus using pal with gpt-5 and gemini-pro: should we use REST or GraphQL?"
Vision analysis
视觉分析
"Use pal with gemini-pro to analyze this architecture diagram"
**Key Parameters:**
- `prompt` (required): The instruction for the AI model
- `model` (optional): Specific model to use (e.g., "gemini-pro", "gpt-5", "o3-mini")
- `conversation_id` (optional): Continue a previous conversation thread
- `system_prompt` (optional): Custom system instructions
- `max_tokens` (optional): Response length limit
- `temperature` (optional): 0.0-2.0, controls randomness
**Common Models:**
- `gemini-pro` - Deep thinking, 1M token context
- `gemini-flash` - Fast responses
- `gpt-5` - Strong reasoning
- `o3-mini` - Fast OpenAI reasoning
- `grok-beta` - X.AI's model
- `llama3` - Local via Ollama"Use pal with gemini-pro to analyze this architecture diagram"
**关键参数:**
- `prompt`(必填):AI模型的指令
- `model`(可选):要使用的特定模型(例如"gemini-pro"、"gpt-5"、"o3-mini")
- `conversation_id`(可选):延续之前的对话线程
- `system_prompt`(可选):自定义系统指令
- `max_tokens`(可选):响应长度限制
- `temperature`(可选):0.0-2.0,控制随机性
**常用模型:**
- `gemini-pro` - 深度思考,100万token上下文
- `gemini-flash` - 快速响应
- `gpt-5` - 强大推理能力
- `o3-mini` - OpenAI快速推理模型
- `grok-beta` - X.AI的模型
- `llama3` - 通过Ollama运行的本地模型clink
- CLI-to-CLI Bridge
clinkclink
- CLI到CLI桥接
clinkSpawn external AI CLIs as subagents with isolated contexts and specialized roles.
python
undefined生成外部AI CLI作为具有隔离上下文和特定角色的子代理。
python
undefinedSpawn Gemini CLI subagent with code reviewer role
生成具有代码审查员角色的Gemini CLI子代理
"Use clink with gemini codereviewer to audit the auth module"
"Use clink with gemini codereviewer to audit the auth module"
Codex subagent for isolated investigation
用于独立调查的Codex子代理
"Use clink with codex to investigate the memory leak in isolation"
"Use clink with codex to investigate the memory leak in isolation"
Custom role with system prompt
带系统提示的自定义角色
"Use clink with gemini role='security-expert' system_prompt='Focus on OWASP Top 10' to scan for vulnerabilities"
"Use clink with gemini role='security-expert' system_prompt='Focus on OWASP Top 10' to scan for vulnerabilities"
Multi-step workflow
多步骤工作流
"""
- Use consensus with gpt-5 and gemini-pro to decide: add dark mode or offline support next
- Continue with clink gemini - implement the recommended feature """
**Key Parameters:**
- `cli_name` (required): "gemini", "codex", or "claude"
- `prompt` (required): Task for the subagent
- `role` (optional): "planner", "codereviewer", "debugger", or custom
- `system_prompt` (optional): Custom instructions for the subagent
- `timeout` (optional): Max execution time in seconds
**Benefits:**
- Fresh context window for heavy tasks
- Parallel investigations without context pollution
- Role specialization (planner vs. implementer)
- Full CLI capabilities (web search, file access, MCP tools)"""
- Use consensus with gpt-5 and gemini-pro to decide: add dark mode or offline support next
- Continue with clink gemini - implement the recommended feature """
**关键参数:**
- `cli_name`(必填):"gemini"、"codex"或"claude"
- `prompt`(必填):子代理的任务
- `role`(可选):"planner"、"codereviewer"、"debugger"或自定义角色
- `system_prompt`(可选):子代理的自定义指令
- `timeout`(可选):最大执行时间(秒)
**优势:**
- 为重任务提供全新的上下文窗口
- 并行调查不会污染上下文
- 角色专业化(规划者 vs 实现者)
- 完整的CLI功能(网页搜索、文件访问、MCP工具)codereview
- Multi-Pass Code Analysis
codereviewcodereview
- 多轮代码分析
codereviewSystematic code review workflow with confidence tracking and multi-model consensus.
python
undefined具有置信度跟踪和多模型共识的系统化代码审查工作流。
python
undefinedBasic code review
基础代码审查
"Perform a codereview of the payment processing module"
"Perform a codereview of the payment processing module"
Multi-model review
多模型审查
"Use codereview with gemini-pro and o3 to review the authentication system"
"Use codereview with gemini-pro and o3 to review the authentication system"
With planning and implementation
包含规划和实现
"""
Perform a codereview using gemini-pro and o3, then:
- Use planner to generate a detailed fix plan
- Implement the critical and high-priority fixes
- Do a final precommit check """
**Workflow:**
1. Initial code exploration (confidence: exploring)
2. Pattern identification (confidence: low → medium)
3. Issue collection with severity levels (critical, high, medium, low)
4. Multi-model validation if specified
5. Consolidated report with actionable recommendations"""
Perform a codereview using gemini-pro and o3, then:
- Use planner to generate a detailed fix plan
- Implement the critical and high-priority fixes
- Do a final precommit check """
**工作流:**
1. 初始代码探索(置信度:探索中)
2. 模式识别(置信度:低→中)
3. 收集带有严重级别的问题(关键、高、中、低)
4. 若指定则进行多模型验证
5. 生成包含可操作建议的整合报告debughelp
- Systematic Debugging Assistant
debughelpdebughelp
- 系统化调试助手
debughelpRoot cause analysis with hypothesis tracking and confidence scoring.
python
undefined带有假设跟踪和置信度评分的根本原因分析工具。
python
undefinedDebug with error context
结合错误上下文进行调试
"Use debughelp to investigate why the API returns 500 on user creation"
"Use debughelp to investigate why the API returns 500 on user creation"
Multi-model debugging
多模型调试
"Debug this memory leak with o3, then verify the fix with gemini-pro"
**Workflow:**
1. Error symptom collection
2. Hypothesis generation with confidence levels
3. Systematic investigation
4. Root cause identification
5. Fix recommendations with validation steps"Debug this memory leak with o3, then verify the fix with gemini-pro"
**工作流:**
1. 错误症状收集
2. 生成带有置信度级别的假设
3. 系统化调查
4. 根本原因识别
5. 提供修复建议和验证步骤planner
- Strategic Planning Workflow
plannerplanner
- 战略规划工作流
plannerBreak down complex tasks into phased, actionable plans.
python
undefined将复杂任务分解为分阶段的可执行计划。
python
undefinedMigration planning
迁移规划
"Use planner to create a strategy for migrating from REST to GraphQL"
"Use planner to create a strategy for migrating from REST to GraphQL"
Multi-model consensus planning
多模型共识规划
"Use planner with gpt-5 and gemini-pro to design the microservices architecture"
**Workflow:**
1. Goal clarification
2. Constraint identification
3. Phase breakdown
4. Risk assessment
5. Deliverable definition with success criteria"Use planner with gpt-5 and gemini-pro to design the microservices architecture"
**工作流:**
1. 目标明确
2. 约束识别
3. 阶段分解
4. 风险评估
5. 定义带有成功标准的交付物precommit
- Pre-Commit Validation
precommitprecommit
- 提交前验证
precommitFinal validation before committing changes, aware of previous code review context.
python
undefined提交变更前的最终验证,可感知之前的代码审查上下文。
python
undefinedAfter implementing fixes
实现修复后
"Perform a precommit check on the authentication changes"
"Perform a precommit check on the authentication changes"
With specific model
使用特定模型
"Use precommit with gemini-pro to validate the security fixes"
**Checks:**
- Regression risk assessment
- Security implications
- Performance impact
- Test coverage validation
- Documentation updates"Use precommit with gemini-pro to validate the security fixes"
**检查内容:**
- 回归风险评估
- 安全影响
- 性能影响
- 测试覆盖率验证
- 文档更新Configuration
配置
Environment Variables
环境变量
bash
undefinedbash
undefinedProvider API Keys
提供商API密钥
GEMINI_API_KEY=your_key_here
OPENAI_API_KEY=your_key_here
OPENROUTER_API_KEY=your_key_here
XAI_API_KEY=your_key_here
GEMINI_API_KEY=your_key_here
OPENAI_API_KEY=your_key_here
OPENROUTER_API_KEY=your_key_here
XAI_API_KEY=your_key_here
Azure OpenAI
Azure OpenAI
AZURE_OPENAI_KEY=your_key_here
AZURE_OPENAI_ENDPOINT=https://your-resource.openai.azure.com/
AZURE_OPENAI_DEPLOYMENT=gpt-4o
AZURE_OPENAI_KEY=your_key_here
AZURE_OPENAI_ENDPOINT=https://your-resource.openai.azure.com/
AZURE_OPENAI_DEPLOYMENT=gpt-4o
Model Settings
模型设置
DEFAULT_MODEL=auto # or specific model like "gemini-pro"
DEFAULT_TEMPERATURE=0.7
DEFAULT_MAX_TOKENS=8000
DEFAULT_MODEL=auto # 或特定模型如"gemini-pro"
DEFAULT_TEMPERATURE=0.7
DEFAULT_MAX_TOKENS=8000
Tool Configuration
工具配置
DISABLED_TOOLS=analyze,refactor,testgen,secaudit,docgen,tracer
DISABLED_TOOLS=analyze,refactor,testgen,secaudit,docgen,tracer
Logging
日志
LOG_LEVEL=INFO # DEBUG, INFO, WARNING, ERROR
LOG_FILE=pal-mcp.log
undefinedLOG_LEVEL=INFO # DEBUG, INFO, WARNING, ERROR
LOG_FILE=pal-mcp.log
undefinedModel Aliases
模型别名
PAL supports shorthand aliases for common models:
python
undefinedPAL支持常用模型的简写别名:
python
undefinedThese are equivalent
以下用法等效
"use pal with gemini-pro"
"use pal with gemini-2.0-flash-exp"
"use pal with gemini-pro"
"use pal with gemini-2.0-flash-exp"
Aliases
别名
"gemini-flash" → "gemini-2.0-flash-exp"
"gemini-pro" → "gemini-2.0-pro-exp"
"gpt-5" → "gpt-5-turbo"
"o3" → "o3-mini"
undefined"gemini-flash" → "gemini-2.0-flash-exp"
"gemini-pro" → "gemini-2.0-pro-exp"
"gpt-5" → "gpt-5-turbo"
"o3" → "o3-mini"
undefinedCursor & VS Code Integration
Cursor与VS Code集成
Create in your project root:
.mcp.jsonjson
{
"mcpServers": {
"pal": {
"command": "uv",
"args": [
"--directory",
"/path/to/pal-mcp-server",
"run",
"pal-mcp-server"
],
"env": {
"GEMINI_API_KEY": "",
"OPENAI_API_KEY": ""
}
}
}
}在项目根目录创建:
.mcp.jsonjson
{
"mcpServers": {
"pal": {
"command": "uv",
"args": [
"--directory",
"/path/to/pal-mcp-server",
"run",
"pal-mcp-server"
],
"env": {
"GEMINI_API_KEY": "",
"OPENAI_API_KEY": ""
}
}
}
}Real-World Workflows
实际工作流
Multi-Model Code Review Pipeline
多模型代码审查流水线
python
undefinedpython
undefinedFull code review → planning → implementation → validation
完整代码审查→规划→实现→验证
"""
- Perform a codereview of the payment module using gemini-pro and o3
- Use planner to break down the critical and high-priority fixes
- Implement the fixes for issues marked 'critical'
- Use precommit with gemini-pro to validate before committing """
**What happens:**
1. Claude walks the code, identifying issues
2. Gemini Pro performs deep analysis (1M token context)
3. O3 validates findings with strong reasoning
4. Consolidated report with severity levels
5. Planner creates phased fix strategy
6. Claude implements critical fixes
7. Gemini Pro validates changes with full context of original review"""
- Perform a codereview of the payment module using gemini-pro and o3
- Use planner to break down the critical and high-priority fixes
- Implement the fixes for issues marked 'critical'
- Use precommit with gemini-pro to validate before committing """
**执行流程:**
1. Claude遍历代码,识别问题
2. Gemini Pro执行深度分析(100万token上下文)
3. O3通过强大推理验证发现的问题
4. 生成带有严重级别的整合报告
5. Planner创建分阶段修复策略
6. Claude实现关键修复
7. Gemini Pro结合原始审查的完整上下文验证变更Context Revival After Reset
重置后的上下文恢复
python
undefinedpython
undefinedWhen Claude's context resets mid-workflow
当Claude在工作流中途重置上下文时
"""
Continue with gemini-pro from conversation_id abc123 to remind me of
the security issues we discussed and the fixes we planned
"""
**Benefit:** Other models maintain conversation history and can "refresh" Claude's understanding without re-reading all files."""
Continue with gemini-pro from conversation_id abc123 to remind me of
the security issues we discussed and the fixes we planned
"""
**优势:**其他模型保留对话历史,可以在无需重新读取所有文件的情况下“刷新”Claude的理解。Isolated Sub-Investigation
独立子调查
python
undefinedpython
undefinedMain task in Claude, detailed analysis in subagent
在Claude中处理主任务,在子代理中进行详细分析
"""
Use clink with gemini role='security-auditor' to:
- Scan all API endpoints for OWASP Top 10 vulnerabilities
- Check for SQL injection, XSS, and auth bypass risks
- Return summary of critical findings only
Then I'll continue the main implementation here.
"""
**Benefit:** Heavy security scan runs in isolated context, returns only summary, main context stays clean."""
Use clink with gemini role='security-auditor' to:
- Scan all API endpoints for OWASP Top 10 vulnerabilities
- Check for SQL injection, XSS, and auth bypass risks
- Return summary of critical findings only
Then I'll continue the main implementation here.
"""
**优势:**繁重的安全扫描在隔离上下文中运行,仅返回摘要,主上下文保持干净。Consensus-Driven Architecture Decision
共识驱动的架构决策
python
undefinedpython
undefinedMultiple models debate approach
多个模型讨论方案
"""
Use pal to get consensus between gpt-5, gemini-pro, and o3:
Should we use event sourcing or traditional CRUD for the order management system?
Consider: scalability, complexity, team expertise, audit requirements.
Each model should provide reasoning, then synthesize a recommendation.
"""
undefined"""
Use pal to get consensus between gpt-5, gemini-pro, and o3:
Should we use event sourcing or traditional CRUD for the order management system?
Consider: scalability, complexity, team expertise, audit requirements.
Each model should provide reasoning, then synthesize a recommendation.
"""
undefinedVision-Assisted Code Review
视觉辅助代码审查
python
undefinedpython
undefinedAnalyze architectural diagrams
分析架构图
"""
Use pal with gemini-pro to:
- Analyze this system architecture diagram (screenshot attached)
- Compare it to the actual codebase structure in /src
- Identify discrepancies and outdated documentation """
undefined"""
Use pal with gemini-pro to:
- Analyze this system architecture diagram (screenshot attached)
- Compare it to the actual codebase structure in /src
- Identify discrepancies and outdated documentation """
undefinedCommon Patterns
常见模式
Pattern: Model-Specific Strengths
模式:模型特定优势
python
undefinedpython
undefinedExtended thinking for complex problems
针对复杂问题的深度思考
"Use pal with gemini-pro for deep architectural analysis"
"Use pal with gemini-pro for deep architectural analysis"
Fast iteration
快速迭代
"Use pal with gemini-flash for quick syntax checks"
"Use pal with gemini-flash for quick syntax checks"
Strong reasoning
强大推理
"Use pal with o3 for logical bug analysis"
"Use pal with o3 for logical bug analysis"
Privacy-sensitive code
隐私敏感代码
"Use pal with llama3 via Ollama for local analysis"
undefined"Use pal with llama3 via Ollama for local analysis"
undefinedPattern: Conversation Continuity
模式:对话上下文延续
python
undefinedpython
undefinedStep 1: Initial analysis
步骤1:初始分析
response1 = "Use pal with gemini-pro to analyze the auth flow"
response1 = "Use pal with gemini-pro to analyze the auth flow"
Returns conversation_id: conv_abc123
返回conversation_id: conv_abc123
Step 2: Follow-up with different model
步骤2:使用不同模型跟进
"Continue conversation conv_abc123 with o3 to verify the CSRF protection"
"Continue conversation conv_abc123 with o3 to verify the CSRF protection"
Step 3: Back to original model
步骤3:回到原模型
"Continue conversation conv_abc123 with gemini-pro to implement the fixes"
undefined"Continue conversation conv_abc123 with gemini-pro to implement the fixes"
undefinedPattern: Progressive Validation
模式:渐进式验证
python
undefinedpython
undefinedImplementation workflow with validation gates
带有验证关卡的实现工作流
"""
- Use planner to design the feature
- Implement the core logic
- Use pal with gemini-flash for quick sanity check
- Use pal with o3 for security validation
- Use precommit with gemini-pro for final review """
undefined"""
- Use planner to design the feature
- Implement the core logic
- Use pal with gemini-flash for quick sanity check
- Use pal with o3 for security validation
- Use precommit with gemini-pro for final review """
undefinedPattern: Parallel Sub-Tasks
模式:并行子任务
python
undefinedpython
undefinedOffload heavy tasks to subagents
将繁重任务卸载到子代理
"""
Spawn three parallel clink subagents:
- clink gemini role='tester' - Generate unit tests for auth module
- clink codex role='documenter' - Write API documentation
- clink gemini role='security' - Perform security audit
I'll continue the main feature implementation while they work.
"""
undefined"""
Spawn three parallel clink subagents:
- clink gemini role='tester' - Generate unit tests for auth module
- clink codex role='documenter' - Write API documentation
- clink gemini role='security' - Perform security audit
I'll continue the main feature implementation while they work.
"""
undefinedTroubleshooting
故障排除
MCP Connection Issues
MCP连接问题
bash
undefinedbash
undefinedCheck MCP server logs
查看MCP服务器日志
tail -f ~/Library/Logs/Claude/mcp*.log
tail -f ~/Library/Logs/Claude/mcp*.log
Verify uvx installation
验证uvx安装
which uvx
uvx --version
which uvx
uvx --version
Test PAL directly
直接测试PAL
cd pal-mcp-server
uv run pal-mcp-server
undefinedcd pal-mcp-server
uv run pal-mcp-server
undefinedAPI Key Not Working
API密钥无法工作
bash
undefinedbash
undefinedVerify key is set
验证密钥已设置
echo $GEMINI_API_KEY
echo $GEMINI_API_KEY
Check .env file
检查.env文件
cat .env | grep GEMINI_API_KEY
cat .env | grep GEMINI_API_KEY
Test API directly
直接测试API
curl -H "Authorization: Bearer $GEMINI_API_KEY"
https://generativelanguage.googleapis.com/v1/models
https://generativelanguage.googleapis.com/v1/models
undefinedcurl -H "Authorization: Bearer $GEMINI_API_KEY"
https://generativelanguage.googleapis.com/v1/models
https://generativelanguage.googleapis.com/v1/models
undefinedModel Not Available
模型不可用
python
undefinedpython
undefinedList available models
列出可用模型
"Use pal with model='list' to show all available models"
"Use pal with model='list' to show all available models"
Check provider status
检查提供商状态
"Use pal to test connection to gemini-pro"
undefined"Use pal to test connection to gemini-pro"
undefinedHigh Token Usage
高Token消耗
bash
undefinedbash
undefinedDisable unused tools to reduce context
禁用未使用的工具以减少上下文占用
export DISABLED_TOOLS="analyze,refactor,testgen,secaudit,docgen,tracer"
export DISABLED_TOOLS="analyze,refactor,testgen,secaudit,docgen,tracer"
Use flash models for quick tasks
使用flash模型处理快速任务
"Use pal with gemini-flash instead of gemini-pro"
"Use pal with gemini-flash instead of gemini-pro"
Limit response length
限制响应长度
"Use pal with max_tokens=2000 for concise analysis"
undefined"Use pal with max_tokens=2000 for concise analysis"
undefinedConversation Context Lost
对话上下文丢失
python
undefinedpython
undefinedAlways capture conversation_id from responses
始终从响应中捕获conversation_id
Store it for later reference
存储以供后续参考
"Continue conversation conv_abc123 with gemini-pro"
"Continue conversation conv_abc123 with gemini-pro"
If lost, start new thread with summary
如果丢失,使用摘要启动新线程
"Use pal with gemini-pro, here's what we discussed before: [summary]"
undefined"Use pal with gemini-pro, here's what we discussed before: [summary]"
undefinedclink Subagent Timeout
clink子代理超时
bash
undefinedbash
undefinedIncrease timeout for heavy tasks
为重任务增加超时时间
"Use clink with gemini timeout=600 to perform comprehensive security audit"
"Use clink with gemini timeout=600 to perform comprehensive security audit"
Split into smaller tasks
拆分为更小的任务
"Use clink with gemini to audit only the authentication module first"
undefined"Use clink with gemini to audit only the authentication module first"
undefinedOllama Local Models
Ollama本地模型
bash
undefinedbash
undefinedStart Ollama server
启动Ollama服务器
ollama serve
ollama serve
Pull models
拉取模型
ollama pull llama3
ollama pull codellama
ollama pull llama3
ollama pull codellama
Verify availability
验证可用性
ollama list
ollama list
Use in PAL
在PAL中使用
"Use pal with llama3 to analyze this code locally"
undefined"Use pal with llama3 to analyze this code locally"
undefinedBest Practices
最佳实践
- Start with Specific Models: Use for deep thinking,
gemini-profor speed,gemini-flashfor reasoningo3 - Leverage Conversation IDs: Track multi-step workflows across models
- Use clink for Isolation: Keep main context clean by offloading heavy analysis to subagents
- Disable Unused Tools: Reduce context window consumption with
DISABLED_TOOLS - Cache Conversation Context: When context resets, use another model to "remind" your primary CLI
- Model Selection Strategy: Match model strengths to task requirements (vision, speed, reasoning, context size)
- Progressive Validation: Use multiple models as validation gates (fast check → deep analysis → security audit)
PAL MCP transforms your AI coding assistant into an orchestrator that can leverage the best model for each subtask while maintaining full conversation continuity across the entire workflow.
- 从特定模型开始:使用进行深度思考,
gemini-pro追求速度,gemini-flash用于推理o3 - 利用对话ID:跨模型跟踪多步骤工作流
- 使用clink进行隔离:将繁重分析卸载到子代理,保持主上下文干净
- 禁用未使用的工具:通过减少上下文窗口消耗
DISABLED_TOOLS - 缓存对话上下文:当上下文重置时,使用其他模型“提醒”你的主CLI
- 模型选择策略:匹配模型优势与任务需求(视觉、速度、推理、上下文大小)
- 渐进式验证:使用多个模型作为验证关卡(快速检查→深度分析→安全审计)
PAL MCP将你的AI代码助手转变为编排器,能够为每个子任务选用最合适的模型,同时在整个工作流中保持完整的对话上下文延续。