This document is the reference for every tool cjdrift exposes. Each section lists the tool's MCP method name, its input schema (JSON Schema 2020-12), and the shape of the result it returns.
The result for every tool is a single TextBlock whose text is a
JSON object. The shape of that object is documented below under
"Result".
Fuzzy search the offline Cangjie 1.1.3 standard-library index.
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
| query | string | yes | — | Free-text search. Matches against type name, member name, package name, and signature. |
| limit | integer | no | 10 | Max results to return. Hard cap 50. |
| kind | string | no | — | Optional filter: "type", "func", "macro", "const", or "trait". |
{
"count": 3,
"total_indexed": 142,
"results": [
{
"id": "std.core.ArrayList.append",
"package": "std.core",
"type": "ArrayList",
"member": "append",
"kind": "func",
"signature": "func append(value: T): Unit",
"summary": "Appends `value` to the end of the list. Amortised O(1).",
"detail": "If the underlying buffer is full, the list grows by 1.5x or 2x. Pre-allocate with `ArrayList<T>(capacity: n)` if you know the size in advance."
}
]
}Look up the long-form record for a single API entry, with a few related entries from the same package.
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
| package | string | yes | — | Package name, e.g. "std.collection". |
| type | string | no | — | Type name within the package. Omit for free functions. |
| member | string | no | — | Member name within the type. Omit for the type itself. |
| related | integer | no | 5 | How many related entries to include. Hard cap 20. |
{
"found": true,
"id": "std.core.ArrayList.append",
"package": "std.core",
"type": "ArrayList",
"member": "append",
"kind": "func",
"signature": "func append(value: T): Unit",
"summary": "Appends `value` to the end of the list. Amortised O(1).",
"detail": "If the underlying buffer is full, the list grows by 1.5x or 2x. Pre-allocate with `ArrayList<T>(capacity: n)` if you know the size in advance.",
"related": [
{ "id": "std.core.ArrayList.size", "signature": "func size(): Int64", "summary": "..." }
]
}When the requested entry does not exist, the tool returns
{"found": false, "requested": "...", "alternatives": [...]} with a
small fuzzy-search fallback so the LLM can recover from a typo.
Search the built-in pattern library for short, idiomatic Cangjie snippets.
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
| query | string | yes | — | Free-text intent. Examples: "parse json", "spawn task", "test runner". |
| limit | integer | no | 5 | Max results. Hard cap 10. |
{
"count": 2,
"total_indexed": 10,
"results": [
{
"id": "json-parse",
"title": "Parse a JSON document",
"tags": ["json", "parse", "decoder"],
"body": "import std.json.JsonParser\nlet v = match (JsonParser(text).parse()) {\n case Ok(x) => x\n case Err(e) => throw Exception(\"bad json: ${e}\")\n}\n",
"notes": "Use cjdrift's parseStrict (in core.jsonx) to reject trailing garbage."
}
]
}Run an allow-listed cjpm or cjpm / cjc / cjlint / cjfmt
subcommand and return the captured output.
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
| command | string | yes | — | One of: build, test, run, update, clean, lint, fmt, check, info, version. |
| cwd | string | no | "." | Working directory. |
| extra_args | array | no | [] | Optional extra flags passed to the subcommand verbatim. |
| timeout_ms | integer | no | 60000 | Process timeout. Hard cap 600000. |
{
"binary": "cjpm",
"args": ["build"],
"cwd": ".",
"exit_code": 0,
"elapsed_ms": 1234,
"output": "... stdout + stderr, truncated to 16 KiB ...",
"ok": true
}Run cjlint and group the findings by rule and severity.
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
| path | string | no | "." | Source directory to lint. |
| rules | array | no | [] | Optional list of rule IDs (e.g. ["G.FMT.01"]). |
| severity | string | no | "info" | One of "error", "warning", "info". Filters out lower severities. |
{
"total_diagnostics": 47,
"kept_after_severity_filter": 12,
"severity_filter": "warning",
"by_rule": [
{ "rule": "G.FMT.01", "count": 7 },
{ "rule": "G.ENU.01", "count": 5 }
],
"findings": [
{
"rule": "G.FMT.01",
"level": "warning",
"message": "...",
"file": "src/foo.cj",
"line": 12,
"column": 5
}
]
}Run cjfmt in either dry_run (default) or write mode.
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
| path | string | yes | — | Path to a .cj file or a directory. |
| dry_run | boolean | no | true | If true, do not write; just return a unified diff. |
| config | string | no | — | Optional cjfmt config file path. |
{
"exit_code": 0,
"mode": "dry_run",
"diff": "--- src/foo.cj\n+++ src/foo.cj\n@@ ...",
"changed": true
}Search the Cangjie central registry for packages.
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
| query | string | yes | — | Search term. Matches against package name and description. |
| limit | integer | no | 10 | Max results. Hard cap 20. |
{
"count": 3,
"query": "json",
"results": [
{
"name": "fast_json_cj",
"description": "High-performance JSON serialization library",
"latest_version": "1.0.4",
"downloads_month": 0
}
]
}When the registry is unreachable, the source field on each result
is set to "offline-seed".
Generate a ready-to-build Cangjie project skeleton.
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
| path | string | yes | — | Directory to create the project in. |
| name | string | no | dir basename | Project name. |
| kind | string | no | "executable" | One of "executable", "library", "mcp-server". |
| force | boolean | no | false | Overwrite existing files. |
{
"path": "/path/to/project",
"kind": "executable",
"name": "myapp",
"written": ["cjpm.toml", "src/main.cj", "README.md"]
}Look up a Cangjie / cjc / cjpm / cjlint error message and return one or more hypothesised diagnoses.
| Field | Type | Required | Description |
|---|---|---|---|
| error | string | yes | Raw error text. May be multi-line. |
{
"matches": 1,
"rule_count": 14,
"diagnoses": [
{
"title": "Cannot find symbol",
"category": "import",
"body": "The compiler does not see a name you used. The most common causes are ...",
"fixes": [
"Add `import <package>` at the top of the file",
"Check spelling; Cangjie identifiers are case-sensitive",
"Run `cjpm update` to pull missing dependencies"
]
}
]
}Read a text file under a configured project root.
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
| path | string | yes | — | File path, relative to root. |
| root | string | no | "." | Project root. |
| start_line | integer | no | 0 | 0-based inclusive start line. |
| end_line | integer | no | -1 | 0-based exclusive end line. -1 = end of file. |
| max_bytes | integer | no | 65536 | Hard cap on returned bytes. Hard cap 1 MiB. |
| allow_absolute | boolean | no | false | Permit absolute paths. |
{
"path": "/abs/path/to/file.cj",
"total_lines": 240,
"start_line": 10,
"end_line": 25,
"bytes_returned": 1024,
"content": "..."
}Write a text file under a configured project root. Requires
confirm: true to actually perform the write.
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
| path | string | yes | — | File path, relative to root. |
| content | string | yes | — | New file content. |
| root | string | no | "." | Project root. |
| confirm | boolean | no | false | Must be true to actually write. |
| allow_absolute | boolean | no | false | Permit absolute paths. |
{
"status": "preview",
"hint": "set confirm=true to actually write the file",
"would_write_bytes": 1024,
"path": "src/foo.cj"
}{
"status": "written",
"path": "/abs/path/to/foo.cj",
"bytes": 1024
}List the entries of a directory under the project root.
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
| path | string | no | "." | Directory path, relative to root. |
| root | string | no | "." | Project root. |
| include_hidden | boolean | no | true | Include dotfiles. |
| allow_absolute | boolean | no | false | Permit absolute paths. |
{
"path": "/abs/path/to/dir",
"count": 5,
"entries": [
{ "name": "src", "type": "dir", "size": 0 },
{ "name": "cjpm.toml", "type": "file", "size": 312 }
]
}