Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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 intomain
base:main
Choose a base branch
Loading
fromfeat/complete-mcp-tools-compliance

Conversation

ThomasK33
Copy link
Member

@ThomasK33ThomasK33 commentedJun 20, 2025
edited
Loading

Summary

Implements complete MCP (Model Context Protocol) tools compliance, achieving100% feature parity with Anthropic's official VS Code extension.

Key Achievements

  • All VS Code tools implemented: 12 tools with identical behavior and output formats
  • MCP format compliance: All tools return proper{content: [{type: "text", text: "JSON"}]} structure
  • Quality validation: 325 tests passing (0 failures, 0 errors)
  • Zero linting issues: All code passes luacheck with 0 warnings/errors

New Tools Added

  • getLatestSelection: Get most recent text selection (different from getCurrentSelection)
  • closeAllDiffTabs: Close all diff-related tabs/windows with VS Code-compatible output

Enhanced Tools

  • openFile: Added missing parameters (preview, selectToEndOfLine, makeFrontmost, text selection)
  • getOpenEditors: Restructured to VS Code{tabs: [...]} format with all required fields
  • checkDocumentDirty: Now exposed via MCP with success/failure JSON responses
  • saveDocument: Now exposed via MCP with detailed success information
  • getWorkspaceFolders: Now exposed via MCP with VS Code-compatible structure

Technical Improvements

  • Text Pattern Matching: Full implementation of startText/endText selection in openFile
  • Error Handling: Comprehensive JSON-RPC error responses throughout
  • Test Infrastructure: Custom JSON encoder/decoder supporting nested objects and special keys
  • Documentation: Complete CLAUDE.md rewrite with development guidelines and troubleshooting

Latest Updates (Latest Commit)

  • Fixed closeAllDiffTabs: Eliminated potential duplicate window closing using set-based approach
  • Enhanced Test Coverage: Added comprehensive tests for openFile parameters (makeFrontmost, preview, line/text selection)
  • Updated Documentation: Added endLine parameter mention in CLAUDE.md
  • Improved JSON Handling: Enhanced encoder/decoder with proper escape sequence support
  • Complete Test Suite: All 325 tests now pass with full coverage of MCP tool features

Compatibility

  • Backward compatible: No breaking changes to existing functionality
  • Internal tools preserved: close_tab remains internal-only per Claude Code requirements
  • VS Code alignment: All output formats match official extension exactly

Validation

All changes have been thoroughly tested and validated:

  • Unit Tests: 325+ tests covering all tools and edge cases
  • Integration Tests: End-to-end MCP protocol flow verification
  • Format Tests: VS Code extension compatibility validation
  • Quality Gates: All linting, formatting, and testing requirements passed

…specsComplete implementation of MCP (Model Context Protocol) tool compliance by:- Adding 2 missing tools from VS Code extension- Converting all tool outputs to MCP-compliant format- Exposing internal tools via MCP while preserving existing functionality- Comprehensive test suite updates with robust JSON handling- Updated documentation to reflect 100% VS Code compatibility- **getLatestSelection**: Get most recent text selection (different from getCurrentSelection)- **closeAllDiffTabs**: Close all diff-related tabs/windows with VS Code-compatible output formatAll tools now return MCP-compliant format: `{content: [{type: "text", text: "JSON-stringified-data"}]}`- **checkDocumentDirty**: Added schema for MCP exposure, success/failure JSON responses- **saveDocument**: Added schema for MCP exposure, detailed success information- **getWorkspaceFolders**: Added schema for MCP exposure, VS Code-compatible structure- **getOpenEditors**: Restructured from `{editors: [...]}` to `{tabs: [...]}` with all VS Code fields- **getCurrentSelection**: Enhanced with proper fallback behavior and MCP format- **openFile**: Added missing parameters (preview, selectToEndOfLine, makeFrontmost, text selection)- **closeTab**: Updated format while keeping internal-only (per Claude Code requirement)- **Text Selection in openFile**: Full implementation of startText/endText pattern matching- **Conditional Output**: openFile returns simple vs detailed responses based on makeFrontmost- **Language Detection**: getOpenEditors includes proper languageId field mapping- **Error Handling**: Comprehensive JSON-RPC error responses throughout- **Robust JSON encoder/decoder**: Custom implementation supporting nested objects and special keys- **Comprehensive test coverage**: All new tools with unit tests- **Updated test expectations**: All existing tests adapted to MCP format- **Format validation**: Tests verify exact VS Code extension compatibility- **CLAUDE.md**: Complete rewrite of MCP tools section with 100% compliance status- **Development Guidelines**: Added MCP tool development patterns and troubleshooting- **Quality Standards**: Updated to reflect 320+ tests with 100% success rate- **Protocol Compliance**: New section documenting VS Code extension feature parity- **Backward compatibility**: No breaking changes to existing API- **VS Code alignment**: Output formats match official VS Code extension exactly- **Internal tools preserved**: close_tab remains internal as required by Claude Code architecture- ✅ 320 tests passing (0 failures, 0 errors)- ✅ All linting checks passing (0 warnings, 0 errors)- ✅ Full MCP protocol compliance- ✅ VS Code extension feature parity achievedChange-Id: Ic1bd33aadb7fa45d64d4aba208acf37b2c9779cbSigned-off-by: Thomas Kosiewski <tk@coder.com>
@ThomasK33ThomasK33 requested a review fromCopilotJune 20, 2025 17:24
Copilot

