Skip to content

chant serve mcp

chant serve mcp [path]

chant serve mcp starts an MCP (Model Context Protocol) server over stdio. This allows AI agents that support MCP — such as Claude Code, Cursor, and Windsurf — to interact with your chant project programmatically.

Typically you don’t run this directly. chant init detects your IDE and writes the MCP config to the appropriate global config file — ~/.claude/mcp.json for Claude Code, ~/.cursor/mcp.json for Cursor, or ~/.config/mcp/mcp.json otherwise. Your agent picks it up automatically. See Agent Integration.

The server exposes six core tools that agents can invoke:

Build chant infrastructure code and generate output for the target lexicon.

ParameterTypeRequiredDescription
pathstringYesPath to the infrastructure directory or file
outputstringNoOutput file path (returns in response if omitted)
format"json" | "yaml"NoOutput format (default: json)

Returns { success, resourceCount, output, format }.

Lint chant infrastructure code and report issues.

ParameterTypeRequiredDescription
pathstringYesPath to the infrastructure directory or file
fixbooleanNoAuto-fix fixable issues (default: false)

Returns { success, errorCount, warningCount, diagnostics, output }.

Import external templates and convert them to chant TypeScript.

ParameterTypeRequiredDescription
sourcestringYesPath to the template file to import
outputstringNoOutput directory (default: ./infra/)

Returns { success, lexicon, generatedFiles, warnings }.

Summarize the resources in a chant project.

ParameterTypeRequiredDescription
pathstringYesPath to the infrastructure directory
format"markdown" | "json"NoOutput format (default: markdown)

Returns a structured summary of resource counts, entity types, and lexicon groupings.

Generate starter files for a chant project.

ParameterTypeRequiredDescription
patternstringYesResource pattern to scaffold (e.g. "s3-bucket", "pipeline")
lexiconstringNoLexicon to use for templates

Returns { success, files } with generated file contents.

Search available resource types across loaded lexicons.

ParameterTypeRequiredDescription
querystringYesSearch query (case-insensitive substring match)
lexiconstringNoFilter to a specific lexicon
limitnumberNoMaximum results (default: 20)

Returns matching resource type entries sorted by relevance.

Lexicon plugins can contribute additional tools. Plugin tools are namespaced as {pluginName}:{toolName} to avoid conflicts with core tools.

The server provides resources that agents can read for context:

URIMIME TypeDescription
chant://contexttext/markdownLexicon-specific instructions, patterns, and best practices
chant://examples/listapplication/jsonJSON array of available examples ([{ name, description }])
chant://examples/<name>text/typescriptSource code of a specific example

Lexicon plugins can contribute additional resources, namespaced as chant://{pluginName}/{path}. Plugin resources with /examples/ in their URI are automatically included in the examples list.

chant init detects your IDE and adds the MCP server to the appropriate global config file:

IDEConfig path
Claude Code~/.claude/mcp.json
Cursor~/.cursor/mcp.json
Other~/.config/mcp/mcp.json

The config looks like:

{
"mcpServers": {
"chant": {
"command": "npx",
"args": ["chant", "serve", "mcp"]
}
}
}

(bunx is used instead of npx when bun is detected as the package manager.)

If your agent doesn’t auto-detect the MCP config, configure the server manually. The command is:

Terminal window
chant serve mcp

The server communicates over stdin/stdout using JSON-RPC 2.0 with line-based framing (one JSON object per line).

The MCP server implements the Model Context Protocol specification version 2024-11-05.

MethodDescription
initializeHandshake — returns protocol version, capabilities, and server info
tools/listList all available tools (core + plugin-contributed)
tools/callInvoke a tool by name with parameters
resources/listList all available resources (core + plugin-contributed)
resources/readRead a resource by URI
CodeMeaning
0Clean shutdown
1Unknown subcommand or startup failure