Skip to main content
Glama
SobieskiCodes

MCP-Claude Code Bridge

read_file

Read file contents to access code, data, or configuration within Claude Code Bridge for debugging, analysis, or task execution.

Instructions

Read contents of a file

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
file_pathYesPath to the file to read

Implementation Reference

  • The readFile method that implements the tool logic - reads a file from the working directory and returns its contents with formatting
    async readFile(filePath) {
      try {
        const fullPath = path.join(this.workingDir, filePath);
        const content = await fs.readFile(fullPath, 'utf8');
        
        return {
          content: [
            {
              type: "text",
              text: `Contents of ${filePath}:\n\n\`\`\`\n${content}\n\`\`\``
            }
          ]
        };
      } catch (error) {
        return {
          content: [
            {
              type: "text",
              text: `Error reading file: ${error.message}`
            }
          ]
        };
      }
    }
  • Tool schema definition for read_file - defines the name, description, and inputSchema with file_path parameter
    {
      name: "read_file",
      description: "Read contents of a file",
      inputSchema: {
        type: "object",
        properties: {
          file_path: {
            type: "string",
            description: "Path to the file to read"
          }
        },
        required: ["file_path"]
      }
    },
  • server.js:144-145 (registration)
    Tool routing in CallToolRequestSchema handler - routes 'read_file' requests to the readFile method
    case 'read_file':
      return await this.readFile(args.file_path);

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/SobieskiCodes/claude-desktop-mcp-to-claude-agent'

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