PAL MCP (Provider Abstraction Layer)

repository·main·Indexed 11 days ago

https://github.com/beehiveinnovations/pal-mcp-server

An AI-powered Model Context Protocol (MCP) server version 9.8.2 that orchestrates multiple AI models (Gemini, OpenAI, Anthropic, X.AI, and others) through a single interface. It enables multi-model collaboration, context isolation via subagents, and conversation continuity for AI CLIs and IDEs. Features include specialized tools for deep thinking, planning, consensus, and code analysis, as well as the `clink` tool for integrating external AI CLI subagents.

Tokens
54.4K
Snippets
126
Records
236
Agent score
96%

What's inside PAL MCP

  1. What is PAL MCP?

    main

    PAL MCP (Provider Abstraction Layer) is a Model Context Protocol server designed to orchestrate multiple AI models within a single workflow. It acts as 'super-glue' for AI CLIs (like Claude Code, Gemini CLI, Codex CLI, or Qwen Code CLI) and IDEs (like Cursor), allowing a primary agent to delegate tasks to specialized models (e.g., Gemini Pro for deep thinking, Flash for speed, or Ollama for local privacy).

    Key capabilities include:

    • Multi-Model Orchestration: Use different models for specific subtasks (analysis, planning, implementation, validation).
    • Conversation Continuity: Context and reasoning are passed between models, allowing a model to 'remind' another of previous discussions.
    • Context Isolation: Offload heavy tasks to subagents to prevent polluting the primary session's context window.
    • Bypassing Token Limits: Automatically manages large prompts and responses that exceed standard MCP limits.
  2. Compare `codereview` with other available tools

    main

    Use the following guide to choose the right tool for your task:

    • codereview: Use for finding bugs, security issues, performance problems, and quality assessment.
    • analyze: Use for understanding code structure without looking for issues.
    • debug: Use for diagnosing specific runtime errors or exceptions.
    • refactor: Use for identifying structural improvements and modernization opportunities.
  3. How the PreCommit tool workflow works

    main

    The precommit tool uses a structured, multi-step workflow to validate git changes. It is divided into two main phases:

    1. Investigation Phase (Claude-Led)

    Claude performs a systematic investigation through a minimum of 3 enforced steps:

    • Step 1: Claude states a validation strategy using direct statements.
    • Step 2: Claude examines changes, diffs, and dependencies with mandatory deeper investigation.
    • Step 3+: Claude performs final verification.
    • Throughout: Claude tracks findings, relevant files, and issues.
    • Completion: Once the minimum steps are met, Claude creates a pal_precommit.changeset file.

    Note: If using a continuation_id with external validation, the minimum step requirement is bypassed to allow immediate expert analysis.

    2. Expert Validation Phase

    Unless precommit_type is set to internal, the tool triggers an expert model (e.g., Gemini Pro) to provide:

    • A complete summary of changes and context.
    • Identification of potential issues or regressions.
    • Assessment of requirement compliance.
    • Final recommendations for a safe commit.

    CRITICAL: To skip expert validation, you must explicitly request "don't use any other model" or set precommit_type to internal.

    # No runnable code example provided for the workflow logic itself, but it is triggered via natural language prompts.
  4. How thinking modes work and how to use them

    main

    While Claude automatically manages thinking modes, you can manually control Gemini's reasoning depth to balance response quality against token consumption and cost. Higher thinking modes use more tokens and take longer but provide better reasoning.

    Thinking Modes (Gemini 3.0 Pro):

    ModeToken BudgetUse CaseCost Impact
    minimal128 tokensSimple, straightforward tasksLowest cost
    low2,048 tokensBasic reasoning tasks16x more than minimal
    medium8,192 tokensDefault - Most development tasks64x more than minimal
    high16,384 tokensComplex problems requiring thorough analysis128x more than minimal
    max32,768 tokensExhaustive reasoning256x more than minimal

    Usage Strategies:

    • Use minimal or low for: Simple formatting, quick explanations, or working within tight budgets.
    • Use high or max for: Debugging complex issues, security reviews, architecture analysis, or finding subtle edge cases.

    Example Prompts:

    • "Get o3 to do a security review of auth/ with thinking mode high"
    • "Use pal to debug this race condition with max thinking mode"
    • "Analyze the entire src/ directory architecture with high thinking using pro"
  5. Understand the output of dependencies mode

    main

    When using dependencies mode for classes, modules, or protocols, the tracer tool generates prompts designed to help Claude produce the following analysis types:

    • Structural Relationships: Maps inheritance hierarchies, composition/aggregation, interface implementations, and module imports/exports.
    • Bidirectional Dependencies: Identifies what the component depends on, what depends on it, circular dependencies, and coupling strength.
    • Architectural Impact: Assesses layer violations, dependency inversion opportunities, refactoring impact, and testability implications.
  6. Compare TestGen with other PAL tools

    main

    Choose the appropriate tool based on your current goal:

    ToolUse Case
    testgenCreating comprehensive test suites, filling coverage gaps, or testing new features.
    debugDiagnosing specific test failures or runtime issues.
    codereviewReviewing existing code quality and test coverage.
    analyzeUnderstanding existing code structure without generating new tests.
  7. Where model capability ranks are used

    main

    The computed capability rank is cached per provider and used in the following areas:

    • Tool schemas: Populates model parameter descriptions when auto mode is active.
    • listmodels tool: Populates the "top models" sections.
    • Fallback messaging: Used when a requested model is unavailable.

    Note: The rank is computed after restriction filters, meaning only models allowed by your configuration will appear in these summaries.

  8. Understand the output of precision mode

    main

    When using precision mode for methods or functions, the tracer tool generates prompts designed to help Claude produce the following analysis types:

    • Call Chain Analysis: Identifies method definition location, all call sites (direct and indirect), and the overall call hierarchy/depth.
    • Execution Flow Mapping: Provides a step-by-step execution path, including branching logic, side effects, state changes, and return value usage.
    • Usage Pattern Analysis: Documents the frequency and context of calls, parameter passing patterns, error handling approaches, and performance implications.
  9. Use Web Search recommendations for enhanced analysis

    main

    Web search is enabled by default. Instead of performing searches directly, Gemini analyzes your request and provides a list of "Recommended Web Searches for Claude" when it identifies that external documentation, API references, or community solutions would improve its reasoning.

    How it works:

    1. Gemini identifies gaps in its training data (e.g., recent framework changes).
    2. Gemini provides its analysis and includes a specific list of search queries.
    3. Claude executes these searches and incorporates the results into the conversation.

    Disabling Web Search: If you want the model to rely strictly on its training data without suggesting searches, you can explicitly instruct it in your prompt:

    "Use gemini to review this code and confirm whether any new framework changes affect the recommendation"

  10. How model routing and provider priority works

    main

    The system automatically routes model requests to the correct provider based on the model name and registry configuration.

    Routing Logic:

    1. Custom Registry: Any model listed in conf/custom_models.json is always routed through the Custom API (requires CUSTOM_API_URL).
    2. OpenRouter Registry: Any model listed in conf/openrouter_models.json is routed through OpenRouter (requires OPENROUTER_API_KEY).
    3. Unknown Models: If a model is not in a registry, the system uses fallback logic based on name patterns.

    Provider Priority Order (for resolving conflicts):

    1. Native APIs (Google, OpenAI) - if keys are available.
    2. Custom endpoints - for models declared in conf/custom_models.json.
    3. OpenRouter - catch-all for cloud models.
  11. Select the appropriate Thinking Mode

    main

    The thinking_mode parameter (available for Gemini models) determines the depth of analysis. Claude will attempt to choose the best mode based on complexity, but you can specify it manually:

    • minimal: For very quick validations.
    • low: For simple tasks.
    • medium: For standard problems.
    • high: For complex issues (this is the default).
    • max: For extremely complex challenges requiring the deepest possible analysis.
  12. Choose between PreCommit, CodeReview, Debug, and Analyze tools

    main

    Select the appropriate tool based on your current workflow goal:

    ToolUse Case
    precommitValidating changes before a git commit and ensuring requirement compliance.
    codereviewGeneral code quality assessment without git context.
    debugDiagnosing specific runtime issues.
    analyzeUnderstanding existing code without a validation context.