MCPcopy
hub / github.com/compiler-explorer/compiler-explorer / registerCompileTool

Function registerCompileTool

lib/mcp/tools/compile.ts:39–278  ·  view source on GitHub ↗
(server: McpServer, compileHandler: CompileHandler, apiHandler: ApiHandler)

Source from the content-addressed store, hash-verified

37const DEFAULT_MAX_STDERR_LINES = 100;
38
39export function registerCompileTool(server: McpServer, compileHandler: CompileHandler, apiHandler: ApiHandler): void {
40 server.tool(
41 'compile',
42 'Compile source code and return assembly output, stdout, and stderr',
43 {
44 source: z.string().describe('Source code to compile'),
45 language: z.string().describe('Language ID (e.g. "c++", "c", "rust", "python")'),
46 compiler: z
47 .string()
48 .optional()
49 .describe(
50 'Compiler ID from list_compilers (e.g. "g161"). If omitted, uses the language\'s ' +
51 '`defaultCompiler` from list_languages.',
52 ),
53 options: z.string().optional().describe('Compiler flags (e.g. "-O2 -std=c++20 -Wall")'),
54 execute: z
55 .boolean()
56 .optional()
57 .describe(
58 'Run the program instead of returning assembly. `asm` becomes empty; runtime output goes to ' +
59 'top-level `stdout`/`stderr`; compile diagnostics move to `buildResult.stdout`/`stderr`.',
60 ),
61 stdin: z.string().optional().describe('Standard input for execution (requires execute=true)'),
62 filters: z
63 .object({
64 intel: z.boolean().optional().describe('Use Intel assembly syntax (default: true)'),
65 demangle: z.boolean().optional().describe('Demangle symbol names (default: true)'),
66 directives: z.boolean().optional().describe('Filter assembler directives (default: true)'),
67 commentOnly: z.boolean().optional().describe('Filter comment-only lines (default: true)'),
68 labels: z.boolean().optional().describe('Filter unused labels (default: true)'),
69 libraryCode: z.boolean().optional().describe('Filter library code (default: false)'),
70 trim: z.boolean().optional().describe('Trim whitespace (default: false)'),
71 })
72 .optional()
73 .describe('Output filters'),
74 libraries: z
75 .array(
76 z.object({
77 id: z.string().describe('Library ID from list_libraries (e.g. "boost").'),
78 version: z.string().describe('Version id ("188") OR human form ("1.88.0") — both accepted.'),
79 }),
80 )
81 .optional()
82 .describe('Libraries to link.'),
83 maxAsmLines: z
84 .number()
85 .int()
86 .positive()
87 .optional()
88 .describe(`Cap asm output (default ${DEFAULT_MAX_ASM_LINES} lines).`),
89 maxStdoutLines: z
90 .number()
91 .int()
92 .positive()
93 .optional()
94 .describe(
95 `Cap each stdout stream — compile and execute separately (default ${DEFAULT_MAX_STDOUT_LINES}).`,
96 ),

Callers 2

createMcpServerFunction · 0.85
mcp-tests.tsFile · 0.85

Calls 12

truncateLinesFunction · 0.85
stringMethod · 0.80
booleanMethod · 0.80
objectMethod · 0.80
arrayMethod · 0.80
numberMethod · 0.80
getLibrariesAsArrayMethod · 0.80
getDefaultCompilerForMethod · 0.80
parseRequestReusableMethod · 0.80
findCompilerMethod · 0.45
compileMethod · 0.45

Tested by

no test coverage detected