read_file
Read file contents from specified paths to access text, configuration files, or document data for Windows automation workflows.
Instructions
读取文件内容
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | 文件路径 |
Input Schema (JSON Schema)
{
"properties": {
"path": {
"description": "文件路径",
"type": "string"
}
},
"required": [
"path"
],
"type": "object"
}
Implementation Reference
- src/tools/filesystem.js:138-145 (handler)The main handler function that implements the read_file tool logic by reading the file content using fs.promises.readFile and returning structured success/error response.async readFile(filePath) { try { const content = await fs.readFile(filePath, 'utf-8'); return { success: true, content, path: filePath }; } catch (error) { return { success: false, error: error.message }; } }
- src/tools/filesystem.js:14-24 (schema)Input schema definition for the read_file tool, requiring a 'path' string parameter.{ name: 'read_file', description: '读取文件内容', inputSchema: { type: 'object', properties: { path: { type: 'string', description: '文件路径' }, }, required: ['path'], }, },
- src/tools/filesystem.js:117-118 (registration)Dispatch/registration of the read_file tool within the executeTool method's switch statement, calling the handler.case 'read_file': return await this.readFile(args.path);
- src/tools/filesystem.js:109-113 (registration)Tool capability check that includes 'read_file' for routing from the main server handler.canHandle(toolName) { const tools = ['read_file', 'write_file', 'list_directory', 'create_directory', 'delete_file', 'copy_file', 'move_file', 'search_files']; return tools.includes(toolName); }
- src/server.js:97-102 (registration)Top-level tool dispatch logic in the MCP server that routes read_file calls to FileSystemTools based on canHandle.for (const [category, toolModule] of Object.entries(this.tools)) { if (toolModule.canHandle(name)) { result = await toolModule.executeTool(name, args); break; } }