RobutlerRobutler
Skills

LSP Skill

Language Server Protocol skill providing code intelligence via Microsoft multilspy.

Overview

The LSP skill provides code intelligence capabilities:

  • Go to Definition - Find where a symbol is defined
  • Find References - Find all usages of a symbol
  • Code Completions - Get contextual completions at cursor
  • Hover Information - Get type info and documentation
  • Document Symbols - List all symbols in a file

Supported Languages

LanguageExtensionsNotes
Python.py, .pyw, .pyiPyright/Pylance
TypeScript.ts, .tsxtsserver
JavaScript.js, .jsx, .mjs, .cjstsserver
Java.javaEclipse JDT
Rust.rsrust-analyzer
Go.gogopls
C#.csOmniSharp
Dart.dartDart Analysis Server
Ruby.rbSolargraph
Kotlin.kt, .ktskotlin-language-server

Language is automatically detected from file extension.

Configuration

skills:
  lsp:
    project_root: "."  # Path to project root (default: current directory)

Python API

from webagents.agents.skills.local.lsp import LSPSkill

# Create skill with config
lsp_skill = LSPSkill({"project_root": "/path/to/project"})

# Add to agent
agent = BaseAgent(
    name="code-agent",
    skills={"lsp": lsp_skill},
)

Tools

goto_definition

Find the definition of a symbol at a given position.

result = await skill.goto_definition(
    file_path="src/main.py",
    line=10,        # 1-indexed
    column=5,       # 1-indexed
    language=None   # auto-detected from extension
)
# Returns: {"found": True, "file": "src/utils.py", "line": 5, "column": 1}

find_references

Find all references to a symbol.

result = await skill.find_references(
    file_path="src/main.py",
    line=10,
    column=5,
    include_declaration=True,
    language=None
)
# Returns: {"count": 3, "references": [{"file": "...", "line": ..., "column": ...}]}

get_completions

Get code completions at cursor position.

result = await skill.get_completions(
    file_path="src/main.py",
    line=10,
    column=5,
    language=None
)
# Returns: {
#   "count": 15, 
#   "completions": [
#     {"label": "append", "kind": 2, "detail": "(item) -> None", ...}
#   ]
# }

get_hover

Get hover information (type info, docs) for a symbol.

result = await skill.get_hover(
    file_path="src/main.py",
    line=10,
    column=5,
    language=None
)
# Returns: {"found": True, "content": "def greet(name: str) -> str"}

get_document_symbols

Get all symbols defined in a file.

result = await skill.get_document_symbols(
    file_path="src/main.py",
    language=None
)
# Returns: {
#   "count": 5, 
#   "symbols": [
#     {"name": "greet", "kind": "Function", "line": 2, "parent": None},
#     {"name": "name", "kind": "Variable", "line": 3, "parent": "greet"}
#   ]
# }

Slash Commands

CommandDescription
/lspShow LSP status including active servers and supported languages

Example output:

**LSP Status**
Project: /Users/me/myproject
Active servers: python, typescript
Supported: python, typescript, javascript, java, rust, go, csharp, dart, ruby, kotlin

Usage Examples

Agent Chat

User: What function is called at line 45 of main.py?

Agent: [uses get_hover tool]
The function at line 45 is `process_data(items: List[str]) -> Dict[str, int]`
which processes a list of strings and returns a frequency dictionary.

User: Where is that function defined?

Agent: [uses goto_definition tool]
`process_data` is defined at src/utils.py:23

Programmatic Use

# Initialize with project
lsp = LSPSkill({"project_root": "/path/to/project"})
await lsp.initialize(agent)

# Find all usages of a function
refs = await lsp.find_references("src/api.py", 50, 10)
print(f"Found {refs['count']} references")

for ref in refs['references']:
    print(f"  {ref['file']}:{ref['line']}")

# Don't forget to cleanup when done
await lsp.cleanup()

API Notes

Line/Column Indexing

  • API uses 1-indexed positions (line 1 is the first line)
  • Internally converts to 0-indexed for LSP protocol
  • Results are converted back to 1-indexed for display

Lazy Initialization

Language servers are started on first use and cached. This means:

  • No startup delay when skill loads
  • First request for a language may take longer
  • Subsequent requests are fast

Call cleanup() to shut down all servers when done.

Error Handling

ScenarioBehavior
Unsupported extensionRaises ValueError with list of supported extensions
Definition not foundReturns {"found": False, "message": "..."}
No completionsReturns {"count": 0, "completions": []}
Server errorsLogged; may raise exceptions

Symbol Kinds

The get_document_symbols tool returns a kind field with these values:

KindDescription
FileFile
ModuleModule
NamespaceNamespace
PackagePackage
ClassClass
MethodMethod
PropertyProperty
FieldField
ConstructorConstructor
EnumEnum
InterfaceInterface
FunctionFunction
VariableVariable
ConstantConstant
StringString literal
NumberNumber literal
BooleanBoolean literal
ArrayArray
ObjectObject literal
StructStruct
EventEvent
OperatorOperator
TypeParameterType parameter

Dependencies

multilspy>=0.0.15

Install with:

pip install multilspy

Architecture

webagents/agents/skills/local/lsp/
├── __init__.py      # Export LSPSkill
├── skill.py         # LSPSkill class wrapping multilspy
├── languages.py     # Language detection and configuration
└── README.md        # Developer documentation

See Also

On this page