@@ -4,6 +4,8 @@ import (
44 "context"
55 "encoding/json"
66 "fmt"
7+ "os"
8+ "path/filepath"
79
810 tea "charm.land/bubbletea/v2"
911 "github.com/xonecas/symb/internal/mcp"
@@ -11,22 +13,27 @@ import (
1113
1214 // ShowArgs represents arguments for the Show tool.
1315 type ShowArgs struct {
14- Content string `json:"content"`
16+ Content string `json:"content,omitempty"`
1517 Language string `json:"language,omitempty"`
18+ FilePath string `json:"file_path,omitempty"`
1619 }
1720
1821 // NewShowTool creates the Show tool definition.
1922 func NewShowTool() mcp.Tool {
2023 return mcp.Tool{
2124 Name: "Show",
22- Description: `Displays content in the user's editor pane with syntax highlighting. Use this to show code snippets, diffs, generated code, or any text the user should see. Does NOT read or write files.`,
25+ Description: `Displays content in the user's editor pane with syntax highlighting. Provide either "content" or "file_path", not both. Use file_path to show a file from disk (saves tokens). Use content for generated snippets or diffs.`,
2326 InputSchema: json.RawMessage(`{
2427 "type": "object",
2528 "properties": {
26- "content": {"type": "string", "description": "The content to display in the editor pane"},
27- "language": {"type": "string", "description": "Language for syntax highlighting (e.g. go, python, diff, markdown). Defaults to text."}
29+ "content": {"type": "string", "description": "The content to display. Mutually exclusive with file_path."},
30+ "language": {"type": "string", "description": "Language for syntax highlighting (e.g. go, python, diff, markdown). Defaults to auto-detect for file_path, text for content."},
31+ "file_path": {"type": "string", "description": "Path to a file to display. Reads from disk. Enables git gutter markers and LSP diagnostics. Mutually exclusive with content."}
2832 },
29- "required": ["content"]
33+ "oneOf": [
34+ {"required": ["content"]},
35+ {"required": ["file_path"]}
36+ ]
3037 }`),
3138 }
3239 }
@@ -56,22 +63,48 @@ func (h *ShowHandler) Handle(_ context.Context, arguments json.RawMessage) (*mcp
5663 }, nil
5764 }
5865
59- if args.Content == "" {
66+ if args.Content != "" && args.FilePath != "" {
6067 return &mcp.ToolResult{
61- Content: []mcp.ContentBlock{{Type: "text", Text: "Content cannot be empty"}},
68+ Content: []mcp.ContentBlock{{Type: "text", Text: "Provide either content or file_path, not both"}},
69+ IsError: true,
70+ }, nil
71+ }
72+ if args.Content == "" && args.FilePath == "" {
73+ return &mcp.ToolResult{
74+ Content: []mcp.ContentBlock{{Type: "text", Text: "Provide either content or file_path"}},
6275 IsError: true,
6376 }, nil
6477 }
6578
79+ content := args.Content
6680 language := args.Language
81+ var absPath string
82+
83+ if args.FilePath != "" {
84+ absPath, _ = filepath.Abs(args.FilePath)
85+ data, err := os.ReadFile(absPath)
86+ if err != nil {
87+ return &mcp.ToolResult{
88+ Content: []mcp.ContentBlock{{Type: "text", Text: fmt.Sprintf("Cannot read file: %v", err)}},
89+ IsError: true,
90+ }, nil
91+ }
92+ content = string(data)
93+ if language == "" {
94+ language = DetectLanguage(args.FilePath)
95+ }
96+ }
97+
6798 if language == "" {
6899 language = "text"
69100 }
70101
71102 if h.program != nil {
72103 h.program.Send(ShowMsg{
73- Content: args.Content,
104+ Content: content,
74105 Language: language,
106+ FilePath: args.FilePath,
107+ AbsPath: absPath,
75108 })
76109 }