@kernlang/mcp-server

Give any AI agent the ability to write, compile, review, and self-correct .kern code through MCP.

What your agent gets

The KERN MCP server exposes the full compiler, reviewer, and language schema. An agent using this server can:

  1. Ask what it can writeschema returns the full language spec as JSON
  2. Compile .kern to any target — Next.js, React, Vue, Express, FastAPI, MCP servers, and more
  3. Self-correct from errorscompile-json returns structured diagnostics with line numbers and suggestions
  4. Review code — 98 static analysis rules with taint tracking and OWASP coverage
  5. Scan MCP servers — 12 security rules mapped to OWASP MCP Top 10

Quick start

Claude Desktop

Add to ~/Library/Application Support/Claude/claude_desktop_config.json:

{
  "mcpServers": {
    "kern": {
      "command": "npx",
      "args": ["@kernlang/mcp-server"]
    }
  }
}

Cursor

Add to .cursor/mcp.json in your project:

{
  "mcpServers": {
    "kern": {
      "command": "npx",
      "args": ["@kernlang/mcp-server"]
    }
  }
}

Claude Code

claude mcp add kern -- npx @kernlang/mcp-server

VS Code / Windsurf

Add to your MCP settings:

{
  "kern": {
    "command": "npx",
    "args": ["@kernlang/mcp-server"]
  }
}

Hosted endpoint (no install)

KERN runs a live MCP server at https://kernlang.dev/api/mcp. Point any MCP client that supports Streamable HTTP at this URL — no npm install required.


Tools

ToolDescription
compileCompile .kern source to any of 12 targets. Returns generated code.
compile-jsonCompile with structured JSON diagnostics (code, line, col, suggestion). For self-correction.
schemaFull KERN language schema as JSON — node types, props, children, shorthands.
reviewRun 98 static analysis rules on TypeScript/JavaScript. Taint tracking, OWASP.
review-kernLint .kern source for structural issues, missing props, pattern violations.
review-mcp-serverScan MCP server code for security vulnerabilities. 12 rules, OWASP MCP Top 10.
parseParse .kern to intermediate representation (IR). For debugging.
decompileConvert IR back to readable .kern text.
validateValidate .kern syntax without compiling.
list-targetsList all 12 compile targets with descriptions.
list-nodesBrowse node types by category with props and allowed children.

Resources

URIDescription
kern://specFull language specification — grammar, node types, shorthands, targets
kern://examples/{category}Example code by category: ui, api, state-machine, mcp, terminal
kern://targetsAvailable compile targets as JSON

Prompts

write-kern

Comprehensive system prompt that teaches an LLM how to write .kern code — grammar rules, node types, style shorthands, and annotated examples for UI, API, state machines, MCP servers, hooks, and type systems.


Self-correction loop

The schema and compile-json tools enable autonomous code generation:

1. schema          → "what can I write?"
2. write .kern     → generate code using schema
3. compile-json    → "did I get it right?"
4. if errors:
     read diagnostics (line, col, suggestion)
     fix and goto 3
5. done — no human intervention needed

Each diagnostic includes code, severity, line, col, endCol, and suggestion — everything an LLM needs to fix its own mistakes.


KERN syntax at a glance

KERN uses indent-based nesting with key=value props. Comments use // or #. Inline code uses <<< ... >>> blocks.

// Comments work with // or #
# This is also a comment

doc text="User management API"
server name=UserAPI port=3001
  middleware name=cors
  middleware name=json

  route GET /api/users
    auth required
    handler <<<
      const users = await db.query('SELECT * FROM users');
      res.json(users);
    >>>
// State machine — 7 lines → 140+ lines TypeScript
machine name=Order initial=pending
  transition from=pending to=confirmed event=confirm
  transition from=confirmed to=shipped event=ship
  transition from=shipped to=delivered event=deliver
  transition from=pending to=cancelled event=cancel

MCP Security in VS Code

The kern-mcp-security extension brings the 12 MCP security rules directly into your editor. Inline diagnostics for command injection, tool poisoning, path traversal, and more — no CLI needed.

ext install kernlang.kern-mcp-security