- Notifications
You must be signed in to change notification settings - Fork35
feat: complete MCP tools compliance with VS Code extension specs#57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Open
ThomasK33 wants to merge3 commits intomainChoose a base branch fromfeat/complete-mcp-tools-compliance
base:main
Could not load branches
Branch not found:{{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline, and old review comments may become outdated.
+1,481 −134
Open
Changes fromall commits
Commits
Show all changes
3 commits Select commitHold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
156 changes: 150 additions & 6 deletionsCLAUDE.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
53 changes: 44 additions & 9 deletionslua/claudecode/tools/check_document_dirty.lua
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
102 changes: 102 additions & 0 deletionslua/claudecode/tools/close_all_diff_tabs.lua
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
--- Tool implementation for closing all diff tabs. | ||
local schema = { | ||
description = "Close all diff tabs in the editor", | ||
inputSchema = { | ||
type = "object", | ||
additionalProperties = false, | ||
["$schema"] = "http://json-schema.org/draft-07/schema#", | ||
}, | ||
} | ||
--- Handles the closeAllDiffTabs tool invocation. | ||
-- Closes all diff tabs/windows in the editor. | ||
-- @param _params table The input parameters for the tool (currently unused). | ||
-- @return table MCP-compliant response with content array indicating number of closed tabs. | ||
-- @error table A table with code, message, and data for JSON-RPC error if failed. | ||
local function handler(_params) -- Prefix unused params with underscore | ||
local closed_count = 0 | ||
-- Get all windows | ||
local windows = vim.api.nvim_list_wins() | ||
local windows_to_close = {} -- Use set to avoid duplicates | ||
for _, win in ipairs(windows) do | ||
local buf = vim.api.nvim_win_get_buf(win) | ||
local buftype = vim.api.nvim_buf_get_option(buf, "buftype") | ||
local diff_mode = vim.api.nvim_win_get_option(win, "diff") | ||
local should_close = false | ||
-- Check if this is a diff window | ||
if diff_mode then | ||
should_close = true | ||
end | ||
-- Also check for diff-related buffer names or types | ||
local buf_name = vim.api.nvim_buf_get_name(buf) | ||
if buf_name:match("%.diff$") or buf_name:match("diff://") then | ||
should_close = true | ||
end | ||
-- Check for special diff buffer types | ||
if buftype == "nofile" and buf_name:match("^fugitive://") then | ||
should_close = true | ||
end | ||
-- Add to close set only once (prevents duplicates) | ||
if should_close then | ||
windows_to_close[win] = true | ||
end | ||
end | ||
-- Close the identified diff windows | ||
for win, _ in pairs(windows_to_close) do | ||
if vim.api.nvim_win_is_valid(win) then | ||
local success = pcall(vim.api.nvim_win_close, win, false) | ||
if success then | ||
closed_count = closed_count + 1 | ||
end | ||
end | ||
end | ||
-- Also check for buffers that might be diff-related but not currently in windows | ||
local buffers = vim.api.nvim_list_bufs() | ||
for _, buf in ipairs(buffers) do | ||
if vim.api.nvim_buf_is_loaded(buf) then | ||
local buf_name = vim.api.nvim_buf_get_name(buf) | ||
local buftype = vim.api.nvim_buf_get_option(buf, "buftype") | ||
-- Check for diff-related buffers | ||
if | ||
buf_name:match("%.diff$") | ||
or buf_name:match("diff://") | ||
or (buftype == "nofile" and buf_name:match("^fugitive://")) | ||
then | ||
-- Delete the buffer if it's not in any window | ||
local buf_windows = vim.fn.win_findbuf(buf) | ||
if #buf_windows == 0 then | ||
local success = pcall(vim.api.nvim_buf_delete, buf, { force = true }) | ||
if success then | ||
closed_count = closed_count + 1 | ||
end | ||
end | ||
end | ||
end | ||
end | ||
-- Return MCP-compliant format matching VS Code extension | ||
return { | ||
content = { | ||
{ | ||
type = "text", | ||
text = "CLOSED_" .. closed_count .. "_DIFF_TABS", | ||
}, | ||
}, | ||
} | ||
end | ||
return { | ||
name = "closeAllDiffTabs", | ||
schema = schema, | ||
handler = handler, | ||
} |
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.