Skip to main content
Glama
bazinga012

MCP Code Executor

read_code_file

Read Python code files to verify content before appending or executing, ensuring accurate code modifications and execution.

Instructions

Read the content of an existing Python code file. Use this to verify the current state of a file before appending more content or executing it.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
file_pathYesFull path to the file to read

Implementation Reference

  • The core handler function that implements the logic for the 'read_code_file' tool: checks if the file exists, reads its content using fs.readFile, and returns a structured JSON response.
    async function readCodeFile(filePath: string) {
        try {
            // Ensure file exists
            await access(filePath);
            
            // Read file content
            const content = await readFile(filePath, 'utf-8');
            
            return {
                type: 'text',
                text: JSON.stringify({
                    status: 'success',
                    content: content,
                    file_path: filePath
                }),
                isError: false
            };
        } catch (error) {
            return {
                type: 'text',
                text: JSON.stringify({
                    status: 'error',
                    error: error instanceof Error ? error.message : String(error),
                    file_path: filePath
                }),
                isError: true
            };
        }
    }
  • src/index.ts:843-858 (registration)
    The registration and dispatch handler in the CallToolRequestSchema switch statement that extracts arguments, validates file_path, calls the readCodeFile handler, and formats the MCP response.
    case "read_code_file": {
        const args = request.params.arguments as ReadCodeFileArgs;
        if (!args?.file_path) {
            throw new Error("File path is required");
        }
    
        const result = await readCodeFile(args.file_path);
    
        return {
            content: [{
                type: "text",
                text: result.text,
                isError: result.isError
            }]
        };
    }
  • The tool schema registration in ListToolsRequestSchema, defining the name, description, and input schema requiring 'file_path' string.
        name: "read_code_file",
        description: "Read the content of an existing Python code file. Use this to verify the current state of a file before appending more content or executing it.",
        inputSchema: {
            type: "object",
            properties: {
                file_path: {
                    type: "string",
                    description: "Full path to the file to read"
                }
            },
            required: ["file_path"]
        }
    },
  • TypeScript interface defining the input arguments for the 'read_code_file' tool.
    interface ReadCodeFileArgs {
        file_path?: string;
    }
Behavior3/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It correctly identifies this as a read operation and mentions the file must be 'existing,' but doesn't disclose error handling, file size limitations, encoding considerations, or what happens with non-existent files. The description provides basic behavioral context but lacks important operational details.

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?

The description consists of two well-structured sentences that efficiently convey purpose and usage guidelines. Every word serves a clear function, with no redundant information or unnecessary elaboration. It's appropriately sized for the tool's complexity.

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's simple single-parameter read operation with no output schema, the description provides adequate context about when to use it and what it does. However, without annotations or output schema, it could benefit from more detail about return format, error conditions, or performance characteristics for a more complete picture.

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

Parameters3/5

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

The input schema has 100% description coverage, with the single parameter 'file_path' clearly documented as 'Full path to the file to read.' The description doesn't add any additional parameter semantics beyond what the schema provides, so it meets the baseline expectation when schema coverage is complete.

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?

The description clearly states the specific action ('Read the content') and target resource ('an existing Python code file'), distinguishing it from siblings like append_to_code_file or execute_code_file. It provides a precise verb+resource combination that leaves no ambiguity about the tool's function.

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

Usage Guidelines5/5

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

The description explicitly states when to use this tool ('to verify the current state of a file before appending more content or executing it'), providing clear context for its application. It distinguishes this read operation from potential write or execute operations performed by sibling tools, offering practical guidance on tool selection.

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/bazinga012/mcp_code_executor'

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