PAS - Scientific Reasoning MCP Server
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
🏛️ PAS - Scientific Reasoning MCP Server
Plato • Aristotle • Socrates
A Model Context Protocol (MCP) server that brings structured, Bayesian reasoning to AI agents. PAS implements a Tree of Thoughts architecture with scientific law grounding, enabling AI to reason more deliberately through complex problems.
🎯 What is PAS?
PAS transforms how AI agents approach complex reasoning by:
Expanding hypotheses systematically (like Plato's ideation)
Critiquing each branch with counterarguments (like Socrates' dialectic)
Grounding reasoning in scientific laws (like Aristotle's empiricism)
Instead of producing a single answer, PAS builds a reasoning tree where each hypothesis is scored using Bayesian inference and challenged through adversarial critique.
Related MCP server: Think MCP
✨ Features
Feature | Description |
Bayesian Tree of Thoughts | Build reasoning trees with posterior probability scoring |
Scientific Law Grounding | 15+ laws (CAP Theorem, Occam's Razor, etc.) inform priors |
Quality Gate | 0.9 score + 0.1 gap thresholds with improvement suggestions |
Negative Space Critique | Find what's MISSING, not just what's wrong |
Smart Interview Pattern | Psychology-based Q&A to gather missing context |
Domain Detection | Auto-detect problem domain for tailored questions |
RLVR Self-Learning | Auto-detect success/failure from terminal output |
Sequential Gap Analysis | Layer-by-layer adversarial gap detection (v32/v37) |
Session Tagging | Organize sessions with tags for retrieval |
Persistent Traits | Learn user preferences across sessions (v22) |
Past Failures Surfacing | Learn from similar past failures during critique |
Live Code Navigation | Find references/definitions via Jedi (v38) |
Symbol Suggestions | Auto-suggest symbols during hypothesis generation |
Preflight Enforcement | Structural guardrails at hypothesis storage (v41) |
Self-Awareness | PAS can introspect its own schema/tools/architecture (v40) |
Self-Aware Test Suite | 4-layer tests that log failures back to PAS (v42) |
🧠 Sequential Thinking Integration
PAS is designed to work alongside @anthropic/mcp-sequential-thinking. While Sequential Thinking handles linear thought chains, PAS provides tree-structured reasoning with Bayesian scoring.
Complementary Usage
Aspect | Sequential Thinking | PAS |
Structure | Linear chain | Bayesian Tree |
Scoring | None | Prior × Likelihood = Posterior |
Self-Critique | None | Tiered penalties (major/minor flaws) |
Quality Gate | None | 0.9 score, 0.1 gap |
Self-Learning | None | Laws + failure memory + traits |
Output | Final thought | Ranked recommendation + gaps |
Recommended Pattern
1. Use Sequential Thinking for quick, linear reasoning
2. When uncertainty is high, escalate to PAS:
→ start_reasoning_session(user_goal="...")
→ Expand, critique, deepen until quality gate passes
3. Record outcome for RLVR learning🛠️ Tools (25+ Total)
Session Management
Tool | Description |
| Begin a new reasoning session with a goal |
| Check session state and thought count |
| Smart router - finds existing or creates new session |
| Explicitly close a session |
| Continue a completed session with inheritance |
| Add tags for organization |
Reasoning (Expand & Critique)
Tool | Description |
| Get context + relevant laws for hypothesis generation |
| Store 1-3 hypotheses with Bayesian scoring |
| Get node context + LLM prompt for counterarguments |
| Store critique with tiered penalties (major/minor) |
| Find scientific laws by semantic similarity |
Sequential Analysis (v32/v37)
Tool | Description |
| Get prompts for 5-layer gap analysis on top candidates |
| Store gap analysis, detect systemic gaps |
5-Layer Gap Analysis checks:
CODE STRUCTURE - What code changes are needed?
DEPENDENCIES - What packages/systems are assumed?
DATA FLOW - What data moves where?
INTERFACES - What APIs/contracts are affected?
WORKFLOWS - What user/system flows change?
Tree Navigation
Tool | Description |
| View full tree structure with scores |
| Find highest-scoring reasoning path |
| Auto-critique, quality gate, return recommendation |
Smart Interview
Tool | Description |
| Generate clarifying questions based on goal |
| Get one question at a time with formatted choices |
| Answer question, trigger follow-up rules |
| Check if enough context gathered |
Interview Features:
Domain Detection - Auto-detect UI, architecture, debugging, testing domains
Hidden Context - Choices carry hidden metadata for trait inference
Follow-up Rules - Conditional question injection based on answers
Progress Tracking - Max 15 questions, 3 levels deep
History Archive - Answered questions stored for self-learning
Self-Learning (RLVR)
Tool | Description |
| Record success/failure with semantic attribution |
| Auto-detect success/failure signals from terminal |
| Update law weights based on outcomes |
| Store user input for semantic search |
| Find past context by similarity |
RLVR Auto-Recording:
{
"finalize_session": {
"terminal_output": "[terminal logs here]",
"auto_record": true
}
}PAS automatically parses terminal output and records outcomes.
Code Navigation (v38)
Tool | Description |
| Index a project for symbol search |
| Semantic search over indexed files |
| Find all references to a symbol (live Jedi) |
| Jump to symbol definition |
| Build caller/callee tree |
| Import LSIF index (optional fallback) |
📦 Installation
Prerequisites
Python 3.10+
PostgreSQL 16+ with extensions:
pgvector(semantic similarity)ltree(tree paths)
Step 1: Clone & Setup
git clone https://github.com/nocountryman/mcp-pas.git
cd mcp-pas
# Create virtual environment
python -m venv .venv
source .venv/bin/activate # Linux/Mac
# Install dependencies
pip install -r requirements.txtDependencies
Package | Version | Purpose |
| latest | Model Context Protocol server framework |
| latest | PostgreSQL adapter |
| latest | Vector similarity for embeddings |
| latest | Data validation |
| latest | Numerical operations |
| latest | Local embeddings (all-MiniLM-L6-v2) |
| ≥0.13.0 | Symbol extraction for code indexing |
| ≥6.0 | Configuration file parsing |
| latest | Live code navigation (find references, go-to-definition) |
Optional Tools
Tool | Install | Purpose |
|
| Generate LSIF indexes for precision code navigation |
When to use LSIF vs Jedi:
Jedi (default): Live analysis, no pre-indexing, works out of the box
LSIF (optional): Pre-computed index via
pyright --outputtype lsif, faster for large codebases
# Generate LSIF index (optional)
pyright --outputtype lsif --outputfile project.lsif.json
# Import into PAS
# → import_lsif(project_id="...", lsif_path="/path/to/project.lsif.json")Step 2: Database Setup
# Create database
sudo -u postgres createdb mcp_pas
# Enable extensions
sudo -u postgres psql -d mcp_pas -c "CREATE EXTENSION IF NOT EXISTS vector;"
sudo -u postgres psql -d mcp_pas -c "CREATE EXTENSION IF NOT EXISTS ltree;"
# Run schema
psql -d mcp_pas -f schema.sql
# Seed scientific laws and domains
python seed_laws.py
python seed_domains_v2.pyStep 3: Environment Configuration
cp env.template .env
# Edit .env with your database credentialsDATABASE_URL=postgresql://user:password@localhost:5432/mcp_pasNote: PAS uses local embeddings via
sentence-transformersby default. No OpenAI API key required.
Step 4: GPU Acceleration (Optional)
PAS embedding model can run on GPU for 5-10x faster loading (11s vs 2-5 min on CPU).
AMD GPUs (ROCm)
Note: ROCm PyTorch wheels require Python 3.10-3.12. On rolling-release distros (Arch/CachyOS) with Python 3.14+, you'll need a separate Python 3.12 virtual environment.
Step 1: Create Python 3.12 venv with ROCm PyTorch:
# Create separate venv with Python 3.12
python3.12 -m venv .venv312
source .venv312/bin/activate
# Install ROCm PyTorch from official wheels
pip install torch --index-url https://download.pytorch.org/whl/rocm6.2
# Install other dependencies
pip install -r requirements.txtStep 2: RDNA2 GPU workaround (RX 6000 series):
RDNA2 GPUs (gfx1032, gfx1030) need an environment variable override:
export HSA_OVERRIDE_GFX_VERSION=10.3.0Add this to your MCP config:
{
"env": {
"DATABASE_URL": "...",
"HSA_OVERRIDE_GFX_VERSION": "10.3.0"
}
}Verify GPU is detected:
source .venv312/bin/activate
HSA_OVERRIDE_GFX_VERSION=10.3.0 python -c "import torch; print(torch.cuda.is_available(), torch.cuda.get_device_name(0))"
# Expected: True AMD Radeon RX 6650 XT (or your GPU)NVIDIA GPUs (CUDA)
On Arch Linux / CachyOS:
sudo pacman -S python-pytorch-cuda cuda cudnnOn Ubuntu/Debian:
pip install torch --index-url https://download.pytorch.org/whl/cu121Performance Comparison
Metric | CPU | GPU (ROCm/CUDA) |
Model load | 2-5 min | 11-30 sec |
Encode 100 texts | ~500ms | ~50ms |
Memory used | System RAM | VRAM |
No other changes needed - once the venv uses ROCm/CUDA torch, the singleton in utils.py automatically loads the model to GPU.
🔌 IDE Integration
VS Code / Cursor (with Claude/Gemini Extension)
Add to your MCP configuration:
{
"mcpServers": {
"pas-server": {
"command": "/path/to/mcp-pas/.venv/bin/python",
"args": ["/path/to/mcp-pas/server.py"],
"env": {
"DATABASE_URL": "postgresql://user:password@localhost:5432/mcp_pas",
"HSA_OVERRIDE_GFX_VERSION": "10.3.0"
}
}
}
}Note: Use
.venv312/bin/pythonfor GPU (ROCm) or.venv/bin/pythonfor CPU-only. RemoveHSA_OVERRIDE_GFX_VERSIONif using NVIDIA or RDNA3+ GPUs.
After configuration: Restart your IDE (Ctrl+Shift+P → Reload Window).
🚀 Usage Walkthrough
Basic Reasoning Flow
1. Start session
→ start_reasoning_session(user_goal="Design a caching layer")
2. Expand hypotheses (3 alternatives)
→ prepare_expansion(session_id="...")
→ store_expansion(session_id="...", h1_text="...", h1_confidence=0.85, ...)
3. Critique top hypothesis
→ prepare_critique(node_id="...") # Returns llm_prompt
→ [Process prompt]
→ store_critique(node_id="...", counterargument="...", severity_score=0.3)
4. Sequential gap analysis (REQUIRED before finalize)
→ prepare_sequential_analysis(session_id="...", top_n=3)
→ [Process 5-layer prompts]
→ store_sequential_analysis(session_id="...", results="[...]")
5. Deepen if score < 0.9 or gap < 0.1
→ store_expansion(parent_node_id="...", h1_text="Improved approach...", h1_confidence=0.95)
6. Get recommendation
→ finalize_session(session_id="...")
# Returns: quality_gate, recommendation, exhaustive_checkSmart Interview Flow
1. Identify missing context
→ identify_gaps(session_id="...")
2. Ask questions one at a time
→ get_next_question(session_id="...")
→ [Present to user]
→ submit_answer(session_id="...", question_id="...", answer="B")
3. Check completion
→ check_interview_complete(session_id="...")
# Once complete, hidden context is propagated to sessionQuality Gate (v31)
PAS won't accept low-quality decisions:
{
"quality_gate": {
"score": 0.95,
"score_threshold": 0.9,
"score_ok": true,
"gap": 0.12,
"gap_threshold": 0.1,
"gap_ok": true,
"passed": true
}
}If passed: false, PAS suggests how to improve:
{
"score_improvement_suggestions": [
{"lever": "score", "action": "Expand deeper with higher confidence (0.9+)"},
{"lever": "gap", "action": "Explore more diverse alternatives"}
]
}📊 Architecture
Module Structure (v42)
server.py Main MCP server (~5400 lines)
├── errors.py Exception hierarchy (~200 lines)
├── utils.py DB, embeddings, validation (~185 lines)
├── reasoning_helpers.py Bayesian scoring, quality (~310 lines)
├── learning_helpers.py RLVR, terminal parsing (~240 lines)
├── interview_helpers.py Interview flow (~220 lines)
├── codebase_helpers.py Symbol extraction (~260 lines)
├── sessions_helpers.py Session lifecycle (~270 lines)
├── metacognitive_helpers.py 5-stage prompting (~200 lines)
├── preflight_helpers.py Preflight enforcement (~180 lines)
├── calibration_helpers.py CSR calibration (~180 lines)
├── purpose_helpers.py Hierarchical inference (~150 lines)
├── hybrid_helpers.py Hypothesis synthesis (~120 lines)
└── self_awareness_helpers.py Schema introspection (~250 lines)
tests/
├── conftest.py Fixtures + Layer 4 failure logging
├── test_tools/ Layer 1: Static domain tests
│ ├── test_reasoning.py 16 tests (9 tools)
│ ├── test_learning.py 6 tests (4 tools)
│ ├── test_codebase.py 8 tests (8 tools)
│ ├── test_metacognitive.py 7 tests (3 tools)
│ └── test_interview.py 5 tests (4 tools)
├── scenarios/ Layer 2: YAML workflow tests
├── test_scenarios.py YAML runner
├── test_coverage.py Layer 3: Self-aware coverage
└── test_server.py Legacy v22/v23 testsDatabase Tables
Table | Purpose |
| Session state, goal, context |
| Hypothesis tree with Bayesian scores |
| Counterarguments and penalties |
| Grounding laws with weights |
| Success/failure for learning |
| Persistent user preferences |
| Archived Q&A for learning |
| Indexed project files |
| Extracted symbols |
| LSIF index data |
📚 Scientific Laws Library
PAS includes 15+ established laws to ground reasoning:
CAP Theorem - Distributed systems trade-offs
Occam's Razor - Prefer simpler solutions
Conway's Law - System structure mirrors organization
Hyrum's Law - All observable behaviors will be depended on
Brooks' Law - Adding people to late projects makes them later
Amdahl's Law - Parallel speedup limits
Hofstadter's Law - It always takes longer than expected
...and more
🧪 Testing
PAS includes a self-aware test suite that tests itself and logs discovered bugs back into PAS for learning.
Test Suite Architecture (v42)
Layer | Purpose | File(s) |
Layer 1 | Static unit tests for 38 tools |
|
Layer 2 | YAML-defined workflow scenarios |
|
Layer 3 | Self-aware coverage reporter |
|
Layer 4 | Failure logging to PAS |
|
Running Tests
# Full suite with PAS failure logging
PAS_DB_NAME=mcp_pas pytest tests/ -v
# Fast mode (no failure logging)
PAS_DB_NAME=mcp_pas PAS_LOG_FAILURES=false pytest tests/ -v
# Run only unit tests
PAS_DB_NAME=mcp_pas pytest tests/test_tools/ -v
# Run YAML scenarios
PAS_DB_NAME=mcp_pas pytest tests/test_scenarios.py -v
# Check coverage (fails if new tool lacks tests)
PAS_DB_NAME=mcp_pas pytest tests/test_coverage.py -vSelf-Aware Coverage
When new tools are added, test_coverage.py automatically fails with:
Missing tests for: [new_tool_name]This ensures test coverage grows with the codebase.
🤖 Model Compatibility
Model | Status |
Claude Opus 4.5 | ✅ Works |
Claude Sonnet 4.5 | ✅ Works |
Gemini 3 Flash | ✅ Works |
Gemini 3 Pro | ⚠️ Tool call format issues |
📈 Changelog
See CHANGELOG.md for version history.
Current version: v42-tests
🤝 Contributing
Contributions welcome! Areas of interest:
Additional scientific laws
New reasoning patterns
Domain-specific question sets
Performance optimizations
📄 License
GNU AGPLv3 License - see LICENSE for details.
🙏 Acknowledgments
Named after the three pillars of Western philosophy:
Plato - Ideation and hypothesis generation
Aristotle - Empirical grounding in scientific laws
Socrates - Dialectic critique and questioning
"The unexamined thought is not worth believing."
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Deterministic reasoning stack for AI agents: simulate, decide & compute, plus cross-domain tools.
Persistent memory and knowledge management for AI agents with semantic search and 50+ tools.
Code intelligence platform for AI agents. 20 tools for architecture, security & impact analysis.
Git-backed platform for skills, tools, and context for AI agents
Related MCP Servers
- AlicenseBqualityDmaintenanceProvides AI assistants with enhanced reasoning capabilities through structured thinking, persistent knowledge graph memory, and intelligent tool orchestration for complex problem-solving.2063MIT
- AlicenseAqualityCmaintenanceEnables structured step-by-step reasoning with branching, revisions, and self-critique to help break down complex problems into manageable steps with confidence tracking and thought history search.736 npm7MIT
- AlicenseBqualityDmaintenanceProvides 10 structured reasoning strategies (Chain of Thought, ReAct, Tree of Thoughts, etc.) for complex problem-solving with session persistence, branching, and tool integration capabilities.33 npm28MIT
- AlicenseNot gradedqualityDmaintenanceTransforms AI assistants into research-grade cognitive workspaces with systematic reasoning, evidence-based analysis, persistent memory management, and intelligent knowledge discovery.MIT