Documentation
¶
Overview ¶
Package mcpgen — language-agnostic files every scaffolded project gets. .clawtool/mcp.toml is the discovery marker `mcp list` walks for; .claude-plugin/ is the optional manifest from ADR-019.
Package mcpgen — Go adapter (ADR-007: wraps mark3labs/mcp-go).
Package mcpgen implements the `clawtool mcp new` generator (ADR-019). Per ADR-007 each language adapter wraps the canonical SDK in that ecosystem (mcp-go for Go, fastmcp for Python, @modelcontextprotocol/sdk for TypeScript). We never re-implement MCP wire protocol — the templates emit ~50 LoC of glue around each SDK's documented "register a tool" call.
Lifecycle:
- Spec: the operator's choices captured by the wizard (language, transport, packaging, tool list).
- Plan: a list of Files the language adapter wants written.
- Apply: write the files atomically + emit the .clawtool/mcp.toml marker.
Adding a fourth language is one new adapter — every language's surface goes through the Adapter interface so the wizard / install path don't grow per-language switches.
Package mcpgen — Python adapter (ADR-007: wraps fastmcp).
Package mcpgen — TypeScript adapter (ADR-007: wraps @modelcontextprotocol/sdk).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Generate ¶
Generate plans + writes a fresh project rooted at outputDir (which becomes outputDir/spec.Name). Refuses to overwrite an existing directory — operators delete first or pick a new name.
Types ¶
type Adapter ¶
Adapter is the per-language template. Each adapter renders a Spec into a Plan; the orchestrator (Generate) writes them.
type File ¶
File is a single artifact the adapter wants written. Mode 0o755 for executable scripts, 0o644 for everything else.
type Spec ¶
type Spec struct {
Name string // kebab-case project name (also dir name)
Description string // server self-description string
Language string // "go" | "python" | "typescript"
Transport string // "stdio" | "streamable-http"
Packaging string // "native" | "docker"
Tools []ToolSpec
Plugin bool // generate .claude-plugin/ alongside source
}
Spec is the wizard's output: everything the language adapter needs to render a project. Tests construct this directly to drive Generate without running huh.
type ToolSpec ¶
type ToolSpec struct {
Name string // snake_case
Description string
Schema string // JSON object string (e.g. `{"type":"object","properties":{...}}`)
}
ToolSpec describes one MCP tool the generated server registers. Schema is stored as a raw JSON Schema object so adapters can emit it verbatim into their language's idiomatic shape.