LSP Inspection for Mastra Workspaces
Give agents semantic understanding of your codebase.
Paul Scanlon · Apr 27, 2026 · 1 min read
Mastra workspaces now support [Language Server Protocol](/content/docs/workspace/lsp "Visit https://mastra.ai/docs/workspace/lsp"/index.html) (LSP) inspection. This enables agents to query language servers for type information, definitions, and implementation details instead of relying on raw text analysis.
When enabled, a new lsp_inspect tool is exposed to the agent. This allows it to navigate symbols and understand code structure with language-specific accuracy.
LSP inspection does not change how files are read or searched. It only adds an additional tool for deeper inspection when working with supported languages.
Your browser does not support the video tag.
Get started!
Create a workspace with lsp: true and assign it to an agent (requires @mastra/core@1.8.0 or later):
1import { Agent } from "@mastra/core/agent";
2import { Workspace, LocalFilesystem, LocalSandbox } from "@mastra/core/workspace";
3
4const workspace = new Workspace({
5 filesystem: new LocalFilesystem({ basePath: "./workspace" }),
6 sandbox: new LocalSandbox({ workingDirectory: "./workspace" }),
7 lsp: true
8});
9
10export const lspAgent = new Agent({
11 id: "lsp-agent",
12 name: "LSP Agent",
13 model: "anthropic/claude-opus-4-6",
14 instructions: "You are a code review assistant. Use workspace tools to read and inspect code.",
15 workspace
16});
TypeScript, JavaScript, Python, Go, and Rust are supported by default. Other languages require registering a [custom language server](/content/docs/workspace/lsp#custom-language-servers "Visit https://mastra.ai/docs/workspace/lsp#custom-language-servers"/index.html).
See the [LSP inspection](/content/docs/workspace/lsp "Visit https://mastra.ai/docs/workspace/lsp"/index.html) docs for full configuration details.