mcp-code-shrinker
Integrates with Hermes Agent, providing repository-scoped context management and patch workflow tools for code understanding and modification.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@mcp-code-shrinkershow the project map and top-level exports"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
MCP Code Shrinker v0.4.1
Semantic Context Compiler — stratified L0-L3 context with exact-source escalation, stable symbol IDs, and repository-scoped isolation. MCP server for Hermes Agent.
Architecture
┌──────────────────────────────────────────────────────────────┐
│ CONTEXT LAYERS │
│ │
│ L0: Project Map (5%) file tree + exports │
│ L1: Semantic Contracts (40%) signatures, effects, throws │
│ L2: Exact Source (40%) NO renaming, NO regex mods │
│ L3: Evidence (15%) tests, stack traces, logs │
├──────────────────────────────────────────────────────────────┤
│ SYMBOL MODEL │
│ │
│ Stable Symbol ID = f(repository-slot.root, file_path, │
│ language, node_type, qualified_name, │
│ signature) │
│ │
│ → Survives neighbor edits │
│ → NFC-normalized, forward-slash paths │
│ → Scoped to repository (different repos = different IDs) │
├──────────────────────────────────────────────────────────────┤
│ REPOSITORY ISOLATION │
│ │
│ requireRepositoryId(args) P0 guard │
│ requireIndex(repoId) slot verification │
│ isInside(slot.root, filePath) path containment │
│ resolveInsideRoot(filePath) canonical path │
│ canonicalRepoPath(path) NFC + POSIX slashes │
│ │
│ → Foreign-repo files: PATH_OUTSIDE_REPOSITORY error │
│ → watch_stop: preserves repository slot │
│ → context.expand: validates implicit targetFile │
├──────────────────────────────────────────────────────────────┤
│ PATCH WORKFLOW │
│ │
│ patch.propose → patch.validate → patch.apply │
│ │ │
│ ├─ hash re-check │
│ ├─ .bak backup │
│ ├─ repository slot bound │
│ └─ outcome → Memory Wiki │
└──────────────────────────────────────────────────────────────┘Related MCP server: code-graph-rag-mcp
Key Guarantees
Symbol ID Stability
Survives neighbor edits: adding/removing unrelated symbols does NOT change existing IDs
NFC normalization: Unicode canonical composition for cross-platform consistency
Forward-slash paths:
\→/for POSIX compatibilityRepository-scoped: same code in different repos → different symbol IDs
Repository Isolation
Every tool requires
repository_id:file.contracts,symbol.source,context.create,context.expandPath containment:
isInside(slot.root, filePath)— rejects files outside repository rootSlot lifecycle:
watch_stopstops watcher but preserves repository bindingCanonical paths: NFC + POSIX slashes + resolved symlinks
Context Packet Protocol
Ranking: symbols sorted by token count (descending)
Quality check: contracts must pass confidence threshold
Coverage manifest: tracks what symbols are already in context
Loss manifest: reports missing symbols with reasons
No double-relative: prevents duplicate file paths in packets
Exact-Source Escalation
Layer 2 returns raw source code with ZERO modifications
No regex replacement, no renaming, no format changes
Contract + source separation: model can verify contract accuracy
Tools (29)
The MCP server publishes exactly the tools declared by src/index.js:
Project, files, symbols and watchers (10)
project.scanproject.mapproject.watch_startproject.watch_stopproject.watch_statusproject.snapshotproject.changed_symbolsfile.contractssymbol.sourcesymbol.context
Artifact Store (9)
artifact.putartifact.getartifact.get_chunkartifact.copy_textartifact.pinartifact.deleteartifact.listartifact.statsartifact.gc
Context (3)
context.createcontext.expandcontext.inspect
Targets accept equivalent plain, handle and qualified forms, for example add, @add and Calculator.add.
Single-file patch workflow (3)
patch.proposepatch.validatepatch.apply
JavaScript validation always requires syntax success. Lint, typecheck and tests are executed when available and fail validation when they run and report errors. Optional unavailable checks no longer block patch.apply. Strict installations can require checks with CODE_SHRINKER_REQUIRED_CHECKS_JSON, for example ["parse","lint","tests"].
Atomic multi-file patch workflow (4)
patchset.proposepatchset.validatepatchset.applypatchset.rollback
The removed development tools (code.generate, code.review, debug.trace, exec.test and related names) are not part of this server.
Installation
git clone https://github.com/sbrejnev988-coder/mcp-code-shrinker.git
cd mcp-code-shrinker
npm install
npm testHermes Integration
The Code Shrinker MCP server is registered in ~/.hermes/config.yaml:
mcp_servers:
code-shrinker:
command: node
args: ["src/index.js"]
cwd: "~/.hermes/workspace/mcp-code-shrinker"Repository-Scope Integration with Memory Wiki
Code Shrinker Memory Wiki
────────────── ───────────
context.create() ──coverage────────► _pack_context()
manifest │
┌─ repository_id ├─ _classify_coverage()
├─ covered: [{ │ SHA-256 normalized
│ kind: "source"|"contract" │ repository_id match
│ file_path: NFC-canonical │ hard-suppress foreign repos
│ symbol_id: stable hash │
│ content_hash: sha256:... │
│ token_count ├─ suppressed_claim_ids
│ }] │
└─ loss: [...] └─ output → context for LLM
↓
_memory_diff() — excludes suppressed
_preference_layer() — excludes suppressedCross-Plugin Hash Protocol v2
Both plugins normalize SHA-256: lowercase, strip
sha256:prefixNFC path canonization on both sides
repository_idrequired on all code claim operationscontent_hashused for exact-match deduplication
P0/P1 Forensic Fixes Applied
P0 (Repository Scope)
✅
file.contractsrequiresrepository_id+ slot.root guard✅
symbol.sourcerequiresrepository_id+ slot.root guard✅ Foreign-repo files rejected:
PATH_OUTSIDE_REPOSITORY✅
context.expandvalidates implicit targetFile against slot.root✅
watch_stoppreserves repository slot (does not delete from indexes)✅
createSymbolIdNFC + forward-slash normalization✅
canonicalRepoPathdouble-relative fix✅ Symbol ID uses
slot.rootnotrootForFile(fp)
P1 (Forensic)
✅
patch.proposestores repository identity/root✅
patch.validatebound to repository slot✅
patch.applybound to repository slot✅ MCP annotations: explicit mutation/destruction sets
Path Security Model
Allowed Roots (from Hermes config):
~/workspace
~/plugins
~/.hermes/proxy
Symbol resolution:
slot.root → canonicalRepoPath(root) → isInside(root, filePath)
YES: ~/workspace/project/src/index.js → resolves
NO: /tmp/outside.js → PATH_OUTSIDE_REPOSITORY
NO: ~/workspace/project/../outside.js → double-relative blockedPerformance
Operation | Typical Time |
| 50-200ms |
| 10-50ms |
| 200-500ms |
| 500-2000ms |
| 100-300ms |
Symbol ID computation | <1ms |
License
MIT
Integration lifecycle v0.4.0
patch.apply and patchset.apply now refresh the repository index synchronously and emit an atomic event under $HERMES_HOME/context-coordination/inbox/code-shrinker. Memory Wiki consumes the event idempotently, stores a structured patch outcome, and archives claims for older file revisions. Coverage manifests use Hash Protocol v2.
Validation policy v0.4.1
Default policy requires successful syntax parsing. Available ESLint, TypeScript and test checks are still authoritative: a reported failure makes the patch invalid. A missing optional executable produces a recorded skipped step but no longer turns an otherwise valid JavaScript patch into inconclusive.
For fail-closed production policy:
export CODE_SHRINKER_REQUIRED_CHECKS_JSON='["parse","lint","tests"]'For one complete repository command:
export CODE_SHRINKER_VALIDATE_CMD_JSON='["npm","test"]'Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
AlicenseAqualityCmaintenanceMCP server that provides AI assistants with structured access to codebases via LogicStamp Context, enabling component analysis, dependency graphs, drift detection, and token-optimized context delivery.7234MIT- Alicense-qualityFmaintenanceA powerful Model Context Protocol server that creates intelligent graph representations of your codebase with comprehensive semantic analysis capabilities, supporting 11 languages and 26 MCP methods.94121MIT
- AlicenseBqualityBmaintenanceA high-performance MCP server for intelligent documentation search, proactive bug detection, and semantic analysis of codebases.2515MIT
- -license-qualityCmaintenanceAn MCP server implementing a multi-phase backend for structured model interactions, bounded compilation, exact-hash confirmation, and Codex-run provenance, with trust-separation hardening.1
Related MCP Connectors
A MCP server built for developers enabling Git based project management with project and personal…
Augments MCP Server - A comprehensive framework documentation provider for Claude Code
Hosted MCP server for structured code review passes on human- and AI-written code. Free tier.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/sbrejnev988-coder/mcp-code-shrinker'
If you have feedback or need assistance with the MCP directory API, please join our Discord server