| name | lsp-generate |
| description | Trigger language server code generation — implement interface stubs, generate test skeletons, add missing methods, generate mock types. Uses suggest_fixes to surface generator options and execute_command to run them. |
| argument-hint | [file-path:line:col] [generation-intent] |
| user-invocable | true |
| allowed-tools | mcp__lsp__suggest_fixes mcp__lsp__execute_command mcp__lsp__apply_edit mcp__lsp__format_document mcp__lsp__get_diagnostics mcp__lsp__open_document mcp__lsp__get_server_capabilities mcp__lsp__go_to_symbol |
| license | MIT |
| compatibility | Requires the agent-lsp MCP server (github.com/blackwell-systems/agent-lsp) |
| metadata | {"required-capabilities":"codeActionProvider","optional-capabilities":"workspaceSymbolProvider documentFormattingProvider"} |
Requires the agent-lsp MCP server.
lsp-generate
lsp-generate creates NEW code that does not yet exist in the file — stubs,
mocks, implementations of interfaces, test functions. It is distinct from
lsp-extract-function, which restructures code that already exists. Use
lsp-generate when you want the language server to write something new; use
lsp-extract-function when you want to reorganize existing code.
Input
file_path: absolute path to the target file
line, column (or position_pattern): position in the file where
generation is triggered (e.g., the line with the unimplemented interface,
the missing method error, the type declaration)
intent: description of what to generate (e.g., "implement io.Reader",
"generate test skeleton", "add missing methods", "generate mock for Handler")
Prerequisites
LSP must be running for the target workspace. If not yet initialized, call
mcp__lsp__start_lsp with the workspace root before proceeding.
Auto-init note: agent-lsp supports workspace auto-inference from file paths.
Explicit start_lsp is only needed when switching workspace roots.
Workflow
Step 1 — Open document and locate position
Call mcp__lsp__open_document for the target file:
mcp__lsp__open_document(file_path: "/abs/path/to/file.go", language_id: "go")
If using position_pattern, use the @@ marker convention from
references/patterns.md to identify the exact cursor position. For example:
"position_pattern": "var _ io.Reade@@r = (*MyType)(nil)"
Step 2 — Get code actions at target position
mcp__lsp__suggest_fixes({
"file_path": "...",
"start_line": N,
"start_column": C,
"end_line": N,
"end_column": C
})
Filter for generator actions:
- Kind
"quickfix" with titles matching the intent (e.g., "Implement
interface", "Generate", "Add stub", "Create test")
- Kind
"source" for source-level generation
If no matching action is found, report "No generator action available at this
position for the given intent" and proceed to the Fallback section below.