This comment was marked as outdated.

- Fix closeAllDiffTabs potential duplicate window closing by using set-based approach instead of array- Add comprehensive test coverage for openFile parameters (makeFrontmost, preview mode, line/text selection)- Update CLAUDE.md documentation to mention endLine parameter for openFile tool- Enhance JSON encoder/decoder in test suite with proper escape sequence handling- Add missing vim API mocks for complex openFile functionality testingAll 325 tests now pass with complete coverage of new MCP tool features.Change-Id: I15bceb2bb44552205ea63c5ef1cb83722f7b5893Signed-off-by: Thomas Kosiewski <tk@coder.com>
@ThomasK33ThomasK33 requested a review fromCopilotJune 20, 2025 17:50
Copilot

This comment was marked as outdated.

Address Copilot review comment: when searching for endText pattern,line_idx is already the correct 1-based index for the lines array,so accessing lines[line_idx + 1] was incorrect.Changed to lines[line_idx] to access the current line directly.Change-Id: I05853ff183ef8f3e5df2863d2184a0cb58cb7e65Signed-off-by: Thomas Kosiewski <tk@coder.com>
@ThomasK33ThomasK33 requested a review fromCopilotJune 20, 2025 21:41
Copy link

@CopilotCopilotAI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Pull Request Overview

This PR updates all MCP tools to return VS Code extension–compatible JSON structures and adjusts tests and documentation accordingly.

  • Wrapped tool handler returns in{ content: [{ type = "text", text = JSON }] } format
  • Revised tests to assert onresult.content[...] and JSON-parse the embedded text
  • Added JSON encode/decode helpers and updated CLAUDE.md with full compliance and new tool registrations

Reviewed Changes

Copilot reviewed 21 out of 21 changed files in this pull request and generated 2 comments.

Show a summary per file
FileDescription
tests/unit/tools/*_spec.luaUpdated assertions to useresult.content[...] and JSON-decode
tests/busted_setup.luaAdded_G.json_encode/_G.json_decode helpers for test JSON ops
lua/claudecode/tools/*.luaWrapped returns in MCP-compliantcontent arrays and added schemas
lua/claudecode/tools/init.luaRegistered new tools (getLatestSelection,closeAllDiffTabs)
CLAUDE.mdDocumented full MCP compliance and tool behaviors

end)
_G.vim.api.nvim_win_set_cursor = spy.new(function(win, pos)
-- Mock cursor setting
end)
end)

after_each(function()
Copy link
Preview

CopilotAIJun 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Theafter_each hook should clear all mocks introduced inbefore_each, includingvim.json.encode,vim.api.nvim_get_current_buf,vim.api.nvim_buf_get_name,vim.api.nvim_buf_line_count,vim.api.nvim_buf_set_mark,vim.api.nvim_buf_get_lines, andvim.api.nvim_win_set_cursor, to avoid leakage between tests.

Copilot uses AI. Check for mistakes.

@@ -42,6 +48,7 @@ describe("Tool: save_document", function()
_G.vim.api.nvim_buf_call = nil
_G.vim.cmd = nil
_G.vim.cmd_history = nil
_G.vim.json.encode = nil
Copy link
Preview

CopilotAIJun 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Also reset the overriddenvim.fn.bufnr spy in thisafter_each to restore the default stub and prevent interference with other tests.

Copilot uses AI. Check for mistakes.

@szihs
Copy link

Not sure, but I see only 10 tools when runningclaude_interactive.sh
These are not listed.

  - close_tab  - executeCode

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

Copilot code reviewCopilotCopilot left review comments

At least 1 approving review is required to merge this pull request.

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@ThomasK33@szihs

[8]ページ先頭

©2009-2025 Movatter.jp