Skip to main content
GET
/
resources
/
files
List Files
curl --request GET \
  --url https://api.example.com/resources/files
{
  "error": {
    "code": "WORKSPACE_NOT_FOUND",
    "message": "Workspace directory does not exist",
    "details": {
      "workspaceRoot": "/invalid/path"
    }
  }
}

Overview

The list-files resource returns a comprehensive list of all Python files in your workspace, including metadata about each file.

Resource URI

pylance://workspace/files

Request

uri
string
required
Resource URI: pylance://workspace/files
filter
string
Optional glob pattern to filter files (e.g., **/models/*.py)
includeTests
boolean
default:"true"
Include test files in the results
excludePatterns
array
Array of glob patterns to exclude (e.g., ["**/__pycache__/**", "**/node_modules/**"])

Response

files
array
Array of file objects in the workspace
totalCount
number
Total number of Python files
workspaceRoot
string
Absolute path to workspace root

Example Request

curl -X POST https://api.pylancemcp.dev/v1/resources/read \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "uri": "pylance://workspace/files",
    "params": {
      "filter": "src/**/*.py",
      "includeTests": false
    }
  }'

Example Response

{
  "files": [
    {
      "path": "/workspace/src/main.py",
      "relativePath": "src/main.py",
      "size": 2048,
      "lastModified": "2025-12-17T10:30:00Z",
      "isTest": false,
      "language": "python"
    },
    {
      "path": "/workspace/src/models/user.py",
      "relativePath": "src/models/user.py",
      "size": 4096,
      "lastModified": "2025-12-16T15:20:00Z",
      "isTest": false,
      "language": "python"
    },
    {
      "path": "/workspace/src/utils/helpers.py",
      "relativePath": "src/utils/helpers.py",
      "size": 1536,
      "lastModified": "2025-12-15T09:45:00Z",
      "isTest": false,
      "language": "python"
    }
  ],
  "totalCount": 3,
  "workspaceRoot": "/workspace"
}

Filter Patterns

Use glob patterns to filter results:
PatternDescription
**/*.pyAll Python files recursively
src/**/*.pyAll Python files in src/ directory
**/test_*.pyAll test files starting with test_
models/*.pyPython files directly in models/
!**/__pycache__/**Exclude __pycache__ directories

Common Use Cases

Get All Source Files

files = client.read_resource(
    uri="pylance://workspace/files",
    filter="src/**/*.py",
    excludePatterns=["**/test_*.py", "**/*_test.py"]
)

Find All Test Files

tests = client.read_resource(
    uri="pylance://workspace/files",
    filter="**/test_*.py"
)

Get Files by Directory

models = client.read_resource(
    uri="pylance://workspace/files",
    filter="src/models/**/*.py"
)

Performance Considerations

File listing is cached for 5 minutes. Changes to the workspace trigger automatic cache invalidation.
Large workspaces (>10,000 files) may experience slower response times. Consider using more specific filter patterns.

Optimization Tips

Use specific filter patterns to reduce result size
Exclude unnecessary directories (__pycache__, .venv, node_modules)
Cache results on the client side when possible
Use includeTests=false if test files aren’t needed

Error Responses

{
  "error": {
    "code": "WORKSPACE_NOT_FOUND",
    "message": "Workspace directory does not exist",
    "details": {
      "workspaceRoot": "/invalid/path"
    }
  }
}

Rate Limits

TierRequests/DayRequests/Hour
Free10020
Hobby5,000500
Pro50,0005,000
EnterpriseUnlimitedUnlimited