Browse documentation

get_file_contents

[solution]

Gets text content for a file under the loaded root, with optional line-window limits. Supports files outside the loaded C# project model when they are still inside the loaded root.

Try it locally in the Glider playground

Parameters

NameTypeRequiredDescription
includeRawContentbooleanNoInclude rawContent with exact line endings and the final line terminator. Null means the character limit prevents an exact window. Unreleased parameter. Available in development builds after Glider 11.0.0. Default: false
filePathstringYesFile path to read. Can be absolute or relative to the loaded root. A repository-relative path also resolves, given its complete prefix, such as src/App/Foo.cs. A partial prefix is not resolved, because guessing one could name a different file.
startLinenumberNoOptional 1-based start line. Defaults to 1.
endLinenumberNoOptional 1-based inclusive end line. Defaults to the end of the file.
maxLinesnumberNoMaximum number of lines to return. Use 0 for unlimited. Default is 400. Default: 400
maxCharsnumberNoMaximum characters to return. Use 0 for unlimited. Default is 100000. Default: 100000
pathStylestringNoPath style: 'absolute' (default) or 'relative' (to solution root). Default: "absolute"
responseDetailstringNocompact returns results and actionable state. full adds diagnostic metadata under responseDiagnostics. Default: "compact"

Examples

Replace sample paths and symbol keys with values from your workspace.

Read an entire file

Arguments
{
  "filePath": "/Users/dev/MyProject/Program.cs"
}
Full MCP request
Full MCP request
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "get_file_contents",
    "arguments": {
      "filePath": "/Users/dev/MyProject/Program.cs"
    }
  }
}
Illustrative response
{
  "success": true,
  "filePath": "/Users/dev/MyProject/Program.cs",
  "totalLines": 180,
  "startLine": 40,
  "endLine": 90,
  "lineCount": 51,
  "truncated": false,
  "inWorkspace": true,
  "fileExtension": ".cs",
  "content": "using System;\n\nnamespace MyProject;\n..."
}

Read a bounded line range

Arguments
{
  "filePath": "/Users/dev/MyProject/Program.cs",
  "startLine": 40,
  "endLine": 90
}
Full MCP request
Full MCP request
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "get_file_contents",
    "arguments": {
      "filePath": "/Users/dev/MyProject/Program.cs",
      "startLine": 40,
      "endLine": 90
    }
  }
}

Read using relative paths with limits

Arguments
{
  "filePath": "src/Program.cs",
  "maxLines": 80,
  "maxChars": 12000,
  "pathStyle": "relative"
}
Full MCP request
Full MCP request
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "get_file_contents",
    "arguments": {
      "filePath": "src/Program.cs",
      "maxLines": 80,
      "maxChars": 12000,
      "pathStyle": "relative"
    }
  }
}

Response Notes

Returns bounded text content plus file metadata and workspace inclusion state Results use top-level fields with success. Compact is the default; full adds responseDiagnostics. Both modes retain errors, coverage, partial state, and recovery advice.