A RAG-powered MCP server that reviews your Symfony code the way 20 years of core-team reviews would.
Ask a LLM to review your code and you get generic advice. Give it thousands of real
code reviews from the Symfony core repository — and it reviews like nicolas-grekas, stof and
xabbuh were looking over your shoulder.
Symfony has 20+ years of public code reviews on GitHub — every merged PR carries comments from
the core team (nicolas-grekas, stof, dunglas, xabbuh, …) and dozens of contributors. That's
a goldmine of domain-specific review patterns: which arguments convince, which patterns get rejected,
what the community considers good Symfony code.
Symfony Reviewer MCP turns that history into a searchable semantic index (RAG) and exposes it through the Model Context Protocol, so your LLM of choice can review your code as:
"Review this code the way stof would" — review
asthe most prolific core-team reviewer
"Review this code the way any Symfony contributor would" — review
asthe whole community
"Review this code the way any core-team member would" — get a panel of experts
Everything runs locally — PHP 8.5 + Symfony 8.1, Ollama for embeddings
(embeddinggemma-300m, 768 dims), Qdrant as the vector store.
No GPU required: the full historical indexing runs on CPU in a few days, then the MCP server
serves fast semantic lookups.
| Tool / Prompt | Role |
|---|---|
review_as_person (tool) |
Semantic search for reviews by a specific reviewer (nicolas-grekas, stof, …) |
review_as_group (tool) |
Semantic search by affiliation group (MEMBER, CONTRIBUTOR, NONE) |
review_as_person (prompt) |
Formatted prompt built on top of the matching tool |
review_as_group (prompt) |
Formatted prompt built on top of the matching tool |
get_stofed (prompt) |
Forces the reviewer persona to stof |
hq_review (prompt) |
Multi-review: queries 14 top reviewers and synthesizes a markdown report |
Two big blocks share a single common point — the Qdrant collection:
- RAG generation — fetch → dataset → vectorization → indexing
- MCP server — semantic retrieval → tool results for the LLM client
flowchart TD
subgraph Build[RAG generation]
A["GitHub API (symfony/symfony)"] --> B["PullsFetcher (merged PRs only)"]
B --> C["ReviewsFetcher (comments + replies)"]
C --> D["DatasetGenerator (var/dataset/pull-{id}.txt)"]
D --> E["Builder"]
E --> F["Ollama (embeddinggemma-300m)"]
F --> G["Qdrant (collection: reviews)"]
end
subgraph Serve[MCP server]
H["MCP tool call (review_as_group / review_as_person)"] --> I["Retriever (semantic search)"]
I --> G
I --> J["LLM client (Claude Desktop, …)"]
end
Requires Docker with the Qdrant and Ollama services reachable
(the compose file uses the external networks shared_qdrant and shared_ollama).
git clone https://github.com/ktherage/symfony-review-mcp
cd symfony-review-mcp
# 1. Install dependencies
docker compose run --rm cli composer install
# 2. Build the RAG (fetch → dataset → vectorize → index)
docker compose run --rm cli bin/console mcp:build
# 3. Start the MCP server
docker compose up -dThe initial
mcp:buildruns through every historical review of the Symfony repository and vectorizes them one by one on CPU — expect it to take several days on the first run. The build is incremental and crash-safe (see below), so you can stop and restart it freely.
All configuration lives in .env:
| Variable | Role |
|---|---|
GITHUB_TOKEN |
GitHub personal access token |
QDRANT_DSN |
Qdrant service URL (e.g. http://qdrant_db:6333) |
OLLAMA_DSN |
Ollama service URL (e.g. http://ollama:11434) |
BLACKLISTED_PATTERN |
JSON array of URL patterns to exclude from the HTTP cache |
APP_VERSION |
Version reported in the MCP metadata |
# Full pipeline: fetch → dataset → vectorization
php bin/console mcp:build
# Re-vectorize without re-fetching (uses the dataset cache)
php bin/console mcp:build --skip-generation -G
# Re-fetch without re-vectorizing (uses the ragged cache)
php bin/console mcp:build --skip-build -Bphp bin/console mcp:serveror via Docker, wiring the services running on your host:
docker run -i --rm \
--add-host=host.docker.internal:host-gateway \
-e QDRANT_DSN=http://host.docker.internal:6333 \
-e OLLAMA_DSN=http://host.docker.internal:11434 \
symfony-reviewer-mcp-cliThen register the server in Claude Desktop (claude_desktop_config.json) — or any MCP client:
{
"mcpServers": {
"symfony-reviewer": {
"command": "docker",
"args": [
"run", "-i", "--rm",
"--add-host=host.docker.internal:host-gateway",
"-e", "QDRANT_DSN=http://host.docker.internal:6333",
"-e", "OLLAMA_DSN=http://host.docker.internal:11434",
"symfony-reviewer-mcp-cli"
]
}
}
}PullsFetcher pages GET /repos/symfony/symfony/pulls?state=all&per_page=100, keeping only PRs
whose merged_at is not null — no point training on rejected ideas. Instead of paging blindly, it
sends a single HEAD request and reads the total page count from the
Link header.
That discovery call is exactly what BLACKLISTED_PATTERN is for: it must not be hidden in the
365-day cache.
ReviewsFetcher then walks GET /repos/symfony/symfony/pulls/{id}/comments per PR and rebuilds the
real conversation tree — parent comments with their replies attached. The catch: the GitHub API
does not guarantee comment order. If a reply arrives before its parent, it is parked in a temporary
pool ($repliesTempPool) and re-attached as soon as the parent shows up — otherwise any thread
where three people argue about tabs vs spaces, out of order, would silently lose replies.
Both fetchers go through a small chain of HTTP decorators:
flowchart TD
A["GithubHttpClient (scoping + Bearer auth)"] --> B["CachedHttpClient (filesystem cache, 365d TTL)"]
B --> C["LoggedHttpClient (structured logging)"]
C --> D["HttpClient::create() (native Symfony)"]
Each decorator adds one responsibility. CachedHttpClient skips the cache for blacklisted patterns
(URL-only keys, fine for the GitHub GET fetchers), otherwise stores a serializable
CachedResponse. The serialization trap: HttpClient::getInfo()
contains a pause_handler key holding a Closure, which cannot be serialized — CachedResponse
filters non-serializable values out:
$this->info = array_filter($info, static fn ($v): bool => !$v instanceof \Closure);Without that filter, FilesystemAdapter fails silently (the serialization exception is swallowed
by DefaultMarshaller with throwOnSerializationFailure set to false) and the cache key is
quietly dropped.
Once fetched, DatasetGenerator turns each PR and its reviews into a structured text file:
[PULL_REQUEST]
id: 54321
author: nicolas-grekas
author_association: MEMBER
description:
[HttpKernel] Fix edge case in exception handling
[REVIEWS]
[REVIEW_1234]
replyTo:
reviewer: stof
reviewer_association: MEMBER
file: src/Component/HttpKernel/Event/ExceptionEvent.php
diff:
@@ -88,7 +88,7 @@
public function getThrowable(): ?\Throwable
{
comment:
We should keep the original exception here,
the wrapper is only for internal use.
reactions:
+1: 5
-1: 0
laugh: 0
hooray: 0
confused: 0
heart: 0
rocket: 0
eyes: 0
These live in var/dataset/pull-{id}.txt and are the ground truth for vectorization.
Files are sent to Ollama with the exact same embedding model used at build time —
hf.co/ggml-org/embeddinggemma-300m-qat-q8_0-GGUF:Q8_0 (768 dimensions, Cosine distance) — so
vectors stay comparable at query time. A model mismatch would silently compare apples with oranges.
sequenceDiagram
participant AI as Symfony AI (Builder)
participant Ollama
participant Model as embeddinggemma-300m
participant Qdrant
AI->>Ollama: vectorize(dataset file content)
Ollama->>Model: model inference
Model-->>Ollama: 768 float values
Ollama-->>AI: Vector (768 dimensions)
AI->>Qdrant: add(VectorDocument)
Qdrant-->>AI: confirmation
Indexing is sequential by design — without a dedicated GPU, the iGPU/CPU does the matrix math and only one vectorization fits at a time. It's a pragmatic trade-off, not a PHP/Qdrant limit.
Instead of a database table to track processed files, the Builder uses atomic rename()s:
pull-{id}.txt → ready to process
processing_pull-{id}.txt → being vectorized
ragged_pull-{id}.txt → vectorized successfully
Crash-safe by construction: if the script dies mid-way, recoverOrphanedProcessingFiles() puts the
orphaned processing_* files back in queue on the next run. No locks, no database, no race
conditions.
src/
├── Command/
│ └── BuildCommand.php # CLI command: mcp:build
├── HTTP/
│ ├── CachedHttpClient.php # filesystem cache decorator (+ blacklist)
│ ├── CachedResponse.php # serializable response (filters Closures)
│ ├── GithubHttpClient.php # GitHub scoping + Bearer auth
│ └── LoggedHttpClient.php # structured logging decorator
├── Kernel.php # Symfony HTTP-less kernel & DI wiring
├── MCP/
│ ├── Prompts/
│ │ ├── GetStofedPrompt.php # persona: stof
│ │ ├── HQReviewPrompt.php # 14-reviewer synthesis
│ │ ├── ReviewAsGroupPrompt.php
│ │ └── ReviewAsPersonPrompt.php
│ └── Tools/
│ ├── ReviewAsGroupMatchingFileDiffTool.php
│ └── ReviewAsPersonMatchingFileDiffTool.php
└── RAG/
├── Builder.php # atomic vectorization pipeline
├── Dataset/
│ └── DatasetGenerator.php # pull-{id}.txt generation
└── Fetcher/
├── PullsFetcher.php # merged PRs (HEAD + Link header)
└── ReviewsFetcher.php # comment threads + replies
What worked well:
- Atomic file-rename pattern — elegant, crash-safe, zero infrastructure.
- Incremental pipeline — re-running
mcp:buildon existing files is a no-op. - Local Ollama embeddings — 768 dims is fast yet rich enough for semantic review search.
What to improve:
- Batch vectorization — documents are added one by one; a batch upsert would be much faster.
- No incremental RAG updates — the pipeline is add-only; edited PR comments on GitHub are not purged/updated automatically.
- Webhook updates — listen to merged-PR events instead of periodic rebuilds.
- Use Qdrant payloads — store the raw GitHub JSON in the document
metadatato filter/index byreviewer_association, date or reactions, without re-parsing the text. - Reaction-weighted scoring — Qdrant Formula Queries could blend reaction counts into the final score, so community-validated reviews rank higher.
- Add your own conventions — swap the corpus for your own team's reviews to enforce your own review culture.
The most surprising takeaway: PHP is a perfectly viable language for RAG pipelines. Symfony's
HttpClient, Cache and Console components, combined with the
symfony/ai-* packages, handle everything from HTTP decoration to
vector-store operations. You don't need Python for semantic search — sometimes the best tool for
the job is the one you already master.