PAMPA 标志

PAMPA

社区
tecnomanu

Protocol for Augmented Memory of Project Artifacts (MCP compatible)

发布者tecnomanu
代码仓库pampa
语言JavaScript
复刻数
13
星标数
30
可用工具
0
传输类型stdio
分类
许可协议ISC
链接
  • 将工具接入 AI 工作流

    PAMPA 提供 MCP 功能,可供兼容的 AI 客户端和智能体使用。

  • 0 个可用工具

    浏览下方可调用的操作;如果服务器提供了名称和描述,也会一并显示。

  • 可直接复制的配置

    使用安装配置片段,在您首选的 MCP 客户端中配置此服务器。

  • 开源社区热度

    关联的代码仓库有 30 个星标和 13 个复刻。

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

🧠 Semantic Features

🏷️ Automatic Semantic Tagging

PAMPA automatically extracts semantic tags from your code without any special comments:

javascript
// 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:

bash
# 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:

javascript
/**
 * @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 TypeWithout @pampaWith @pampaImprovement
Domain-specific0.73310.8874+21%
Intent matching~0.61.0000+67%
General search0.6-0.80.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):

json
{
	"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:

json
{
	"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

bash
# Run without installing
npx pampa --help

# Or install globally (requires Node.js 20+)
npm install -g pampa

Index or update a project

bash
# 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 <query> | Hybrid BM25 + vector search with optional scoped filters | | npx pampa context <list | show | use> | 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) |

bash
# 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:

jsonc
// .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"
}
bash
# 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 clear

MCP 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

bash
# Watch the repository with a 750 ms debounce and local embeddings
npx pampa watch --provider transformers --debounce 750

The 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

bash
npm run bench

The 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:

ProviderCostPrivacyInstallation
Transformers.js🟢 Free🟢 Totalnpm install @xenova/transformers
Ollama🟢 Free🟢 TotalInstall Ollama + npm install ollama
OpenAI🔴 ~$0.10/1000 functions🔴 NoneSet OPENAI_API_KEY
Cohere🟡 ~$0.05/1000 functions🔴 NoneSet 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

bash
# 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

LayerRoleTechnology
IndexerCuts code into semantic chunks, embeds, writes codemap and SQLitetree-sitter, openai@v4, sqlite3
CodemapGit-friendly JSON with {file, symbol, sha, lang} per chunkPlain JSON
Chunks dir.gz code bodies (or .gz.enc when encrypted) (lazy loading)gzip → AES-256-GCM when enabled
SQLiteStores vectors and metadatasqlite3
MCP ServerExposes tools and resources over standard MCP protocol@modelcontextprotocol/sdk
LoggingDebug and error logging in project directoryFile-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:
    • query (string) - Semantic search query (e.g., "authentication function", "error handling")
    • limit (number, optional) - Maximum number of results to return (default: 10)
    • provider (string, optional) - Embedding provider (default: "auto")
    • path (string, optional) - PROJECT ROOT directory path where PAMPA database is located
  • 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:
    • sha (string) - SHA of the code chunk to retrieve (obtained from search_code results)
    • path (string, optional) - PROJECT ROOT directory path (same as used in search_code)
  • Chunk Location: {path}/.pampa/chunks/{sha}.gz or {sha}.gz.enc
  • Returns: Complete source code

index_project

Index a project from the agent.

  • Parameters:
    • path (string, optional) - PROJECT ROOT directory path to index (will create .pampa/ subdirectory here)
    • provider (string, optional) - Embedding provider (default: "auto")
  • Creates:
    • {path}/.pampa/pampa.db (SQLite database with embeddings)
    • {path}/.pampa/chunks/ (compressed code chunks)
    • {path}/pampa.codemap.json (lightweight index for version control)
  • 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:
    • path (string, optional) - PROJECT ROOT directory path to update (same as used in index_project)
    • provider (string, optional) - Embedding provider (default: "auto")
  • Updates:
    • Re-scans all files for changes
    • Updates embeddings for modified functions
    • Removes deleted functions from database
    • Adds new functions to database
  • When to use:
    • ✅ At the start of development sessions
    • ✅ After creating new functions
    • ✅ After modifying existing functions
    • ✅ After deleting functions
    • ✅ Before major code analysis tasks
    • ✅ After refactoring code
  • Effect: Keeps your AI agent's code memory synchronized with current state

get_project_stats

Get indexed project statistics.

  • Parameters:
    • path (string, optional) - PROJECT ROOT directory path where PAMPA database is located
  • 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

IdeaHint
More languagesInstall tree-sitter grammar and add it to LANG_RULES
Custom embeddingsExport OPENAI_API_KEY or switch OpenAI for any provider that returns vector: number[]
SecurityRun behind a reverse proxy with authentication
VS Code PluginPoint 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:

    bash
    export PAMPA_ENCRYPTION_KEY="$(openssl rand -base64 32)"
  2. Index with encryption enabled (skips plaintext writes even if stale files exist):

    bash
    npx pampa index --encrypt on

    Without --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

安装

TypingMind
{
  "mcpServers": {
    "pampa": {
      "command": "npx",
      "args": [
        "-y",
        "pampa",
        "mcp"
      ]
    }
  }
}

将 PAMPA MCP 与多个 AI 模型配合使用

TypingMind 在工作区级别连接 MCP 工具,因此连接 PAMPA 后,您就可以在 TypingMind 中搭配不同的 AI 模型使用,无需为每个模型单独设置。 此 MCP 通过您设备上的 TypingMind MCP 连接器在本地运行。

本地连接器设置指南

如果 MCP 服务器需要访问您电脑上的本地文件、应用或私有资源,请选择此方式。

1

打开 MCP 设置

在 TypingMind 中,依次前往“设置”、“高级设置”和“模型上下文协议”,然后选择“设置连接器”。

  1. 在您的浏览器中打开 TypingMind。
  2. 点击“设置”图标。
  3. 进入“高级设置”。
  4. 打开“模型上下文协议”部分。
  5. 点击“设置连接器”,然后选择“此设备”。
TypingMind MCP 连接器设置界面,已选择“此设备”
2

运行连接器命令

选择“此设备”,从 TypingMind 复制命令并在终端中运行。使用 MCP 时,请保持该进程运行。

  1. 复制 TypingMind 显示的设置命令。
  2. 在 macOS 上打开“终端”,或在 Windows 上打开 Windows Terminal。
  3. 粘贴并运行命令。
  4. 如果终端询问您是否继续,请确认安装软件包。
  5. 使用 MCP 工具时,请勿关闭终端窗口或停止其中的连接器进程。
3

将 PAMPA 添加为服务器

当连接器状态为“就绪”时,点击“编辑服务器”,然后粘贴 MCP 服务器配置。

  1. 等待连接器状态显示为“就绪”。
  2. 点击“编辑服务器”。
  3. 粘贴 PAMPA MCP 服务器配置。
  4. 保存服务器列表。
  5. 如需确认连接器是否仍处于就绪状态,请刷新。
TypingMind MCP 设置界面,显示正在运行的服务器和“编辑服务器”按钮
{
  "mcpServers": {
    "pampa": {
      "command": "npx",
      "args": [
        "-y",
        "pampa"
      ]
    }
  }
}
4

在不同模型中使用同一连接

保存服务器列表,打开“插件”,启用 PAMPA MCP 工具,然后在 TypingMind 中选择任意受支持的 AI 模型,即可在聊天中使用这些工具,或将其分配给智能体。

  1. 在 TypingMind 中打开“插件”页面。
  2. 启用 PAMPA MCP 工具。
  3. 开始聊天并选择您想使用的 AI 模型。
  4. 在聊天中使用 MCP 工具,或将其分配给 AI 智能体。
  5. 根据需要随时切换到其他 AI 模型,无需重新连接 MCP。
在 TypingMind 聊天中使用已启用的 MCP 工具和选定的 AI 模型
您能使用 PAMPA 帮我完成这项任务吗?
PAMPA
当然,我看过了。
以下是我使用 PAMPA 得到的结果。

常见问题

PAMPA MCP 服务器有什么用途?

PAMPA 是一个 MCP 服务器,可让兼容的 AI 客户端连接外部工具并获取上下文。在 TypingMind 中,只需添加一次此 MCP 服务器,即可在您的 AI 工作区中使用其工具。

可以在 TypingMind 中让多个 AI 模型使用 PAMPA MCP 吗?

可以。TypingMind 在工作区层面连接 MCP 工具,因此您无需为每个模型单独配置 MCP 服务器,就能在 Claude、ChatGPT、Gemini 或您在 TypingMind 中配置的其他 AI 模型中使用 PAMPA。

为什么在 TypingMind 中使用 PAMPA MCP?

TypingMind 将多个 AI 模型、提示词、插件、AI 智能体、API 密钥和 MCP 工具整合到同一个工作区中,是最出色的大语言模型聊天前端之一。连接 PAMPA 后,您可以在偏好的不同模型中使用其 MCP 工具,同时在 TypingMind 中井然有序地管理聊天工作流程。

如何将 PAMPA MCP 连接到 TypingMind?

PAMPA 通过 TypingMind 本地 MCP 连接器运行。当 MCP 服务器需要访问您计算机上的本地文件、桌面应用、命令行工具或私有资源时,这种方式最合适。

PAMPA MCP 在 TypingMind 中提供哪些工具?

PAMPA 提供 MCP 功能,您可以在 TypingMind 的插件页面启用这些功能,然后在聊天中使用,或将其分配给 AI 智能体。

使用 PAMPA MCP 需要向 TypingMind 提供我的 API 密钥吗?

不需要。TypingMind 采用本地优先的设计,让您自行选择模型提供商,并自行管理 API 密钥、提示词和 MCP 配置。如果 PAMPA 需要身份验证,请在创建连接时,为该 MCP 服务器添加所需的请求头、OAuth 设置或本地配置。

相关 MCP 服务器

查看全部

立即创建您自己的 AI 工作区

订阅我们的电子简报,获取新功能和后续赠奖活动的通知 👇