(ctx context.Context, request mcp.CallToolRequest)
| 119 | } |
| 120 | |
| 121 | func (ps *ProjectService) ReadFile(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) { |
| 122 | var path string |
| 123 | |
| 124 | if args, ok := request.Params.Arguments.(map[string]any); ok { |
| 125 | path = args["path"].(string) |
| 126 | } |
| 127 | basePath := ps.config.CodeAudit.RepositoryPath |
| 128 | absPath := filepath.Join(basePath, path) |
| 129 | data, err := os.ReadFile(absPath) |
| 130 | ps.LogCall("readFile", absPath) |
| 131 | if err != nil { |
| 132 | return nil, err |
| 133 | } |
| 134 | if len(data) > 60000 { |
| 135 | return nil, fmt.Errorf("file is too large") |
| 136 | } |
| 137 | return &mcp.CallToolResult{ |
| 138 | Content: []mcp.Content{ |
| 139 | &mcp.TextContent{ |
| 140 | Type: "text", |
| 141 | Text: string(data), |
| 142 | }, |
| 143 | }, |
| 144 | }, nil |
| 145 | } |
| 146 | |
| 147 | func (ps *ProjectService) LogCall(name, arg string) { |
| 148 | log.Printf("Call [%s ] - %s", name, arg) |
no test coverage detected