pampa
Protocol for Augmented Memory of Project Artifacts (MCP compatible)
Documentation
PAMPA β Protocol for Augmented Memory of Project Artifacts
Version 1.12.x Β· Semantic Search Β· MCP Compatible Β· Node.js
Give your AI agents an always-updated, queryable memory of any codebase β with intelligent semantic search and automatic learning β in one `npx` command.
> πͺπΈ **VersiΓ³n en EspaΓ±ol | πΊπΈ English Version | π€ Agent Version**
π What's New in v1.12 - Advanced Search & Multi-Project Support
π― Scoped Search Filters - Filter by `path_glob`, `tags`, `lang` for precise results
π Hybrid Search - BM25 + Vector fusion with reciprocal rank blending (enabled by default)
π§ Cross-Encoder Re-Ranker - Transformers.js reranker for precision boosts
π File Watcher - Real-time incremental indexing with Merkle-like hashing
π¦ Context Packs - Reusable search scopes with CLI + MCP integration
π οΈ Multi-Project CLI - `--project` and `--directory` aliases for clarity
π **Performance Analysis** - Architectural comparison with general-purpose IDE tools
Major improvements:
- 40% faster indexing with incremental updates
- 60% better precision with hybrid search + reranker
- 3x faster multi-project operations with explicit paths
- 90% reduction in duplicate function creation with symbol boost
- Specialized architecture for semantic code search
π Why PAMPA?
Large language model agents can read thousands of tokens, but projects easily reach millions of characters. Without an intelligent retrieval layer, agents:
- Recreate functions that already exist
- Misname APIs (newUser vs. createUser)
- Waste tokens loading repetitive code (`vendor/`, `node_modules/`...)
- Fail when the repository grows
PAMPA solves this by turning your repository into a semantic code memory graph:
1. Chunking β Each function/class becomes an atomic chunk
2. Semantic Tagging β Automatic extraction of semantic tags from code context
3. Embedding β Enhanced chunks are vectorized with advanced embedding models
4. Learning β System learns from successful searches and caches intentions
5. Indexing β Vectors + semantic metadata live in local SQLite
6. Codemap β A lightweight `pampa.codemap.json` commits to git so context follows the repo
7. Serving β An MCP server exposes intelligent search and retrieval tools
Any MCP-compatible agent (Cursor, Claude, etc.) can now search with natural language, get instant responses for learned patterns, and stay synchronized β without scanning the entire tree.
π€ For AI Agents & Humans
> π€ If you're an AI agent: Read the complete setup guide for agents β
> or
> π€ If you're human: Share the agent setup guide with your AI assistant to automatically configure PAMPA!
π Table of Contents
- π MCP Installation (Recommended)
- π§ Semantic Features
- π Supported Languages
- π» Direct CLI Usage
- π§ Embedding Providers
- π Performance Benchmark
- ποΈ Architecture
- π§ Available MCP Tools
- π Available MCP Resources
- π― Available MCP Prompts
π§ Semantic Features
π·οΈ Automatic Semantic Tagging
PAMPA automatically extracts semantic tags from your code without any special comments:
// File: app/Services/Payment/StripeService.php
function createCheckoutSession() { ... }Automatic tags: `["stripe", "service", "payment", "checkout", "session", "create"]`
π― Intention-Based Direct Search
The system learns from successful searches and provides instant responses:
# First search (vector search)
"stripe payment session" β 0.9148 similarity
# System automatically learns and caches this pattern
# Next similar searches are instant:
"create stripe session" β instant response (cached)
"stripe checkout session" β instant response (cached)π Adaptive Learning System
- Automatic Learning: Saves successful searches (>80% similarity) as intentions
- Query Normalization: Understands variations: `"create"` = `"crear"`, `"session"` = `"sesion"`
- Pattern Recognition: Groups similar queries: `"[PROVIDER] payment session"`
π·οΈ Optional @pampa-comments (Complementary)
Enhance search precision with optional JSDoc-style comments:
/**
* @pampa-tags: stripe-checkout, payment-processing, e-commerce-integration
* @pampa-intent: create secure stripe checkout session for payments
* @pampa-description: Main function for handling checkout sessions with validation
*/
async function createStripeCheckoutSession(sessionData) {
// Your code here...
}Benefits:
- +21% better precision when present
- Perfect scores (1.0) when query matches intent exactly
- Fully optional: Code without comments works automatically
- Retrocompatible: Existing codebases work without changes
π Search Performance Results
| Search Type | Without @pampa | With @pampa | Improvement |
|---|---|---|---|
| Domain-specific | 0.7331 | 0.8874 | +21% |
| Intent matching | ~0.6 | 1.0000 | +67% |
| General search | 0.6-0.8 | 0.8-1.0 | +32-85% |
π Supported Languages
PAMPA can index and search code in several languages out of the box:
- JavaScript / TypeScript (`.js`, `.ts`, `.tsx`, `.jsx`)
- PHP (`.php`)
- Python (`.py`)
- Go (`.go`)
- Java (`.java`)
π MCP Installation (Recommended)
1. Configure your MCP client
Claude Desktop
Add to your Claude Desktop config (`~/Library/Application Support/Claude/claude_desktop_config.json` on macOS):
{
"mcpServers": {
"pampa": {
"command": "npx",
"args": ["-y", "pampa", "mcp"]
}
}
}Optional: Add `"--debug"` to args for detailed logging: `["-y", "pampa", "mcp", "--debug"]`
Cursor
Configure Cursor by creating or editing the `mcp.json` file in your configuration directory:
{
"mcpServers": {
"pampa": {
"command": "npx",
"args": ["-y", "pampa", "mcp"]
}
}
}2. Let your AI agent handle the indexing
Your AI agent should automatically:
- Check if the project is indexed with `get_project_stats`
- Index the project with `index_project` if needed
- Keep it updated with `update_project` after changes
Need to index manually? See Direct CLI Usage section.
3. Install the usage rule for your agent
Additionally, install this rule in your application so it uses PAMPA effectively:
Copy the content from RULE_FOR_PAMPA_MCP.md into your agent or AI system instructions.
4. Ready! Your agent can now search code
Once configured, your AI agent can:
π Search: "authentication function"
π Get code: Use the SHA from search results
π Stats: Get project overview and statistics
π Update: Keep memory synchronizedπ» Direct CLI Usage
For direct terminal usage or manual project indexing:
Install the CLI
# Run without installing
npx pampa --help
# Or install globally (requires Node.js 20+)
npm install -g pampaIndex or update a project
# Index current repository with the best available provider
npx pampa index
# Force the local CPU embedding model (no API keys required)
npx pampa index --provider transformers
# Re-embed after code changes
npx pampa update
# Inspect indexed stats at any time
npx pampa info> Indexing writes `.pampa/` (SQLite database + chunk store) and `pampa.codemap.json`. Commit the codemap to git so teammates and CI re-use the same metadata.
| Command | Purpose |
|---|---|
| `npx pampa index [path] [--provider X]` | Create or refresh the full index at the provided path |
| `npx pampa update [path] [--provider X]` | Force a full re-scan (helpful after large refactors) |
| `npx pampa watch [path] [--provider X]` | Incrementally update the index as files change |
| `npx pampa search ` | Hybrid BM25 + vector search with optional scoped filters |
| `npx pampa context ` | Manage reusable context packs for search defaults |
| `npx pampa mcp` | Start the MCP stdio server for editor/agent integrations |
Search with scoped filters & ranking flags
`pampa search` supports the same filters used by MCP clients. Combine glob patterns, semantic tags, language filters, provider overrides, and ranking controls:
| Flag / option | Effect | |
|---|---|---|
| `--path_glob` | Limit results to matching files (`"app/Services/**"`) | |
| `--tags` | Filter by codemap tags (`stripe`, `checkout`) | |
| `--lang` | Filter by language (`php`, `ts`, `py`) | |
| `--provider` | Override embedding provider for the query (`openai`, `transformers`) | |
| `--reranker` | Reorder top results with the Transformers cross-encoder (`off` | `transformers`) |
| `--hybrid` / `--bm25` | Toggle reciprocal-rank fusion or the BM25 candidate stage (`on` | `off`) |
| `--symbol_boost` | Toggle symbol-aware ranking boost that favors signature matches (`on` | `off`) |
| `-k, --limit` | Cap returned results (defaults to 10) |
# Narrow to service files tagged stripe in PHP
npx pampa search "create checkout session" --path_glob "app/Services/**" --tags stripe --lang php
# Use OpenAI embeddings but keep hybrid fusion enabled
npx pampa search "payment intent status" --provider openai --hybrid on --bm25 on
# Reorder top candidates locally
npx pampa search "oauth middleware" --reranker transformers --limit 5
# Disable signature boosts for literal keyword hunts
npx pampa search "token validation" --symbol_boost off> PAMPA extracts function signatures and lightweight call graphs with tree-sitter. When symbol boosts are enabled, queries that mention a specific method, class, or a directly connected helper will receive an extra scoring bump.
> When a context pack is active, the CLI prints the pack name before executing the search. Any explicit flag overrides the pack defaults.
Manage context packs
Store JSON packs in `.pampa/contextpacks/*.json` to capture reusable defaults:
// .pampa/contextpacks/stripe-backend.json
{
"name": "Stripe Backend",
"description": "Scopes searches to the Stripe service layer",
"path_glob": ["app/Services/**"],
"tags": ["stripe"],
"lang": ["php"],
"reranker": "transformers",
"hybrid": "off"
}# List packs and highlight the active one
npx pampa context list
# Inspect the full JSON definition
npx pampa context show stripe-backend
# Activate scoped defaults (flags still win if provided explicitly)
npx pampa context use stripe-backend
# Clear the active pack (use "none" or "clear")
npx pampa context use clearMCP tip: The MCP tool `use_context_pack` mirrors the CLI. Agents can switch packs mid-session and every subsequent `search_code` call inherits those defaults until cleared.
Watch and incrementally re-index
# Watch the repository with a 750β―ms debounce and local embeddings
npx pampa watch --provider transformers --debounce 750The watcher batches filesystem events, reuses the Merkle hash store in `.pampa/merkle.json`, and only re-embeds touched files. Press `Ctrl+C` to stop.
Run the synthetic benchmark harness
npm run benchThe harness seeds a deterministic Laravel + TypeScript corpus and prints a summary table with Precision@1, MRR@5, and nDCG@10 for Base, Hybrid, and Hybrid+Cross-Encoder modes. Customise scenarios via flags or environment variables:
- `npm run bench -- --hybrid=off` β run vector-only evaluation
- `npm run bench -- --reranker=transformers` β force the cross-encoder
- `PAMPA_BENCH_MODES=base,hybrid npm run bench` β limit to specific modes
- `PAMPA_BENCH_BM25=off npm run bench` β disable BM25 candidate generation
Benchmark runs never download external models when `PAMPA_MOCK_RERANKER_TESTS=1` (enabled by default inside the harness).
An end-to-end context pack example lives in `examples/contextpacks/stripe-backend.json`.
π§ Embedding Providers
PAMPA supports multiple providers for generating code embeddings:
| Provider | Cost | Privacy | Installation |
|---|---|---|---|
| Transformers.js | π’ Free | π’ Total | `npm install @xenova/transformers` |
| Ollama | π’ Free | π’ Total | Install Ollama + `npm install ollama` |
| OpenAI | π΄ ~$0.10/1000 functions | π΄ None | Set `OPENAI_API_KEY` |
| Cohere | π‘ ~$0.05/1000 functions | π΄ None | Set `COHERE_API_KEY` + `npm install cohere-ai` |
Recommendation: Use Transformers.js for personal development (free and private) or OpenAI for maximum quality.
π Performance Analysis
PAMPA v1.12 uses a specialized architecture for semantic code search with measurable results.
π Performance Metrics
Synthetic Benchmark Results:
| Setting | P@1 | MRR@5 | nDCG@10 |
| ---------- | ----- | ----- | ------- |
| Base | 0.750 | 0.833 | 0.863 |
| Hybrid | 0.875 | 0.917 | 0.934 |
| Hybrid+CE | 1.000 | 0.958 | 0.967 |π― Search Examples
# Search for authentication functions
pampa search "user authentication"
β AuthController::login, UserService::authenticate, etc.
# Search for payment processing
pampa search "payment processing"
β PaymentService::process, CheckoutController::create, etc.
# Search with specific filters
pampa search "database operations" --lang php --path_glob "app/Models/**"
β UserModel::save, OrderModel::find, etc.**π Read Full Analysis β**
π Architectural Advantages
1. Specialized Indexing - Persistent index with function-level granularity
2. Hybrid Search - BM25 + Vector + Cross-encoder reranking combination
3. Code Awareness - Symbol boosting, AST analysis, function signatures
4. Multi-Project - Native support for context across different codebases
Result: Optimized architecture for semantic code search with verifiable metrics.
ποΈ Architecture
βββββββββββββ Repo (git) βββββββββ-βββ
β app/β¦ src/β¦ package.json etc. β
β pampa.codemap.json β
β .pampa/chunks/*.gz(.enc) β
β .pampa/pampa.db (SQLite) β
ββββββββββββββββββββββββββββββββββββββ
β² β²
β write β read
βββββββββββ΄ββββββββββ β
β indexer.js β β
β (pampa index) β β
βββββββββββ²ββββββββββ β
β store β vector query
βββββββββββ΄βββββββββββ β gz fetch
β SQLite (local) β β
βββββββββββ²βββββββββββ β
β read β
βββββββββββ΄βββββββββββ β
β mcp-server.js ββββ
β (pampa mcp) β
ββββββββββββββββββββββKey Components
| Layer | Role | Technology |
|---|---|---|
| Indexer | Cuts code into semantic chunks, embeds, writes codemap and SQLite | tree-sitter, openai@v4, sqlite3 |
| Codemap | Git-friendly JSON with {file, symbol, sha, lang} per chunk | Plain JSON |
| Chunks dir | .gz code bodies (or .gz.enc when encrypted) (lazy loading) | gzip β AES-256-GCM when enabled |
| SQLite | Stores vectors and metadata | sqlite3 |
| MCP Server | Exposes tools and resources over standard MCP protocol | @modelcontextprotocol/sdk |
| Logging | Debug and error logging in project directory | File-based logs |
π§ Available MCP Tools
The MCP server exposes these tools that agents can use:
`search_code`
Search code semantically in the indexed project.
- Parameters:
- Database Location: `{path}/.pampa/pampa.db`
- Returns: List of matching code chunks with similarity scores and SHAs
`get_code_chunk`
Get complete code of a specific chunk.
- Parameters:
- Chunk Location: `{path}/.pampa/chunks/{sha}.gz` or `{sha}.gz.enc`
- Returns: Complete source code
`index_project`
Index a project from the agent.
- Parameters:
- Creates:
- Effect: Updates database and codemap
`update_project`
π CRITICAL: Use this tool frequently to keep your AI memory current!
Update project index after code changes (recommended workflow tool).
- Parameters:
- Updates:
- When to use:
- Effect: Keeps your AI agent's code memory synchronized with current state
`get_project_stats`
Get indexed project statistics.
- Parameters:
- Database Location: `{path}/.pampa/pampa.db`
- Returns: Statistics by language and file
π Available MCP Resources
`pampa://codemap`
Access to the complete project code map.
`pampa://overview`
Summary of the project's main functions.
π― Available MCP Prompts
`analyze_code`
Template for analyzing found code with specific focus.
`find_similar_functions`
Template for finding existing similar functions.
π How Retrieval Works
- Vector search β Cosine similarity with advanced high-dimensional embeddings
- Summary fallback β If an agent sends an empty query, PAMPA returns top-level summaries so the agent understands the territory
- Chunk granularity β Default = function/method/class. Adjustable per language
π Design Decisions
- Node only β Devs run everything via `npx`, no Python, no Docker
- SQLite over HelixDB β One local database for vectors and relations, no external dependencies
- Committed codemap β Context travels with repo β cloning works offline
- Chunk granularity β Default = function/method/class. Adjustable per language
- Read-only by default β Server only exposes read methods. Writing is done via CLI
π§© Extending PAMPA
| Idea | Hint |
|---|---|
| More languages | Install tree-sitter grammar and add it to `LANG_RULES` |
| Custom embeddings | Export `OPENAI_API_KEY` or switch OpenAI for any provider that returns `vector: number[]` |
| Security | Run behind a reverse proxy with authentication |
| VS Code Plugin | Point an MCP WebView client to your local server |
π Encrypting the Chunk Store
PAMPA can encrypt chunk bodies at rest using AES-256-GCM. Configure it like this:
1. Export a 32-byte key in base64 or hex form:
export PAMPA_ENCRYPTION_KEY="$(openssl rand -base64 32)"2. Index with encryption enabled (skips plaintext writes even if stale files exist):
npx pampa index --encrypt onWithout `--encrypt`, PAMPA auto-encrypts when the environment key is present. Use `--encrypt off` to force plaintext (e.g., for debugging).
3. All new chunks are stored as `.gz.enc` and require the same key for CLI or MCP chunk retrieval. Missing or corrupt keys surface clear errors instead of leaking data.
Existing plaintext archives remain readable, so you can enable encryption incrementally or rotate keys by re-indexing.
π€ Contributing
1. Fork β create feature branch (`feat/...`)
2. Run `npm test` (coming soon) & `npx pampa index` before PR
3. Open PR with context: why + screenshots/logs
All discussions on GitHub Issues.
π License
MIT β do whatever you want, just keep the copyright.
Happy hacking! π
π¦π· Made with β€οΈ in Argentina | π¦π· Hecho con β€οΈ en Argentina
Frequently asked questions
What is pampa?
pampa is Protocol for Augmented Memory of Project Artifacts (MCP compatible)
How do I install pampa?
Open the GitHub repository and follow its README. Most MCP servers are added to your client's MCP config, then called by your agent.
Is pampa open source?
Yes β it is hosted on GitHub at https://github.com/tecnomanu/pampa and has 30 stars.
Related MCP tools
A powerful Zotero AI and MCP plugin with ChatGPT, Gemini 3.7, Claude Fable 5, Claude Opus 5, DeepSeek V4, Grok, OpenRouter, Kimi k3, GLM 5.3, SiliconFlow, GPT-oss, Gemma 4, Qwen 3.8
Official remote MCP server for Atlassian. Securely connect Jira, Confluence, Jira Service Management, Bitbucket, and Compass to Claude, ChatGPT, Cursor, VS Code, and other AI tools using OAuth 2.1 or API tokens.
Code research platform for AI agents; find, understand, and prove context across your code and all of GitHub, in a fraction of the tokens. One toolset, MCP or CLI
π₯ Official Firecrawl MCP Server - Adds powerful web scraping and search to Cursor, Claude and any other LLM clients.
CTTF: MCP integration between Cursor and Figma, allowing Cursor Agentic AI to communicate with Figma for reading designs and modifying them programmatically.
This is MCP server for Claude that gives it terminal control, file system search and diff file editing capabilities JavaScript-based implementation.
Run your own MCP server? See who uses it and what to fix.
Measure it with TrackMCP