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; }

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