MCPcopy Create free account
hub / github.com/ChangeYourWay/Fenrir-CodeAuditTool / ReadFile

Method ReadFile

application/server/project.go:121–145  ·  view source on GitHub ↗
(ctx context.Context, request mcp.CallToolRequest)

Source from the content-addressed store, hash-verified

119}
120
121func (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
147func (ps *ProjectService) LogCall(name, arg string) {
148 log.Printf("Call [%s ] - %s", name, arg)

Callers 5

LoadConfigFunction · 0.80
loadPromptFunction · 0.80
ParseFileMethod · 0.80
LoadASTIndexMethod · 0.80
loadPromptFunction · 0.80

Calls 1

LogCallMethod · 0.95

Tested by

no test coverage detected