Skip to content

Codegraph / MCP for AI Agents ​

Developer tooling for AI-assisted navigation of MyHoreca Pay. Not a production runtime dependency.

Purpose ​

Codegraph helps AI agents:

  • inspect project structure and module boundaries;
  • find symbol usages and API contract touchpoints;
  • avoid duplicate DTOs, services, and UI components;
  • validate architecture dependency rules;
  • keep architecture documentation aligned with code.

Two layers ​

1. Repository manifest (always available) ​

Path: codegraph/manifest.yaml

Machine-readable index of:

AreaWhat is indexed
BackendC# projects, allowed/forbidden references, key interfaces
FrontendAPI layer, shared components, pages, routes, tests
API surfaceendpoint → controller → hook → page → docs → tests
Docsportal paths and AI agent docs
Rulesarchitecture tests and boundary notes

Agents should read codegraph/manifest.yaml before creating new services, DTOs, components, or endpoints.

2. Optional MCP server (local IDE tooling) ​

An MCP codegraph server indexes the repo into a queryable graph (symbols, imports, callers, impact). Examples of compatible local tools:

  • codegraph-ai — tree-sitter + MCP (search, get_context, project_overview)
  • CodeGraph — local SQLite graph via MCP
  • cgh — multi-language graph + docs FTS

Copy .cursor/mcp.json.example (repository root) to .cursor/mcp.json and adjust for your chosen server. Do not commit personal MCP secrets or machine-specific paths unless the team standardizes them.

C# note: many codegraph MCP tools index TypeScript/JavaScript best. For .NET boundaries, combine MCP with codegraph/manifest.yaml and dotnet test on MyHoreca.Pay.ArchitectureTests.

Agent workflow (mandatory) ​

Before backend architecture changes ​

  1. Read codegraph/manifest.yaml → modules.backend
  2. Run or review architecture tests: backend/tests/MyHoreca.Pay.ArchitectureTests
  3. If MCP is enabled: query impact/callers for affected symbols
  4. Do not add references that violate allowed_references / forbidden_references

Before creating a service / interface / DTO ​

  1. Search manifest shared_symbols.backend_interfaces and api_surface
  2. Grep backend: IBankAdapter, IPaymentAllocationService, similar names
  3. Extend existing abstractions in Application or Domain — do not duplicate

Before creating a UI component ​

  1. Check shared_symbols.frontend_components in manifest
  2. Inspect frontend/src/shared/ui/index.ts
  3. Extend shared components; pages stay thin

Before changing API contracts ​

For each endpoint, update all touchpoints listed in manifest api_surface:

  • backend controller/handler
  • frontend/src/api/contracts/apiContracts.ts
  • frontend/src/api/hooks/usePayApi.ts
  • consuming pages
  • tests (unit/integration/Playwright)
  • docs/docs/backend/api.md

After structure changes ​

Update in the same PR:

  • codegraph/manifest.yaml
  • docs/docs/backend/api.md (if API changed)
  • docs/docs/architecture/* (if boundaries changed)
  • AGENTS.md / .cursor/rules/codegraph.mdc (if agent rules changed)

What codegraph understands ​

KindSource
C# projects & references*.csproj, manifest, architecture tests
TypeScript importsMCP index or grep/frontend/src
React components/hooksmanifest + frontend/src/components, frontend/src/api/hooks
API contractsmanifest api_surface, apiContracts.ts, controllers
Docs referencesdocs/docs/**, vitepress config
Testsmanifest links + backend/tests, frontend/tests, docs/playwright

Dependency validation ​

Automated (CI/local):

bash
cd backend
dotnet test tests/MyHoreca.Pay.ArchitectureTests

Documented rules in manifest dependency_rules:

  • Domain must not reference Infrastructure/Persistence/Api
  • Application must not reference Api
  • Bank parsing stays in BankStatements adapters
  • Syrve writes stay behind ISyrvePaymentPostingAppService approval gate

MCP tool usage (when configured) ​

Prefer graph queries over blind file reads:

TaskMCP (if available)Fallback without MCP
Find symbolsearch / symbol_lookupgrep + manifest
Who calls Xfind_callers / codegraph_callersgrep references
API impactmanifest api_surface + grep /api/manifest + grep
Module boundariesmanifest modules.backendread *.csproj
UI reusemanifest shared_symbols.frontend_componentsread frontend/src/shared/ui

Rule: use codegraph/MCP for navigation and impact analysis; use direct file edits for implementation.

  • AGENTS.md (repository root)
  • .cursor/rules/codegraph.mdc (repository root)
  • .cursor/mcp.json.example (repository root)
  • docs/docs/ai-agents/rules.md

Non-goals ​

  • Codegraph is not deployed with API/Gateway/Frontend containers
  • Codegraph MCP is not required for local dev or CI build
  • Do not add codegraph packages to Directory.Packages.props or frontend package.json runtime deps