Skip to content

AI Integrations ​

Connect CodeGuard to your AI development workflow using the Model Context Protocol.

What is MCP? ​

The Model Context Protocol (MCP) lets a compatible host application discover and call tools exposed by a local process. CodeGuard is a deterministic static-analysis tool provider. It does not contain, call or require an AI model or an API key.

How CodeGuard fits in ​

  1. Your AI client launches codeguard mcp --root <project-root> as a local stdio process.
  2. The assistant calls CodeGuard tools to get project information and structured diagnostics.
  3. CodeGuard analyzes files on your machine and returns the results. It never edits files.
  4. The assistant explains the findings. Any change is yours to apply or approve in your client.

The homepage demo shows a simulated version of this exchange. See Security & Privacy for the boundaries and for what a third-party client may do with returned diagnostics.

Supported clients ​

Only clients marked as verified have been tested by the CodeGuard project.

Codex

Verified integration

Configured through ~/.codex/config.toml and manually validated with CodeGuard.

VS Code

Generic MCP compatibility

Documented stdio configuration in .vscode/mcp.json. Follows the generic MCP configuration pattern.

MCP Inspector

Generic MCP compatibility

Useful for testing the handshake and listing tools. A debugging aid rather than an AI client.

Other desktop assistants and IDEs

Not yet tested

Any client that can launch a local stdio MCP server may work. None of these have been tested by the CodeGuard project.

Set up Codex ​

Verified integration. Codex has been manually validated with CodeGuard.

Prerequisites ​

  • Node.js 24 or newer (the package requires >=24).
  • Codex installed on the same machine as the project.

Install the package ​

Install the beta
npm install -g codeguard-local@beta

Configure the MCP server ​

Add this to ~/.codex/config.toml, merging with any existing entries:

~/.codex/config.toml
[mcp_servers.codeguard]
command = "codeguard"
args = ["mcp", "--root", "<project-root>"]

Replace <project-root> with the project directory before copying it into your settings.

--root is required. It is canonicalized and becomes the filesystem boundary of that server instance, so use one entry per project root and keep the root explicit.

Verify the connection ​

Restart Codex after editing its configuration, then confirm that the six CodeGuard tools are available. To check the server independently of any client, use MCP Inspector:

Verify with MCP Inspector
npx @modelcontextprotocol/inspector codeguard mcp --root .

In Inspector, confirm initialization, list tools, call get_project_info, then call analyze_project.

Example workflow ​

  1. Ask the assistant to review the project with CodeGuard, or to run the review_project prompt.
  2. It calls get_project_info, then analyze_project.
  3. Ask it to explain a finding, for example SEC001, with explain_diagnostics.
  4. Review any suggested change yourself before applying it.

Common errors ​

  • Connection closes or tools are missing: confirm Node.js 24+, that codeguard is on the PATH the host uses, and that --root names an existing directory. Restart the host after changing configuration.
  • Host cannot find node: use an explicit Node executable path in the host configuration.
  • Server prints extra output: stdout carries MCP protocol messages only; diagnostics go to stderr.

More help is in Troubleshooting.

Other MCP clients ​

Generic MCP compatibility. Any client that can launch a stdio MCP server can use this command. Check your client's documentation for where to enter it.

Generic stdio launch command
codeguard mcp --root <project-root>

The command and arguments to give any client that launches stdio MCP servers.

VS Code uses the same pattern in .vscode/mcp.json:

.vscode/mcp.json
{
  "servers": {
    "codeguard": {
      "type": "stdio",
      "command": "codeguard",
      "args": ["mcp", "--root", "${workspaceFolder}"]
    }
  }
}

Clients not listed above are not yet tested.

MCP tools ​

All tools are read-only and scoped to the configured root.

analyze_project

Run a fresh whole-project analysis.

Expected usage
Ask for an overview of every finding in the configured root.
Arguments
includeSuggestions (optional boolean)
Response
Project name, type and language, files scanned, analyzer statuses, error and warning totals, bounded diagnostics and (by default) remediation suggestions.

analyze_file

Analyze one project-relative source file with its project context.

Expected usage
Use after a finding points at a file, or to check a file you just edited.
Arguments
filePath (required, project-relative)
Response
Diagnostics located in that file only.

get_project_info

Describe the project and its CodeGuard configuration.

Expected usage
A good first call so the assistant knows the project type and which analyzers are enabled.
Arguments
None
Response
Project name and root, type, language, frameworks, enabled analyzers, configuration status and the discovered source-file count.

get_diagnostics

Return a bounded, optionally filtered page of diagnostics from a fresh analysis.

Expected usage
Page through findings, or ask for errors only.
Arguments
severity (error, warning or all), limit (1–200), offset (all optional)
Response
A page of structured diagnostics.

get_security_issues

Return SEC001–SEC005 findings as potential issues for review.

Expected usage
Focused follow-up on security rules.
Arguments
None
Response
Security findings without secret values; reports explicitly when security analysis is disabled in configuration.

get_architecture_issues

Return ARCH001–ARCH002 findings about local dependencies.

Expected usage
Focused follow-up on circular or unresolved imports.
Arguments
None
Response
Architecture findings; reports explicitly when architecture analysis is disabled in configuration.

MCP prompts ​

Prompts are guidance templates. They do not execute an AI model and do not modify files. CodeGuard itself remains a deterministic static analysis tool.

review_project

Guides an assistant to review the project: gather project info, run the analysis, order findings by severity and propose remediation.

Arguments
focus (optional): all, typescript, javascript, security or architecture
Example
Run review_project with focus = security.
Limitations
A guidance template only. It does not run a model, and CodeGuard never edits files.

explain_diagnostics

Guides an assistant to explain a diagnostic code, its likely cause and a safe remediation, and to state uncertainty.

Arguments
code (required, e.g. TS2322 or SEC001); filePath (optional, project-relative)
Example
Run explain_diagnostics with code = SEC001.
Limitations
Codes accept letters, digits, '.', '_' and '-'. File paths must be relative and stay inside the project.

Verify and troubleshoot ​

See MCP setup for the full server reference and Troubleshooting for connection and prompt-argument problems.

Privacy and security ​

  • CodeGuard makes no network requests and no AI calls.
  • Whatever your MCP client receives (file paths, line numbers, messages and remediation text) may be sent onward by that client under its own privacy terms.
  • Secret values are not included in security findings, but keep credentials out of source files.
  • Point --root only at projects you are comfortable exposing to that client.

Read the full Security & Privacy page for details.