Model Context Protocol

KERN + MCP

Write MCP servers. Audit MCP servers. Be an MCP server. Three capabilities. One language.

The agent lifecycle

Compile to MCP

Write an MCP server in .kern. Guards, tools, resources, prompts — all declarative. Compiles to a production MCP server with security built in.

mcp name=FileTools version=1.0

  tool name=readFile
    description text="Read a file"
    param name=path type=string
    guard type=pathContainment
      param=path allowlist=/data
    handler <<<
      const content = await
        fs.readFile(params.path, 'utf-8');
      return { content: [{
        type: "text", text: content
      }] };
    >>>
MCP server docs →

Audit MCP Servers

12 security rules mapped to the OWASP MCP Top 10. Catches command injection, tool poisoning, path traversal, secrets leaks, and more.

$ kern review-mcp src/server.ts

! MCP01 command-injection
  User param flows to exec()
  server.ts:24

! MCP03 tool-description-poisoning
  Hidden instruction in description
  server.ts:8

~ MCP06 missing-input-validation
  Tool param used without validation
  server.ts:31

\u2713 3 findings (2 errors, 1 warning)
MCP security rules →

Be an MCP Server

@kernlang/mcp-server gives any AI agent the ability to write, compile, review, and self-correct .kern code. 11 tools. 3 resources. 1 prompt.

// Agent self-correction loop
1. schema        → "what can I write?"
2. write .kern   → generate code
3. compile-json  → "did I get it right?"
4. if errors:
     read diagnostics
     fix and goto 3
5. done — zero human intervention
Setup guide →
11

MCP tools

12

compile targets

12

security rules

98

review rules

What your agent gets

11 tools, 3 resources, and a system prompt — everything an agent needs to write production code.

compile

Compile .kern to any of 12 targets. Returns generated code.

compile-json

Compile with structured JSON diagnostics — line, col, suggestion. For self-correction loops.

schema

Full language schema as JSON. Node types, props, children, shorthands.

review

98 static analysis rules on TypeScript/JavaScript. Taint tracking, OWASP.

review-kern

Lint .kern source for structural issues and pattern violations.

review-mcp-server

Scan MCP server code. 12 rules mapped to OWASP MCP Top 10.

parse

Parse .kern to IR. Debugging and structure inspection.

decompile

IR back to readable .kern text.

validate

Syntax check without compilation.

list-targets

All 12 compile targets with descriptions.

list-nodes

Browse node types by category with props and children.

Plus 3 resources (kern://spec, kern://examples/{category}, kern://targets) and a write-kern system prompt.

Connect your agent

One line. Your agent can now write, compile, and review KERN code.

Claude Desktop~/Library/.../claude_desktop_config.json
{
  "mcpServers": {
    "kern": {
      "command": "npx",
      "args": ["@kernlang/mcp-server"]
    }
  }
}
Cursor.cursor/mcp.json
{
  "mcpServers": {
    "kern": {
      "command": "npx",
      "args": ["@kernlang/mcp-server"]
    }
  }
}
Claude CodeTerminal
claude mcp add kern -- npx @kernlang/mcp-server
VS Code / WindsurfMCP settings
{
  "kern": {
    "command": "npx",
    "args": ["@kernlang/mcp-server"]
  }
}

Live MCP endpoint

KERN runs an MCP server on this site. Point any MCP client at it — no install required.

https://kernlang.dev/api/mcp

Streamable HTTP transport. Compatible with any MCP client that supports remote servers.

MCP Security in VS Code

Scan MCP servers for vulnerabilities directly in the editor. 12 rules mapped to OWASP MCP Top 10 — inline diagnostics, no setup.

ext install kernlang.kern-mcp-security

Why this matters

MCP is how AI agents discover and use tools. KERN is the first language where the language itself is an MCP tool.

Zero-install discovery

Agents discover KERN through MCP. No npm install needed for the hosted endpoint. Copy one URL, paste into your client.

Self-correction loops

compile-json returns structured diagnostics. Agents fix their own mistakes in a loop — no human intervention.

Security by default

MCP servers compiled from .kern include guards. MCP servers reviewed by kern catch OWASP Top 10. Both sides covered.

Give your agent superpowers

One MCP server. 12 targets. 98 review rules. Your agent writes better code.