Skip to main content
Glama

check_tolk_syntax

Check Tolk source code for syntax and type errors quickly. Supports custom @alias import resolution for faster feedback during development.

Instructions

Checks Tolk source code for syntax and type errors without returning full compilation output. Faster feedback loop for iterative development. Supports pathMappings for custom @alias import resolution. Returns OK + code hash on success, or error details on failure.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
entrypointFileNameYesThe main .tolk file to check (e.g., "main.tolk")
sourcesYesObject mapping filename -> source code content. Must include the entrypoint file. Example: {"main.tolk": "fun main(): int { return 0; }"}
pathMappingsNoMaps @alias prefixes to absolute folder paths for import resolution. Example: {"@mylib": "/path/to/mylib"}

Implementation Reference

  • src/tools.ts:163-224 (registration)
    Registration of the 'check_tolk_syntax' tool via server.tool() calls on the MCP server.
    server.tool(
      "check_tolk_syntax",
      "Checks Tolk source code for syntax and type errors without returning full compilation output. " +
        "Faster feedback loop for iterative development. Supports pathMappings for custom @alias import resolution. " +
        "Returns OK + code hash on success, or error details on failure.",
      {
        entrypointFileName: z.string().describe('The main .tolk file to check (e.g., "main.tolk")'),
        sources: z
          .record(z.string(), z.string())
          .describe(
            "Object mapping filename -> source code content. Must include the entrypoint file. " +
              'Example: {"main.tolk": "fun main(): int { return 0; }"}',
          ),
        pathMappings: z
          .record(z.string(), z.string())
          .optional()
          .describe(
            "Maps @alias prefixes to absolute folder paths for import resolution. " +
              'Example: {"@mylib": "/path/to/mylib"}',
          ),
      },
      async (args) => {
        const { sources, entrypointFileName } = args;
    
        const validationError = validateSources(sources, entrypointFileName);
        if (validationError) {
          return {
            content: [{ type: "text", text: `Validation error: ${validationError}` }],
            isError: true,
          };
        }
    
        try {
          const result = await runTolkCompiler({
            entrypointFileName,
            fsReadCallback: makeFsReadCallback(sources),
            optimizationLevel: 2,
            withStackComments: false,
            ...(args.pathMappings ? { pathMappings: args.pathMappings } : {}),
          });
    
          if (result.status === "error") {
            return {
              content: [{ type: "text", text: `Syntax/type error:\n\n${result.message}` }],
              isError: true,
            };
          }
    
          let text = `OK — no errors found.\n\n**Code hash:** \`${result.codeHashHex}\``;
          if (result.stderr && result.stderr.length > 0) {
            text += `\n\n### Warnings\n\`\`\`\n${result.stderr}\n\`\`\``;
          }
    
          return { content: [{ type: "text", text }] };
        } catch (err) {
          return {
            content: [{ type: "text", text: `Unexpected compiler error: ${getErrorMessage(err)}` }],
            isError: true,
          };
        }
      },
    );
  • Zod schema definitions for check_tolk_syntax input parameters: entrypointFileName (string), sources (record of strings), optional pathMappings (record of strings).
    {
      entrypointFileName: z.string().describe('The main .tolk file to check (e.g., "main.tolk")'),
      sources: z
        .record(z.string(), z.string())
        .describe(
          "Object mapping filename -> source code content. Must include the entrypoint file. " +
            'Example: {"main.tolk": "fun main(): int { return 0; }"}',
        ),
      pathMappings: z
        .record(z.string(), z.string())
        .optional()
        .describe(
          "Maps @alias prefixes to absolute folder paths for import resolution. " +
            'Example: {"@mylib": "/path/to/mylib"}',
        ),
    },
  • Handler function for check_tolk_syntax: validates sources, runs the Tolk compiler (syntax-only mode with optimizationLevel=2, no stack comments), returns OK+code hash on success or syntax/type error details on failure.
    async (args) => {
      const { sources, entrypointFileName } = args;
    
      const validationError = validateSources(sources, entrypointFileName);
      if (validationError) {
        return {
          content: [{ type: "text", text: `Validation error: ${validationError}` }],
          isError: true,
        };
      }
    
      try {
        const result = await runTolkCompiler({
          entrypointFileName,
          fsReadCallback: makeFsReadCallback(sources),
          optimizationLevel: 2,
          withStackComments: false,
          ...(args.pathMappings ? { pathMappings: args.pathMappings } : {}),
        });
    
        if (result.status === "error") {
          return {
            content: [{ type: "text", text: `Syntax/type error:\n\n${result.message}` }],
            isError: true,
          };
        }
    
        let text = `OK — no errors found.\n\n**Code hash:** \`${result.codeHashHex}\``;
        if (result.stderr && result.stderr.length > 0) {
          text += `\n\n### Warnings\n\`\`\`\n${result.stderr}\n\`\`\``;
        }
    
        return { content: [{ type: "text", text }] };
      } catch (err) {
        return {
          content: [{ type: "text", text: `Unexpected compiler error: ${getErrorMessage(err)}` }],
          isError: true,
        };
      }
    },
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Without annotations, the description clearly states the return behavior: 'OK + code hash on success, or error details on failure'. It also mentions support for pathMappings in import resolution. No contradictory claims.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Three sentences, each adding distinct value: purpose, use case, and parameter highlight. No redundancy or extra words.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool has 3 parameters, nested objects, and no output schema, the description covers behavior, return format, and a key parameter detail. It is sufficient for an agent to understand when and how to use it.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Input schema covers all parameters with descriptions (100% coverage). The description adds value by explaining the purpose of 'pathMappings' for custom alias import resolution, which goes beyond the schema's generic description.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Clearly states the tool checks Tolk source code for syntax and type errors, and explicitly distinguishes it from 'compile_tolk' by noting it does not return full compilation output. Verb and resource are specific.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Describes the tool as providing a 'faster feedback loop for iterative development', implying it is for quick checks. While it does not explicitly name alternatives, the sibling tool 'compile_tolk' contrasts with the description's emphasis on speed and lighter output.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/izzzzzi/izTolkMcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server