-
Notifications
You must be signed in to change notification settings - Fork 5
Add expandable tool details showing descriptions and input schemas #48
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
d395a1c
Initial plan
Copilot a38ffe1
Add tool descriptions and input schemas to backend API and frontend UI
Copilot ade5a07
Add test for tool details in config API
Copilot 51bdcd9
Address code review feedback: extract constants and improve documenta…
Copilot 9cdff5d
Remove dropdown expand/collapse section for individual tools
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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,110 @@ | ||
| """Test that tool details (description and inputSchema) are included in config API response.""" | ||
|
|
||
| import pytest | ||
| import sys | ||
| import os | ||
|
|
||
| # Ensure backend is on path | ||
| sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))) | ||
|
|
||
| from modules.mcp_tools.client import MCPToolManager | ||
|
|
||
|
|
||
| class FakeTool: | ||
| """Mock tool object for testing.""" | ||
| def __init__(self, name, description="", inputSchema=None): | ||
| self.name = name | ||
| self.description = description | ||
| self.inputSchema = inputSchema or {"type": "object", "properties": {}} | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def mock_mcp_manager(monkeypatch): | ||
| """Create a mock MCP manager with test data.""" | ||
| manager = MCPToolManager() | ||
|
|
||
| # Mock available_tools with detailed tool information | ||
| manager.available_tools = { | ||
| "test_server": { | ||
| "tools": [ | ||
| FakeTool( | ||
| "test_tool", | ||
| "This is a test tool description", | ||
| { | ||
| "type": "object", | ||
| "properties": { | ||
| "arg1": { | ||
| "type": "string", | ||
| "description": "First argument" | ||
| }, | ||
| "arg2": { | ||
| "type": "number", | ||
| "description": "Second argument" | ||
| } | ||
| }, | ||
| "required": ["arg1"] | ||
| } | ||
| ) | ||
| ], | ||
| "config": { | ||
| "description": "Test server", | ||
| "is_exclusive": False, | ||
| "author": "Test Author" | ||
| } | ||
| } | ||
| } | ||
|
|
||
| manager.available_prompts = {} | ||
| return manager | ||
|
|
||
|
|
||
| def test_tools_detailed_includes_description_and_schema(mock_mcp_manager): | ||
| """Test that tools_detailed field contains description and inputSchema.""" | ||
| server_tools = mock_mcp_manager.available_tools["test_server"]["tools"] | ||
| server_config = mock_mcp_manager.available_tools["test_server"]["config"] | ||
|
|
||
| # Simulate what the config endpoint does | ||
| tools_detailed = [] | ||
| for tool in server_tools: | ||
| tool_detail = { | ||
| 'name': tool.name, | ||
| 'description': tool.description or '', | ||
| 'inputSchema': getattr(tool, 'inputSchema', {}) or {} | ||
| } | ||
| tools_detailed.append(tool_detail) | ||
|
|
||
| # Verify the structure | ||
| assert len(tools_detailed) == 1 | ||
| assert tools_detailed[0]['name'] == 'test_tool' | ||
| assert tools_detailed[0]['description'] == 'This is a test tool description' | ||
| assert 'inputSchema' in tools_detailed[0] | ||
| assert 'properties' in tools_detailed[0]['inputSchema'] | ||
| assert 'arg1' in tools_detailed[0]['inputSchema']['properties'] | ||
| assert tools_detailed[0]['inputSchema']['properties']['arg1']['type'] == 'string' | ||
| assert tools_detailed[0]['inputSchema']['properties']['arg1']['description'] == 'First argument' | ||
|
|
||
|
|
||
| def test_canvas_tool_has_detailed_info(): | ||
| """Test that canvas pseudo-tool has detailed information.""" | ||
| canvas_tools_detailed = [{ | ||
| 'name': 'canvas', | ||
| 'description': 'Display final rendered content in a visual canvas panel. Use this for: 1) Complete code (not code discussions), 2) Final reports/documents (not report discussions), 3) Data visualizations, 4) Any polished content that should be viewed separately from the conversation.', | ||
| 'inputSchema': { | ||
| 'type': 'object', | ||
| 'properties': { | ||
| 'content': { | ||
| 'type': 'string', | ||
| 'description': 'The content to display in the canvas. Can be markdown, code, or plain text.' | ||
| } | ||
| }, | ||
| 'required': ['content'] | ||
| } | ||
| }] | ||
|
|
||
| # Verify canvas tool structure | ||
| assert len(canvas_tools_detailed) == 1 | ||
| assert canvas_tools_detailed[0]['name'] == 'canvas' | ||
| assert 'description' in canvas_tools_detailed[0] | ||
| assert len(canvas_tools_detailed[0]['description']) > 0 | ||
| assert 'inputSchema' in canvas_tools_detailed[0] | ||
| assert 'content' in canvas_tools_detailed[0]['inputSchema']['properties'] | ||
Oops, something went wrong.
Oops, something went wrong.
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.
Check notice
Code scanning / CodeQL
Unused local variable Note test
Copilot Autofix
AI 23 days ago
The best way to fix this problem is to simply remove the assignment to
server_configat line 64. Since the assigned value is not used and the assignment itself does not cause any side effects, this removal is safe and will not affect the functionality of the test. The removal should only affect this single line in the code (server_config = ...), and no imports or further changes are needed.