Vibe Coding Meets Enterprise Reality: Building an MCP for Architecture Standards

AI coding is fun until your architecture crumbles. We built an MCP server that enforces enterprise standards so AI assistants stop reinventing the wheel.

Siddhartha Lahiri · · 5 min read

The Problem with "Vibe Coding" at Scale

"Vibe coding" works brilliantly—until your team has three different patterns for the same thing across three microservices. Developer A's service uses UserService with UserRepository. Developer B's uses UsersManager with UserDAO. Developer C skips the service layer entirely and puts business logic in the router.

Same company. Same stack. Three different patterns. Multiply this across dozens of developers and hundreds of services, and you have an unmaintainable mess. The promise of AI-assisted development isn't just speed—it's consistency at speed. But that requires standards.

The Current Solutions Fall Short

Most AI-powered editors now support rules files—markdown documents that tell the AI how to write code. Claude has CLAUDE.md, Cursor has .cursorrules, and similar patterns exist across tools. Two issues emerge:

  • Rules are local. Every developer has their own copy. When standards evolve, someone needs to update every repository. Rules drift. Exceptions creep in. Within months, the "standard" exists in five different versions.
  • Context adds up. Comprehensive architecture rules are verbose—naming conventions, project structure, error handling, security requirements, testing standards, API design principles, logging formats. That's context window space that could be used for actual code.

A Different Approach: Standards as a Service

What if standards weren't embedded in context, but called on-demand?

This is the idea behind MCP (Model Context Protocol)—a standard for giving AI assistants access to external tools. Instead of stuffing everything into the prompt, the AI calls tools when it needs specific information.

I built a prototype exploring this concept: arch-mcp, an MCP server for Python microservice architecture standards.

  • To be clear: this is an experiment, not a production system. It's a proof-of-concept exploring whether centralized, tool-based standards can work better than local rules files.
  • How discovery works: You still need a lightweight system prompt telling the AI these tools exist and when to use them. The MCP reduces what's loaded in context, but doesn't eliminate the need for some orchestration. The heavy lifting moves to the server.

How It Works

The MCP server exposes focused tools:

  • scaffold_project → Create a new microservice with standard structure
  • scaffold_feature → Add a feature module with all required files
  • get_naming_conventions → Retrieve naming patterns on-demand
  • validate_code → Check code against architecture rules
  • check_architecture → Verify layer dependencies
  • get_tdd_workflow → Get test-driven development steps

The AI calls these as needed. Standards are centralised. Every developer connecting to the same server gets the same rules.

How validation works: The current implementation uses pattern matching—regex-based checks for things like bare except: clauses, hardcoded secrets patterns, and naming convention violations. It's not AST parsing or LLM-assisted analysis. It catches common issues but isn't foolproof. Think of it as a first-pass sanity check, not a comprehensive static analyzer.

What Validation Catches

Here's an example of the validation feedback:

DATABASE_URL = "postgresql://admin:password123@prod-db:5432/app"
```
```
VIOLATION: no-hardcoded-secrets (error)
  Hardcoded credential detected.
  Fix: Use environment variables via pydantic-settings        

Another example—catching bare exceptions:

try:
    process_order()
except:
    pass
```
```
VIOLATION: no-bare-except (error)
  Don't use bare 'except:' - catches all exceptions including
  KeyboardInterrupt and SystemExit.
  Fix: Catch specific exceptions (ValueError, TypeError, etc.)        

These are pattern-based checks. They catch obvious issues but won't detect subtle architectural violations that require deeper code understanding.

The Developer Experience

  • Create a project: "Create a new microservice called product-service"
  • Add a feature: "Add a product feature to my project"
  • The scaffold generates schemas, service, repository, router, errors, and test files—all following consistent naming conventions.
  • Validate: "Check my codebase for architecture violations"

For the full walkthrough, see the tutorial in the GitHub repo.

What Gets Enforced

Structural Rules

  • Naming conventions: ProductCreate, ProductService, ProductRepository
  • File naming: product_service.py, product_router.py
  • Folder structure: features organized as self-contained modules

Behavioural Rules

  • Layer dependencies: routers depend on services, services depend on repositories (not the reverse)
  • No hardcoded secrets
  • No bare except clauses

Testing Rules

  • 80% coverage target
  • Pytest with async support
  • Test files generated alongside features
Customisation Projects can override defaults via .arch-mcp/rules.yaml. Standards are documented, not black-boxed—get_architecture_guide returns readable documentation for onboarding or AI reasoning.

How This Compares to Existing Tools

Fair question: why not just use existing solutions?

  • Cookiecutter / Yeoman handle project scaffolding but don't provide ongoing validation. Once the project is created, you're on your own.
  • Ruff / ESLint catch style issues but operate at the syntax level, not the architectural level. They won't tell you that your router is importing from the repository layer.
  • ArchUnit / jQAssistant do architectural testing but run in CI—after the code is written. MCP can provide feedback during generation.
The difference is timing. Traditional linters catch mistakes after they're written. MCP-based tools can influence what gets generated in the first place. That said, this prototype doesn't replace these tools. It's complementary—an experiment in shifting enforcement earlier in the workflow.

Limitations

  • This is a prototype. It's not production-hardened, battle-tested, or enterprise-ready.
  • Pattern matching has limits. The validation uses regex, not AST parsing. It catches obvious violations but misses subtle ones.
  • The brownfield problem. Scaffolding new features is straightforward. Editing existing code with complex multi-file dependencies is harder. The current tools don't provide granular edit guidance.
  • Connectivity required. The MCP server needs to be reachable. For air-gapped or regulated environments, this is a blocker. A local mode isn't implemented yet.
  • Opinionated patterns. The prototype enforces one architectural style (service/repository layers). Not every team wants this rigidity. Configurable rulesets are on the roadmap but not implemented.

The Bigger Picture

AI-assisted development is here to stay. The question isn't whether to adopt it, but how to adopt it responsibly.

"Vibe coding" works for individual projects and prototypes. But teams need more: consistency across services, maintainability over years, onboarding that doesn't require tribal knowledge.

Centralised, on-demand standards—delivered through protocols like MCP—might be one path forward. The AI remains flexible where it should be, while guardrails keep the codebase coherent.

This prototype is an exploration of that idea. It's not a product. It's a question: can we make AI-assisted development more consistent without sacrificing the speed that makes it valuable?

Try It Yourself

The prototype is open source.

Option 1: Use the hosted server

claude mcp add --transport sse arch-controls https://arch-mcp.sid.sh/sse        

Option 2: Run locally

pip install arch-mcp
claude mcp add arch-controls -- arch-mcp        

Then ask:

  • "Create a new microservice called order-service"
  • "Add a product feature to my project"
  • "Check my codebase for architecture violations"

GitHub: github.com/slahiri/arch.mcp

What's Next

If this concept proves useful, there are several directions to explore:

  • Edit-aware tooling: Smarter guidance for multi-file refactoring
  • Deeper validation: Moving from regex to AST-based checks
  • Configurable rulesets: Strict, moderate, and relaxed enforcement profiles
  • Local mode: Bundled rules for offline/air-gapped environments

What patterns are you seeing for enforcing standards with AI coding tools? I'd be curious to hear what's working in practice.

First published on LinkedIn. Join the discussion there →