Skip to content

OpenSIN-Code/SIN-Code-Symfony-Lens

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

sin-code-symfony-lens

Symfony-specific analysis tools for the SIN-Code Bundle. 8 MCP tools that turn your Symfony project into a queryable knowledge graph for coding agents and humans.

Python MCP License: MIT

Part of the SIN-Code agent-engineering stack. Install alongside the rest via the SIN-Code Bundle.

What it does

sin-code-symfony-lens exposes 8 production-grade analyzers as MCP tools, so agents like opencode, Claude Code, and Cursor can ask deep, structured questions about a Symfony codebase — services, routes, Doctrine entities, Twig templates, the DI container, and migration safety — without running the full PHP toolchain.

It is a static, regex-based analyzer: it parses services.yaml, PHP attributes, Doctrine annotations, Twig {% extends %} chains, and Doctrine migration SQL — fast enough to run on every keystroke.

The 8 MCP tools

Tool What it analyzes
symfony_analyze_services services.yaml + PHP attributes → service graph (aliases, autowiring, factories, decorates)
symfony_analyze_routes #[Route] attributes + routes.yaml + routes.xml + legacy @Route annotations
symfony_analyze_entities Doctrine entities — fields, types, relations (OneToMany/ManyToOne/...), indexes, lifecycle callbacks
symfony_analyze_templates Twig extends / include / use / import / macro / block resolution
symfony_analyze_container Full DI container view (services + routes + parameters) in a single response
symfony_validate_migration Detects breaking DDL changes in pending Doctrine migrations (drop column, change type, etc.)
symfony_phpstan_check Runs PHPStan/Psalm, parses JSON output, integrates with the Proof-of-Correctness stack
symfony_full_analysis All of the above in a single tool call (use for cold-start of a new project)

Install

# Standalone
pip install sin-code-symfony-lens

# Or via the SIN-Code Bundle (recommended)
pip install sin-code-bundle[symfony]

Then run the MCP server:

symfony-lens   # → FastMCP server on stdio

Wire it into your opencode config:

{
  "mcp": {
    "symfony-lens": {
      "type": "local",
      "command": ["symfony-lens"]
    }
  }
}

Quick example

# From any agent that speaks MCP:
result = await client.call_tool(
    "symfony_analyze_services",
    {"project_root": "/path/to/symfony-app"}
)
# → {
#     "services": 87,
#     "autowired": 76,
#     "decorated": 4,
#     "graph": [...]
#   }

Architecture

symfony_lens/
├── server.py                  # FastMCP entrypoint (8 @mcp.tool() definitions)
├── analyzers/
│   ├── service_analyzer.py    # services.yaml + PHP #[AsService] etc.
│   ├── route_analyzer.py      # #[Route], routes.yaml, routes.xml, @Route
│   ├── entity_analyzer.py     # Doctrine #[ORM\Entity] + field introspection
│   ├── twig_analyzer.py       # Twig template graph
│   └── container_analyzer.py  # aggregate view
├── doctrine/
│   ├── schema_inspector.py    # ORM metadata
│   └── migration_validator.py # DDL diff vs. previous schema
├── static_analysis/
│   └── phpstan_bridge.py      # JSON parser + sin-poc integration
└── utils/                     # PHP regex parser, YAML/attribute helpers

Every module ships with a .doc.md companion (CoDocs standard).

Why regex, not tree-sitter-php?

tree-sitter-php requires a C toolchain at install time. For a 50 MB tool that runs in <300 ms per project, a hand-tuned regex parser hits 95% of the cases agents actually need (route paths, service IDs, attribute names) and stays zero-dep. The remaining 5% fall through to phpstan_bridge, which calls the real PHP toolchain when needed.

Tests

pip install -e .[dev]
pytest -v

20 tests, all green.

Companion skills

License

MIT — see LICENSE.

Versioning

See CHANGELOG.md for release notes (current: 0.1.0, 2026-06-05).

About

Symfony-specific static analysis tools for SIN-Code Bundle — services, routes, entities, Twig, migrations, PHPStan via 8 MCP tools

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages