public
synced 2026-11-26 05:05:12 +00:00
watch 1
fork 0
you've already forked pi-hermes-mcp

latest commit message

Ryana Que
d72a5c3 2026-05-06 19:29:21 +08:00 11 commits
2026-05-06 19:08:24 +08:00
2026-05-06 19:08:24 +08:00

pi-to-mcp bridge

Production-shaped MCP bridge that gives Hermes/Rumi code intelligence and safe edit tooling without delegating cognition to Pi or any second LLM.

Architecture: Hermes/Rumi -> MCP tools -> local repo intelligence + LSP + safe edit harness.

Non-goal: Hermes -> Pi -> LLM.

run

Stable command:

/home/ubuntu/agent-lab/pi-mcp-bridge/bin/pi-mcp-bridge

Hermes MCP config snippet:

mcp_servers:
  pi_tools:
    command: "/home/ubuntu/agent-lab/pi-mcp-bridge/bin/pi-mcp-bridge"
    args: []
    timeout: 180
    connect_timeout: 30
    sampling:
      enabled: false

Full snippet lives in mcp.pi-tools.yaml.

Bootstrap/verify:

cd /home/ubuntu/agent-lab/pi-mcp-bridge
scripts/bootstrap.sh

tool groups

repo intelligence

  • repo_index: file/lang/import/symbol/reference/framework index.
  • index_status: JSON + SQLite cache paths, freshness, row counts.
  • repo_map: repo overview, markers, graph stats, agent instructions.
  • framework_map: Next.js, React Native/Expo, TypeScript, Go, Rust project shape.
  • route_map: Next App/Pages routes and React Native navigation screens.
  • dependency_graph: resolved import graph globally or around a file.
  • symbol_search, semantic_search, embedding_search: local search only, no external API keys.

true JSON-RPC LSP

  • lsp_definition
  • lsp_hover
  • lsp_references
  • lsp_code_actions
  • lsp_rename
  • lsp_rename_transaction
  • lsp_diagnostics
  • lsp_enriched_references
  • lsp_capabilities
  • lsp_session_status
  • lsp_cleanup
  • lsp_crash_session (ops/test helper)
  • monorepo_workspaces

Supported servers verified locally:

  • TypeScript/JavaScript: typescript-language-server --stdio
  • Go: gopls serve
  • Rust: rust-analyzer

The client speaks real stdio JSON-RPC, handles server-initiated requests such as workspace/configuration, reads notifications on a background thread, and returns LSP WorkspaceEdit previews instead of blindly writing. LSP processes are now managed across tool calls by workspace/language/command, with idle cleanup, stale-file refresh through didChange, crash detection/restart, and language-specific workspace roots for mixed monorepos.

safe edits and verification

  • edit_plan: exact-replace dry run with diff/blast radius/check plan.
  • safe_replace: exact replacement with diff/blast radius/optional diagnostics.
  • edit_transaction: exact replacement transaction report.
  • workspace_edit_preview: preview arbitrary LSP WorkspaceEdit as unified diffs.
  • workspace_edit_transaction: apply an LSP WorkspaceEdit only on a clean git tree, then report diff/blast radius/diagnostics/rollback.
  • verification_plan: checks for changed files.
  • checkpoint: git status or checkpoint commit.
  • audit_log: local JSONL audit trail.
  • bridge_healthcheck: end-to-end health and readiness.

cache and local state

Indexes live under:

~/.cache/pi-mcp-bridge/<repo-hash>/

Per repo cache files include:

  • index.json
  • index.sqlite3
  • audit.jsonl

No external embeddings/API keys are used. embedding_search uses local HashingVectorizer and logs compact metadata to SQLite for observability.

verification commands

cd /home/ubuntu/agent-lab/pi-mcp-bridge
. .venv/bin/activate
python -m py_compile server.py
PYTHONPATH=. pytest -q

Canary against bridge fixtures:

hermes --profile pi-mcp-canary chat -Q -q 'Use pi_tools on /home/ubuntu/agent-lab/pi-mcp-bridge/fixtures/lsp-ts. Call lsp_rename_transaction(file_path="main.ts", line=3, character=24, new_name="helperRenamed"), lsp_code_actions(file_path="main.ts", start_line=3, start_character=24), lsp_enriched_references(file_path="main.ts", line=3, character=24), and lsp_diagnostics(file_path="main.ts", wait_seconds=1).'

Canary against real app repo:

hermes --profile pi-mcp-canary chat -Q -q 'Use pi_tools on /home/ubuntu/agent-lab/real-app-canary/dashboard/starter-example. Call bridge_healthcheck, repo_map(refresh_index=true), framework_map(refresh_index=true), route_map(refresh_index=true), embedding_search(query="dashboard invoices customers revenue", limit=5, refresh_index=true), lsp_diagnostics(file_path="app/page.tsx", wait_seconds=1), and lsp_code_actions(file_path="app/page.tsx", start_line=1, start_character=0).'

Canary against mixed monorepo fixture:

pi-mcp-canary -z 'Use pi_tools on /home/ubuntu/agent-lab/pi-mcp-bridge/fixtures/lsp-monorepo. Call monorepo_workspaces, lsp_definition for apps/web/main.ts, services/api/main.go, crates/core/src/lib.rs, then lsp_cleanup(max_idle_seconds=0).'

current caveats

  • WorkspaceEdit application intentionally requires a clean git tree.
  • LSP rename apply is opt-in. Dry-run is default.