Magento-MCP-Server
AGENTS.md1 starsChanged 5 months agoMITView on GitHub
Magentic is a Docker-based MCP server for agentic AI workflows. It uses an npm workspace monorepo with two Node.js application packages and one PHP analyzer package: README.md in the repository root covers setup, running the stack, and operational commands. Architecture and reference notes live in the docs/ directory: The Compose project is named magentic. Main services:
- Sends data out
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about code style.
Of the AGENTS.md files we read, the 35,266 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository5 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- clean-code-passSkill
- git-commit-and-pushSkill
- clean-code-passSkill
- git-commit-and-pushSkill
The file
We split this AGENTS.md into the rules it gives an agent
11 rules. About 0 are common, 6 are distinctive, and 5 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈6
Distinctive · estimate
This author's own choices. Worth a look.
5
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 122
Keep source-code comments out.
- Distinctive: line 123
Prefer dash-case filenames for consistency with the core package.
- Very specific: line 124
Keep Docker service names as magentic_*.
- Very specific: line 125
Keep Docker service Dockerfiles under matching services/<service>/ directories when possible.
- Distinctive: line 126
Do not import from archive/reference folders.
- Distinctive: line 127
Do not add test files unless explicitly requested.
- Distinctive: line 128
Treat Redis as short-term process state.
- Very specific: line 134
Do not mark a class final unless the design clearly calls for sealing it.
- Very specific: line 135
Prefer a readonly class. If it must hold mutable state, mark the unchanging properties readonly.
- Distinctive: line 136
Keep functions flat; favor early returns and small private helpers over nested blocks.
- Distinctive: line 137
When a function declares more than two parameters, put each parameter on its own line.
≈ “Common” is an estimate: at least 1 in 5 of the 45,344 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
AGENTS.md
Project Snapshot
Magentic is a Docker-based MCP server for agentic AI workflows. It uses an npm workspace monorepo with two Node.js application packages and one PHP analyzer package:
packages/core: Fastify backend, BullMQ worker, Redis queues, PostgreSQL storage, Neo4j graph writes, startup schema installation.packages/site: React, Vite, Tailwind frontend with routed views and React Force Graph 2D visualization.packages/php-analyzer: PHP analyzer microservice usingnikic/php-parser.
Documentation
README.md in the repository root covers setup, running the stack, and operational commands. Architecture and reference notes live in the docs/ directory:
docs/architecture_project.md: holistic project and service architecture.docs/architecture_world_mapping.md: source indexing and graph/world-mapping workflow, including the worker ingestion flow.packages/mcp/resource/graph-schema.json: slim, machine-readable graph schema (node kinds, relationship types, edge properties, type-mapping rules) served to agents by the MCP server'sget_graph_schematool. The worked example adjacency graph lives indocs/architecture_world_mapping.md.docs/test_system_sanity.md: runtime and integration sanity checks.docs/README-performance.md: PHP analyzer file-scanning performance notes.docs/architecture_mcp.md: thepackages/mcpservice — a thin MCP adapter exposingget_status,graph_search,get_graph_search_result,store_config_search, andget_graph_schemaover Streamable HTTP at/mcp.graph_searchreturns a handle (format,webViewUrl,queryId, and a per-form token estimate) rather than inline data;get_graph_search_resultfetches the stored result on demand;store_config_searchis plain-English semantic search over Magento admin configuration.docs/plan_vector_config_search.md: the semantic config search feature — a second, independent vector index pipeline (separate from the graph) that parsessystem.xmlinto descriptions, embeds them via an external model, and stores them inmagentic_pgvectorforstore_config_search.docs/architecture_auth.md: access-control design — a single static token (MAGENTIC_API_TOKEN, defaultexample-token) checked in nginx (envsubst-renderedmap) on every/apiand/mcprequest.
Docker Services
The Compose project is named magentic. Main services:
magentic_frontend: public entrypoint onlocalhost:8080; Nginx in both production and dev (dev rebuilds the SPA withvite build --watchinstead of running the Vite dev server, so nginx — and its auth gate — is always in the path).magentic_backend: private Fastify API service; routes live inpackages/core/src/server.ts.magentic_worker: private BullMQ worker; entrypoint ispackages/core/src/worker.ts.magentic_analyzer_php: private PHP analyzer runtime.magentic_watcher: standalone file watcher (packages/watcher). Readsconfig.json(read-only./datamount) forwatcherEnabled,sourceSubpaths(or whole mount), andprojectRoot/composer.lock, watches*.php+ the lock with chokidar (native events;MAGENTIC_WATCH_POLLING=trueforces polling), re-scopes when the config file changes, and POSTs debounced change batches to the backend'sPOST /api/graph/index/delta(upserts vs. deletes split by event type). That route proxies the appropriate indexing requests (/api/graph/index/sourcefor PHP,/api/graph/index/packagesforcomposer.lock, then/api/graph/index/links). The watcher pauses while a full reindex holds the lock (handles the409and polls/api/status).magentic_redis: queue backend for BullMQ.magentic_postgres: persistent application storage and schema history.magentic_pgvector: dedicated PostgreSQL +pgvectorinstance (imagepgvector/pgvector:pg17, databasemagentic_vectors) holding theconfig_embeddingssemantic-search vectors. Separate frommagentic_postgresso the vector store stays swappable; schema history is still tracked inmagentic_postgres.magentic_graphdb: Neo4j graph database, exposed for local browser/debug access.magentic_embedder: bundled embedding model — allama.cppserver built multi-stage (only/appfromghcr.io/ggml-org/llama.cpp:servercopied ontoubuntu:24.04, ~470 MB/arch) with theembeddinggemma-300mGGUF (768 dims) baked into the image, exposing an OpenAI-format/v1/embeddingson port 8080. Always enabled (not profile-gated) so semantic search works out of the box with no external LM Studio. The backend/worker pick which embedder to call viaEMBEDDER_TYPE(localdefault → this service;remote→ an external server, defaults to LM Studio); the two providers are configured by symmetricLOCAL_EMBEDDER_*andREMOTE_EMBEDDER_*env sets. The image is multi-arch (the GGUF file is arch-independent; only the llama.cpp binary differs) and built by the same release matrix as the other images. SwitchingEMBEDDER_TYPErequires a vector reset-and-reindex (stored and query vectors must come from the same model).
Dev Compose overrides are in docker-compose.dev.yml. Backend/worker/site/PHP analyzer source mounts allow most source edits without rebuilding the image; the backend/worker also mount packages/core/schema so new Neo4j/PostgreSQL schema scripts are installed on restart without an image rebuild. The backend/worker run tsx watch; the site runs vite build --watch and is served by nginx (refresh the browser to pick up a rebuild — no HMR). Rebuild the image only when package metadata or Dockerfiles change. In dev mode, magentic_analyzer_php runs Composer install on startup so packages/php-analyzer/vendor is available locally but ignored by Git.
Common Commands
Root scripts are in package.json:
npm run build
npm run lint
npm run typecheck
npm test
npm run docker:up
npm run docker:dev
npm run docker:dev:build
npm run dev:backend
npm run dev:worker
npm run dev:siteESLint (eslint.config.mjs, flat config) covers the TypeScript packages and e2e/; npm run typecheck runs tsc --noEmit per workspace. Run both before committing.
Useful checks:
curl -s http://localhost:8080/api/health
curl -s -X POST http://localhost:8080/api/graph/index/packages
curl -s -X POST http://localhost:8080/api/graph/index/links
curl -s "http://localhost:8080/api/graph/index/status"
curl -s "http://localhost:8080/api/graph/index/status/<job-id>"
docker run --rm --network magentic_default curlimages/curl -X POST http://magentic_analyzer_php/analyze -H "Content-Type: application/json" -d '{"path": "vendor/magento/module-catalog"}'Core Layout
Important core paths:
src/server.ts: Fastify server and API routes.src/worker.ts: worker process entrypoint and config wiring.src/worker/index-source-worker.ts: source indexing worker that consumes the PHP analyzer JSONL stream.src/queue/index-packages.ts: BullMQ queue contract.src/modules/processing/source-php/: JSONL stream consumption, fact accumulation, mapping, and Neo4j writes for source indexing. Seedocs/architecture_world_mapping.md.src/modules/processing/composer-lock/: Composer lock parsing and graph record building (writes a queryablepsr4Namespaceslist on each Package node).src/modules/processing/magento-xml/:index-xmlpipeline that parses Magento XML config (di.xml,events.xml,crontab.xml/cron_groups.xml,webapi.xml,extension_attributes.xml) into DI/observer/cron/webapi/extension-attribute edges andEvent/CronGroup/WebapiRoute/ExtensionAttributenodes. One handler per file type (registry.ts), sharedrecord-builder.ts, injectable IO (file-system.ts), discovery + area classification (discovery.ts). Entry pointsrc/worker/index-xml-worker.ts.src/modules/processing/package-linking/:index-linkspipeline that connects declared:PHPClassnodes to:Packagenodes withDECLARED_IN_PACKAGEedges via PSR-4 longest-prefix matching, entirely in Cypher. Entry pointsrc/worker/index-links-worker.ts; triggered byPOST /api/graph/index/links(optional{ "symbolId": "<FQN>" }for a scoped relink).src/modules/processing/store-config/: the vector (semantic config search) pipeline's parser. Readssystem.xml+ itsetc/adminhtml/system/*.xmlfragments (read-store-config-sources.ts), merges them across files and modules resolving<include>s (merge-store-config.ts— the genuinely complex part), and builds one natural-language description per config field (build-config-descriptions.ts). The structuralsection/group/fieldpath is the id; the explicitconfig_path(when a field declares one) is kept as nullable extra data.save-config-vector.ts/reset-config-vector.ts/search-config-vector.tsmap descriptions onto theconfig_embeddingstable (config-embeddings-table.ts) and call the embedding + vector-store layer. This pipeline writes tomagentic_pgvector, not the graph; it is independent ofindex-source/index-xml/etc.src/modules/vector/: provider-agnostic embedding + storage layer used by the vector pipeline.embedding.ts(embedding()) calls an OpenAI-format embeddings endpoint viaembedding/request-embeddings.tswith a configurable URL/model and a nullable bearer token (works with LM Studio, OpenAI, and any compatible server), guarded by an in-house token estimator (embedding/estimate-tokens.ts);vector-store.ts(createVectorStore) is an abstract pgvector store whose table/columns come from aVectorTableparameter (upsert/search/reset).embedding/read-embedding-config.tsbuilds theEmbeddingConfigfromsrc/config.tsfor both server and worker.src/queue/index-vector.ts+src/worker/index-vector-worker.ts: theindex-vectorBullMQ pipeline (operation: "index" | "reset-and-index"), wired into the singlemagentic_worker. Triggered byPOST /api/vector/index/reindex(reindex — upsert) andPOST /api/vector/index/reset-and-reindex(clear then re-embed), mirroring the graph'sreindex/reset-and-reindexpair; both guarded bymagentic:vector-index:lock(independent of the graph'smagentic:graph-index:lock).POST /api/vector/searchembeds a query and returns the top matches.src/modules/graph/: generic graph write helpers (upsert.tsfor the source path,merge-sync.tsfor the composer path — merge nodes/edges then prune what is no longer present).src/api/status.ts+src/api/usage/ping.ts:GET /api/status(combined frontend status: graph + vector indexing in-progress/locked + AI-agent connected) andPOST /api/usage/ping(clients record recent activity). Backed bysrc/modules/usage.ts, a neutralusage:lastRedis key with a 120s TTL (the TTL is the idle window; key present = connected). The shared snapshot shape is built once bysrc/modules/stream/build-status-snapshot.tsand reused by both the polled route and the stream. Route files mirror their URL segment:/api/status→api/status.ts,/api/usage/ping→api/usage/ping.ts,/api/stream/status→api/stream/status.ts.src/api/stream/status.ts(routeGET /api/stream/status) +src/modules/stream/streamer.ts+src/modules/stream/status-events.ts: a push channel for status. Producers publish a tiny typed flag to one Redis pub/sub channelmagentic:status-events: indexing changes (the worker on jobactive/progress/completed/failedviasrc/modules/stream/forward-index-events.ts, and the enqueue routes) publish{ "type": "index" }; the MCP usage ping publishes{ "type": "agent_ping" }only on the idle→connected transition (so a newly connected agent lights up instantly — repeat pings stay silent, and idle resolves via the 59s poll once theusage:activeTTL expires). Thetypeis a publish-side trigger label; both triggers re-read the one combined status snapshot. The backend keeps a single subscriber that, on any message, debounces, rebuilds the snapshot, and broadcasts it as a single Server-Sent Eventevent: statusoverGET /api/stream/status(including one initialstatusframe on connect — note: never anagent_pingframe on connect, so a fresh page load does not look like agent activity). Constant 2 extra Redis connections regardless of queue count (1 publisher in the worker, 1 subscriber in the backend). Final-state correctness: the worker publishes after releasing its lock, so the broadcast never reports a stalelocked. The frontend (StatusContext) consumes the stream via afetch-reader (so the bearer header applies — nativeEventSourcecannot set it), replaces status on eachevent: status, auto-reconnects with backoff, and keeps a slow 59s safety poll for agent freshness + resync.src/api/config/:GET /api/configandPUT /api/configfor user-editable runtime settings, plusGET /api/graph/stats(Neo4j node/edge counts) undersrc/api/graph/stats.ts. Settings are file-backed bysrc/modules/app-config.ts(JSON atMAGENTIC_CONFIG_PATH, default/app/data/config.json, bind-mounted from./dataso it survives rebuilds) — loaded into memory at backend startup and rewritten only on UI save; manual file edits need a backend restart. Settings:phpVersion(parser target, threaded into the index-source job and on to the PHP analyzer'sParserFactory),projectRoot(wherecomposer.lockis read, joined onto the mount ingetComposerRoot),sourceSubpaths(a list of directories scanned for PHP, each in its own analyzer pass; empty = whole mount), and the active embedder —embedderType(local|remote) plus the editableremoteEmbedderUrl/remoteEmbedderModel/remoteEmbedderBearerToken(the local embedder stays env-only and read-only;GET /api/configreturns it aslocalEmbedderfor display).readEmbeddingConfig()resolves the activeEmbeddingConfigfrom these settings (remote) or env (local); the backend resolves it per search request and snapshots it into the vector job at enqueue, so the worker uses the job's config (the worker has noconfig.jsonmount). The worker never reads the file — the backend snapshots these into job data at enqueue time. The single index-source job loops the directories (worker concurrency is 1, so per-directory queue jobs would not parallelize anyway) and reports per-directory progress.src/config.ts: environment-backed config, includingGRAPH_BATCH_SIZE(source ingestion batch and transaction size, default 5000),POSTGRES_VECTOR_URL(themagentic_pgvectorconnection), and the embedder settings:EMBEDDER_TYPE(localdefault |remote) selecting between two symmetric sets —LOCAL_EMBEDDER_URL/LOCAL_EMBEDDER_MODEL/LOCAL_EMBEDDER_BEARER_TOKEN(default the in-clustermagentic_embedder) andREMOTE_EMBEDDER_URL/REMOTE_EMBEDDER_MODEL/REMOTE_EMBEDDER_BEARER_TOKEN(default LM Studio athost.docker.internal:1234/v1/embeddings).readEmbeddingConfig()resolves the active set into anEmbeddingConfig(full OpenAI-format endpoint, model, nullable bearer token).src/modules/index-lock.ts: two independent Redis locks —magentic:graph-index:lock(graph reindex/reset) andmagentic:vector-index:lock(vector reindex/reset). Each pipeline acquires/checks only its own.src/schema/install-schemas.ts: startup schema installer, applying scripts to three databases (postgresql,neo4j,pgvector) and recording history inmagentic_postgres.schema/postgresql/: PostgreSQL.sqlschema scripts.schema/pgvector/:magentic_pgvector.sqlscripts (thevectorextension + theconfig_embeddingstable,embedding vector(768), keyed by the configpath).schema/neo4j/: Neo4j.cypherschema scripts. Node id uniqueness is per label (PHPClass.id,PHPMethod.id,Event.id,CronGroup.id,WebapiRoute.id,ExtensionAttribute.id,Package.id,Author.id) — there is no shared:Symbolbase. Plus edge identity constraints for EXTENDS, IMPLEMENTS, USES, HAS_METHOD, PARAM_TYPE, RETURNS_TYPE, DECLARED_IN_PACKAGE, PREFERENCE_FOR, PLUGIN_FOR, INJECTS, OBSERVES, SCHEDULED_IN, SERVED_BY, HAS_EXTENSION_ATTRIBUTE, and OF_TYPE. Seedocs/architecture_world_mapping.mdfor the node/edge model.
Schema scripts are installed on backend/worker startup, not during Docker build and not from frontend requests. PostgreSQL stores executed schema scripts in application_schema_history.
Frontend Layout
Important site paths:
src/app/App.tsx: app shell, routing, fixed sidebar/top bar layout.src/app/navigation.ts: navigation IDs and route paths.src/components/: shared UI components.src/features/graph/: React Force Graph 2D graph visualization.src/views/: route views.
The frontend uses same-origin /api/* calls through a central apiFetch helper (src/lib/api.ts) that attaches the bearer token. Nginx proxies /api to magentic_backend:3000 (with a dedicated buffering-off /api/stream location for the Server-Sent Events status stream) and /mcp to magentic_mcp:3000 in both dev and prod. The nginx template is baked into the magentic_frontend image, so changing it (e.g. a new location) needs a frontend image rebuild, not just a restart.
PHP Analyzer Layout
Important PHP analyzer paths:
packages/php-analyzer/composer.json: PHP package manifest.services/analyzer-php/Dockerfile: PHP analyzer runtime image.
The analyzer package uses PSR-4 namespace Magentic\PhpAnalyzer\. The analyzed source mount is read-only at /mnt/analyzed-source; do not confuse it with the analyzer application source in packages/php-analyzer.
Conventions
- Keep source-code comments out. ESLint enforces this: the only comment form allowed is a
/** */doc block (no//line comments, no inline comments). Add a doc block only for type information a native type cannot express. - Prefer dash-case filenames for consistency with the core package.
- Keep Docker service names as
magentic_*. - Keep Docker service Dockerfiles under matching
services/<service>/directories when possible.services/backend/Dockerfileintentionally builds the shared backend image used by bothmagentic_backendandmagentic_worker. - Do not import from archive/reference folders.
- Do not add test files unless explicitly requested.
- Treat Redis as short-term process state; PostgreSQL is durable application state; Neo4j is graph storage.
PHP Conventions
These apply to PHP code (packages/php-analyzer). Clean code comes first; treat the rest as defaults, not hard gates. It is fine to write a rough version first and refine it after.
- Do not mark a class
finalunless the design clearly calls for sealing it;finalblocks extension and mocking. - Prefer a
readonlyclass. If it must hold mutable state, mark the unchanging propertiesreadonly. - Keep functions flat; favor early returns and small private helpers over nested blocks.
- When a function declares more than two parameters, put each parameter on its own line.
- Let the code describe itself instead of commenting. Add a docblock only for type information a native type cannot express (generics, array shapes); when a docblock is present, document every such parameter and the return so it is not partial.
- Replace an if/else chain of more than two branches with
match(orswitch). - Model a fixed set of values as an enum rather than an array of constants or magic strings.
- Inject collaborators so they can be mocked in tests; instantiating a pure value object from local data is fine.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

