Markdown Helpers

Markdown helpers of the public tools that show files: code fences, and numbered lines.

Note

Experimental. The MCPServer was designed and coded by Claude Code (Anthropic’s Claude Opus 5.5), with Lawrence McDaniel as co-author. It is experimental, and will be documented.

smarter.apps.mcpserver.protocol.tools.markdown.CODE_FENCE_LANGUAGES = {'.css': 'css', '.go': 'go', '.hcl': 'hcl', '.html': 'html', '.js': 'javascript', '.json': 'json', '.jsx': 'jsx', '.md': 'markdown', '.py': 'python', '.rst': 'rst', '.scss': 'scss', '.sh': 'bash', '.sql': 'sql', '.tf': 'hcl', '.toml': 'toml', '.ts': 'typescript', '.tsx': 'tsx', '.yaml': 'yaml', '.yml': 'yaml'}

The language of a Markdown code fence, by file extension, so that a client highlights the code.

Others are text.

{
    '.css': 'css',
    '.go': 'go',
    '.hcl': 'hcl',
    '.html': 'html',
    '.js': 'javascript',
    '.json': 'json',
    '.jsx': 'jsx',
    '.md': 'markdown',
    '.py': 'python',
    '.rst': 'rst',
    '.scss': 'scss',
    '.sh': 'bash',
    '.sql': 'sql',
    '.tf': 'hcl',
    '.toml': 'toml',
    '.ts': 'typescript',
    '.tsx': 'tsx',
    '.yaml': 'yaml',
    '.yml': 'yaml',
}
smarter.apps.mcpserver.protocol.tools.markdown.code_fence_language(path)[source]

Return the Markdown code fence language of a file.

Parameters:

path (str) – The file’s path.

Return type:

str

Returns:

The language, from CODE_FENCE_LANGUAGES, or text.

smarter.apps.mcpserver.protocol.tools.markdown.numbered_excerpt(lines)[source]

Return a hit’s lines, each after its line number, right-aligned, for a code block.

Parameters:

lines (list[SearchLine]) – The hit’s lines.

Return type:

str

Returns:

The lines, e.g. `` 9 text`` and 10  text.