pal-mcp-server
AGENTS.md7 starsChanged 46 days agoApache-2.0View on GitHub
This file provides guidance to AI agents like claude-code, codex, and others, when working with this repository. Before making any changes or submitting PRs, always run the comprehensive quality checks: This script automatically runs: Run Integration Tests (requires API keys): This script will: Current log files (with proper rotation): For programmatic log analysis (used by tests): Simulation tests are available to test the MCP server in a 'live' scenario, using your configured API keys to ensure the models are working…
- Reads credentials
- Installs packages
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about code style.
Of the AGENTS.md files we read, the 35,337 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository2 other files it gives its agents.
- .capy/AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
The file
Show its rules and text
We split this AGENTS.md into the rules it gives an agent
19 rules. About 1 is common, 5 are distinctive, and 13 are very specific to this project.
≈1
Common · estimate
Many files like this have a rule of this kind.
≈5
Distinctive · estimate
This author's own choices. Worth a look.
13
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 9
Before making any changes or submitting PRs, always run the comprehensive quality checks:
- Distinctive: line 26
Import sorting with isort
- Common: line 53
Create/update .env file
- Distinctive: line 132
IMPORTANT: After any code changes, restart your Claude session for the changes to take effect.
- Distinctive: line 206
Note: All simulator tests should be run individually for optimal testing and better error isolation.
- Very specific: line 261
Ensure virtual environment is activated: source .pal_venv/bin/activate
- Very specific: line 262
Run quality checks: ./code_quality_checks.sh
- Very specific: line 263
Check logs to ensure server is healthy: tail -n 50 logs/mcp_server.log
- Very specific: line 267
Run quality checks again: ./code_quality_checks.sh
- Very specific: line 268
Run integration tests locally: ./run_integration_tests.sh
- Very specific: line 269
Run quick test mode for fast validation: python communication_simulator_test.py --quick
- Very specific: line 270
Run relevant specific simulator tests if needed: python communication_simulator_test.py --individual <test_name>
- Very specific: line 271
Check logs for any issues: tail -n 100 logs/mcp_server.log
- Very specific: line 277
Run integration tests: ./run_integration_tests.sh
- Very specific: line 278
Run quick test mode: python communication_simulator_test.py --quick
- Very specific: line 279
Run full simulator test suite (optional): ./run_integration_tests.sh --with-simulator
- Distinctive: line 280
Verify all tests pass 100%
- Very specific: line 361
Run the lock commands below on Python 3.10, the oldest supported interpreter.
- Very specific: line 382
All dependencies from requirements.txt installed
≈ “Common” is an estimate: at least 1 in 5 of the 45,344 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
AGENTS.md
This file provides guidance to AI agents like claude-code, codex, and others, when working with this repository.
Quick Reference Commands
Code Quality Checks
Before making any changes or submitting PRs, always run the comprehensive quality checks:
# Activate virtual environment first
workon pal
# if pal virtualenv does not exist (workon | grep pal)
mkvirtualenv pal
# Run all quality checks (linting, formatting, tests)
./code_quality_checks.shThis script automatically runs:
- Ruff linting with auto-fix
- Black code formatting
- Import sorting with isort
- Complete unit test suite (excluding integration tests)
- Verification that all checks pass 100%
Run Integration Tests (requires API keys):
# Run integration tests that make real API calls
./run_integration_tests.sh
# Run integration tests + simulator tests
./run_integration_tests.sh --with-simulatorServer Management
Setup/Update the Server
# Run setup script (handles everything)
./run-server.shThis script will:
- Set up Python virtual environment
- Install all dependencies
- Create/update .env file
- Configure MCP with Claude
- Verify API keys
View Logs
# Follow logs in real-time
./run-server.sh -f
# Or manually view logs
tail -f logs/mcp_server.logLog Management
View Server Logs
# View last 500 lines of server logs
tail -n 500 logs/mcp_server.log
# Follow logs in real-time
tail -f logs/mcp_server.log
# View specific number of lines
tail -n 100 logs/mcp_server.log
# Search logs for specific patterns
grep "ERROR" logs/mcp_server.log
grep "tool_name" logs/mcp_activity.logMonitor Tool Executions Only
# View tool activity log (focused on tool calls and completions)
tail -n 100 logs/mcp_activity.log
# Follow tool activity in real-time
tail -f logs/mcp_activity.log
# Use simple tail commands to monitor logs
tail -f logs/mcp_activity.log | grep -E "(TOOL_CALL|TOOL_COMPLETED|ERROR|WARNING)"Available Log Files
Current log files (with proper rotation):
# Main server log (all activity including debug info) - 20MB max, 10 backups
tail -f logs/mcp_server.log
# Tool activity only (TOOL_CALL, TOOL_COMPLETED, etc.) - 20MB max, 5 backups
tail -f logs/mcp_activity.logFor programmatic log analysis (used by tests):
# Import the LogUtils class from simulator tests
from simulator_tests.log_utils import LogUtils
# Get recent logs
recent_logs = LogUtils.get_recent_server_logs(lines=500)
# Check for errors
errors = LogUtils.check_server_logs_for_errors()
# Search for specific patterns
matches = LogUtils.search_logs_for_pattern("TOOL_CALL.*debug")Testing
Simulation tests are available to test the MCP server in a 'live' scenario, using your configured API keys to ensure the models are working and the server is able to communicate back and forth.
IMPORTANT: After any code changes, restart your Claude session for the changes to take effect.
Run All Simulator Tests
# Run the complete test suite
python communication_simulator_test.py
# Run tests with verbose output
python communication_simulator_test.py --verboseQuick Test Mode (Recommended for Time-Limited Testing)
# Run quick test mode - 6 essential tests that provide maximum functionality coverage
python communication_simulator_test.py --quick
# Run quick test mode with verbose output
python communication_simulator_test.py --quick --verboseQuick mode runs these 6 essential tests:
cross_tool_continuation- Cross-tool conversation memory testing (chat, thinkdeep, codereview, analyze, debug)conversation_chain_validation- Core conversation threading and memory validationconsensus_workflow_accurate- Consensus tool with flash model and stance testingcodereview_validation- CodeReview tool with flash model and multi-step workflowsplanner_validation- Planner tool with flash model and complex planning workflowstoken_allocation_validation- Token allocation and conversation history buildup testing
Why these 6 tests: They cover the core functionality including conversation memory (utils/conversation_memory.py), chat tool functionality, file processing and deduplication, model selection (flash/flashlite/o3), and cross-tool conversation workflows. These tests validate the most critical parts of the system in minimal time.
Note: Some workflow tools (analyze, codereview, planner, consensus, etc.) require specific workflow parameters and may need individual testing rather than quick mode testing.
Run Individual Simulator Tests (For Detailed Testing)
# List all available tests
python communication_simulator_test.py --list-tests
# RECOMMENDED: Run tests individually for better isolation and debugging
python communication_simulator_test.py --individual basic_conversation
python communication_simulator_test.py --individual content_validation
python communication_simulator_test.py --individual cross_tool_continuation
python communication_simulator_test.py --individual memory_validation
# Run multiple specific tests
python communication_simulator_test.py --tests basic_conversation content_validation
# Run individual test with verbose output for debugging
python communication_simulator_test.py --individual memory_validation --verboseAvailable simulator tests include:
basic_conversation- Basic conversation flow with chat toolcontent_validation- Content validation and duplicate detectionper_tool_deduplication- File deduplication for individual toolscross_tool_continuation- Cross-tool conversation continuation scenarioscross_tool_comprehensive- Comprehensive cross-tool file deduplication and continuationline_number_validation- Line number handling validation across toolsmemory_validation- Conversation memory validationmodel_thinking_config- Model-specific thinking configuration behavioro3_model_selection- O3 model selection and usage validationollama_custom_url- Ollama custom URL endpoint functionalityopenrouter_fallback- OpenRouter fallback behavior when only provideropenrouter_models- OpenRouter model functionality and alias mappingtoken_allocation_validation- Token allocation and conversation history validationtestgen_validation- TestGen tool validation with specific test functionrefactor_validation- Refactor tool validation with codesmellsconversation_chain_validation- Conversation chain and threading validationconsensus_stance- Consensus tool validation with stance steering (for/against/neutral)
Note: All simulator tests should be run individually for optimal testing and better error isolation.
Run Unit Tests Only
# Run all unit tests (excluding integration tests that require API keys)
python -m pytest tests/ -v -m "not integration"
# Run specific test file
python -m pytest tests/test_refactor.py -v
# Run specific test function
python -m pytest tests/test_refactor.py::TestRefactorTool::test_format_response -v
# Run tests with coverage
python -m pytest tests/ --cov=. --cov-report=html -m "not integration"Run Integration Tests (Uses Free Local Models)
Setup Requirements:
# 1. Install Ollama (if not already installed)
# Visit https://ollama.ai or use brew install ollama
# 2. Start Ollama service
ollama serve
# 3. Pull a model (e.g., llama3.2)
ollama pull llama3.2
# 4. Set environment variable for custom provider
export CUSTOM_API_URL="http://localhost:11434"Run Integration Tests:
# Run integration tests that make real API calls to local models
python -m pytest tests/ -v -m "integration"
# Run specific integration test
python -m pytest tests/test_prompt_regression.py::TestPromptIntegration::test_chat_normal_prompt -v
# Run all tests (unit + integration)
python -m pytest tests/ -vNote: Integration tests use the local-llama model via Ollama, which is completely FREE to run unlimited times. Requires CUSTOM_API_URL environment variable set to your local Ollama endpoint. They can be run safely in CI/CD but are excluded from code quality checks to keep them fast.
Development Workflow
Before Making Changes
- Ensure virtual environment is activated:
source .pal_venv/bin/activate - Run quality checks:
./code_quality_checks.sh - Check logs to ensure server is healthy:
tail -n 50 logs/mcp_server.log
After Making Changes
- Run quality checks again:
./code_quality_checks.sh - Run integration tests locally:
./run_integration_tests.sh - Run quick test mode for fast validation:
python communication_simulator_test.py --quick - Run relevant specific simulator tests if needed:
python communication_simulator_test.py --individual <test_name> - Check logs for any issues:
tail -n 100 logs/mcp_server.log - Restart Claude session to use updated code
Before Committing/PR
- Final quality check:
./code_quality_checks.sh - Run integration tests:
./run_integration_tests.sh - Run quick test mode:
python communication_simulator_test.py --quick - Run full simulator test suite (optional):
./run_integration_tests.sh --with-simulator - Verify all tests pass 100%
NEVER commit ./.capy/knowledge.db during the session!
Common Troubleshooting
Server Issues
# Check if Python environment is set up correctly
./run-server.sh
# View recent errors
grep "ERROR" logs/mcp_server.log | tail -20
# Check virtual environment
which python
# Should show: .../pal-mcp-server/.pal_venv/bin/pythonTest Failures
# First try quick test mode to see if it's a general issue
python communication_simulator_test.py --quick --verbose
# Run individual failing test with verbose output
python communication_simulator_test.py --individual <test_name> --verbose
# Check server logs during test execution
tail -f logs/mcp_server.log
# Run tests with debug output
LOG_LEVEL=DEBUG python communication_simulator_test.py --individual <test_name>tests/test_tool_surface.py compares every tool schema with a committed baseline.
Pytest isolates personal CLI manifests before collection and resets the clink
environment override/cache between tests. Ordinary tests use shipped manifests;
configuration tests can explicitly supply synthetic overrides. Do not change
HOME to work around local CLI configuration. See docs/testing.md for details.
python -m pytest tests/test_tool_surface.pyLinting Issues
# Auto-fix most linting issues
ruff check . --fix
black .
isort .
# Check what would be changed without applying
ruff check .
black --check .
isort --check-only .File Structure Context
./code_quality_checks.sh- Comprehensive quality check script./run-server.sh- Server setup and managementcommunication_simulator_test.py- End-to-end testing frameworksimulator_tests/- Individual test modulestests/- Unit test suitetools/- MCP tool implementationsproviders/- AI provider implementationssystemprompts/- System prompt definitionslogs/- Server log files
Dependency Management
Dependencies are pinned using pip-tools. Abstract constraints live in source files; pip-compile resolves them into pinned lock files.
| Source (edit this) | Lock file (generated) |
pyproject.toml | requirements.txt |
requirements-dev.in | requirements-dev.txt |
Run the lock commands below on Python 3.10, the oldest supported interpreter. Dev deps are constrained against runtime pins (-c requirements.txt in requirements-dev.in) to prevent version divergence.
# Add or update a runtime dependency: edit pyproject.toml [project] dependencies, then:
pip-compile --strip-extras --no-header pyproject.toml -o requirements.txt
# Add or update a dev dependency: edit requirements-dev.in, then:
pip-compile --strip-extras --no-header requirements-dev.in -o requirements-dev.txt
# Upgrade all pinned versions to latest:
pip-compile --upgrade --strip-extras --no-header pyproject.toml -o requirements.txt
pip-compile --upgrade --strip-extras --no-header requirements-dev.in -o requirements-dev.txtCI enforces freshness: the lint job recompiles and diffs — if lock files are stale, the build fails.
--no-header omits pip-compile's provenance header, whose recorded command line varies by
environment (some setups inject --no-index) and would otherwise cause spurious diffs in CI.
Environment Requirements
- Python 3.10+ with virtual environment
- All dependencies from
requirements.txtinstalled - Proper API keys configured in
.envfile
This guide provides everything needed to efficiently work with the PAL MCP Server codebase using Claude. Always run quality checks before and after making changes to ensure code integrity.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

