Mastra workspaces now support Language Server Protocol (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.
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.
See the LSP inspection docs for full configuration details.
