Skip to main content

MCP Tools Reference

This note provides implementation details for AD-013.

Kapi MCP Server

Started via kapi mcp. The tools default to ad-hoc single-file processing, but optionally accept a project (.kapi) file for project-scoped defaults and content resolution.

Server info: {"name": "kapi", "version": "<version>"}

list_formats

List all supported file formats with their extensions, MIME types, and read/write capabilities.

Input: none

Output (one element shown; total is len(formats), set at runtime from the live registry, so the real value tracks the registered formats — see the generated Format Reference):

{
"formats": [
{
"name": "json",
"display_name": "JSON",
"extensions": [".json"],
"mime_types": ["application/json"],
"has_reader": true,
"has_writer": true,
"source": "built-in"
}
// …one entry per registered format
],
"total": 0 // = len(formats), runtime-dependent
}

detect_format

Detect the file format from a file path based on its extension.

Input:

ParameterTypeRequiredDescription
pathstringyesFile path to detect format from

Output:

{
"format": "json",
"extensions": [".json"],
"has_reader": true,
"has_writer": true
}

extract_content

Parse a file and extract translatable content blocks with source text and word counts.

Input:

ParameterTypeRequiredDescription
pathstringyesFile path to extract content from
formatstringnoOverride format detection
source_langstringnoSource language (default: en)
projectstringnoPath to .kapi project file for scoped format detection

Output:

{
"format": "json",
"word_count": 42,
"blocks": [
{
"id": "greeting",
"source_text": "Hello World",
"word_count": 2
}
]
}

word_count

Count translatable words in a file.

Input:

ParameterTypeRequiredDescription
pathstringyesFile path to count words in
formatstringnoOverride format detection
source_langstringnoSource language (default: en)
projectstringnoPath to .kapi project file for scoped format detection

Output:

{
"format": "json",
"word_count": 42,
"block_count": 5
}

run_flow

Execute a processing flow on a file. The flow name is any built-in flow from list_flows (e.g. pseudo-translate, qa-check, tm-leverage, ai-translate-qa, secure-translate). AI-powered flows (e.g. ai-translate, ai-translate-qa) run only when the required provider API keys are configured.

Input:

ParameterTypeRequiredDescription
flow_namestringyesName of the flow (e.g. pseudo-translate)
pathstringyes*Input file path (*optional when a project file with content patterns resolves the inputs)
projectstringnoPath to a .kapi project file for project-scoped execution (resolves inputs from content patterns)
source_langstringnoSource language (default: en)
target_langstringyes*Target language (*optional for pseudo-translate, defaults to qps)
output_pathstringnoOutput file path (default: auto-generated as <base>_<lang><ext>)

Output:

{
"flow_name": "pseudo-translate",
"input_path": "locales/en.json",
"output_path": "locales/en_qps.json"
}

pseudo_translate

Shorthand for run_flow with flow_name: "pseudo-translate". Pseudo-translates a file for localization QA testing.

Input:

ParameterTypeRequiredDescription
pathstringyesFile path to pseudo-translate
target_langstringnoTarget language (default: qps)
output_pathstringnoOutput file path (default: auto-generated)

Output: same as run_flow.

list_flows

List all available processing flows.

Input: none

Output (illustrative selection; total is len(flow.BuiltInFlows())):

{
"flows": [
{ "name": "pseudo-translate", "description": "Generate pseudo-translations for testing" },
{ "name": "qa-check", "description": "Run rule-based quality checks on translations" },
{ "name": "ai-translate", "description": "Translate content using AI/LLM" }
// …one entry per built-in flow
],
"total": 0 // = len(flow.BuiltInFlows()), runtime-dependent
}

list_tools

List all available processing tools (built-in and plugin-provided).

Input: none

Output (one element shown; total is len(tools), runtime-dependent — see the generated Tool Reference):

{
"tools": [
{
"name": "word-count",
"description": "Count translatable words in content",
"source": "built-in"
}
// …one entry per registered tool
],
"total": 0 // = len(tools), runtime-dependent
}

Brand, terminology, and TM tools

The shared CLI base (cli/mcp_brand.go) registers a further set of offline tools on the same mcp stdio server via RegisterMCPToolFactory, so any binary built on the CLI base (including kapi) exposes them, so non-Claude MCP clients get local parity with the brand tools. All run offline against local files and SQLite stores.

brand_guide

Render a brand voice guide (markdown) from a starter pack or a profile YAML, to inject into context before generating content.

Input:

ParameterTypeRequiredDescription
profile_packstringone of pack/fileStarter pack name (e.g. marketing-blog, technical-docs)
profile_filestringone of pack/filePath to a profile YAML

Output:

FieldTypeDescription
profilestringResolved profile name
guidestringRendered markdown voice guide

brand_check

Score text against a brand voice profile using deterministic vocabulary rules; returns a 0–100 compliance score and findings.

Input:

ParameterTypeRequiredDescription
textstringyesThe text to check
profile_packstringone of pack/fileStarter pack name
profile_filestringone of pack/filePath to a profile YAML

Output:

FieldTypeDescription
profilestringResolved profile name
scoreintOverall 0–100 compliance score
dimensionsarrayPer-dimension scores
findingsarrayVocabulary findings

brand_rewrite

Rewrite text to comply with a brand voice profile by substituting forbidden/competitor terms (deterministic, offline).

Input: same as brand_check.

Output:

FieldTypeDescription
profilestringResolved profile name
originalstringInput text
rewrittenstringRewritten text
changesarray{from, to, count} substitutions made

term_lookup

Look up a term in a local termbase to enforce consistent terminology.

Input:

ParameterTypeRequiredDescription
termstringyesThe term to look up
source_langstringnoSource locale (e.g. en)
target_langstringnoTarget locale (e.g. fr)
termbasestringnoPath to the termbase db (default: termbase.db)

Output:

FieldTypeDescription
matchesarray{term, locale, status, match_type} entries
totalintlen(matches)

Search a local translation memory for prior translations of source text.

Input:

ParameterTypeRequiredDescription
textstringyesSource text to search for
source_langstringyesSource locale (e.g. en)
target_langstringyesTarget locale (e.g. fr)
min_scorenumbernoMinimum match score 0–1 (default: 0.7)
tmstringnoPath to the TM db (default: tm.db)

Output:

FieldTypeDescription
matchesarray{source, target, score, match_type} entries (max 10)
totalintlen(matches)

Implementation Files

FilePurpose
cli/mcp.goShared mcp subcommand + server bootstrap (NewMCPCmd)
cli/mcp_brand.goShared brand/terminology/TM MCP tools registered via RegisterMCPToolFactory (brand_guide, brand_check, brand_rewrite, term_lookup, tm_search) + their input/output types
kapi/cmd/kapi/root.goWires the kapi root command, including mcp
kapi/cmd/kapi/mcp_tools.gokapi MCP tool handlers + input/output types (list_formats, detect_format, extract_content, run_flow, list_flows, word_count, list_tools, pseudo_translate)
kapi/cmd/kapi/mcp_tools_test.goUnit tests for kapi MCP handlers

Testing

The MCP handshake can be verified manually:

echo '{"jsonrpc":"2.0","method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"test","version":"1.0"}},"id":1}' \
| kapi mcp 2>/dev/null