JetBrains / JetBrains/mcp-server-plugin
Feature Request: Add get_editor_selection tool to expose currently selected text/code
- Dominant language
- Kotlin
- Stars
- 134
- Forks
- 42
- PR merge metrics
- No merged PRs in 30d
Description
## Summary
Add a new MCP tool (e.g. `get_editor_selection` or `get_selected_text`) that returns the currently selected text in the active editor, along with file path, line numbers, and language context.
## Motivation
The Claude Code CLI plugin for JetBrains IDEs already supports live selection context sharing via WebSocket — when a user selects code in the editor, it's automatically injected into the Claude Code CLI session. However, this feature is **not available through the MCP Server**, which means external MCP clients like **Claude Desktop App**, **Cursor**, or any other MCP-compatible tool cannot access the user's current selection.
This creates a significant gap: the MCP Server provides 23+ powerful tools for file operations, search, refactoring, and diagnostics, but has no way to know **what the user is currently looking at or has selected**. Users have to manually copy-paste code snippets or specify file paths and line numbers instead of simply selecting code and asking their AI tool about it.
## Proposed Tool
```json
{
"name": "get_editor_selection",
"description": "Returns the currently selected text in the active editor, along with file path, line range, and language",
"result": {
"filePath": "string",
"selectedText": "string",
"startLine": "number",
"endLine": "number",
"startColumn": "number",
"endColumn": "number",
"language": "string",
"hasSelection": "boolean"
}
}
```
When no text is selected, `hasSelection` would be `false` and optionally the tool could return the current cursor position and/or the line under the cursor.
## Use Cases
- User selects a code block and asks an MCP client "explain this" or "refactor this"
- User selects a function and asks "write tests for this"
- User highlights an error and asks "what's wrong here?"
- Any MCP client can provide IDE-aware code assistance without requiring the user to manually specify context
## Context
- The built-in MCP Server (since IntelliJ 2025.2) already has deep IDE integration
- The Claude Code JetBrains plugin already implements selection sharing via WebSocket (proving the IDE API supports it)
- This would bring MCP clients to feature parity with the Claude Code CLI integration
- Other useful additions could include `get_cursor_context` (current file + cursor position) and `get_diagnostics_at_cursor`
## Environment
- WebStorm 2025.3
- MCP Server Plugin (built-in)
- Claude Desktop App as MCP client
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.