@@ -1,4 +1,4 @@
1-package mcp
1+package mcp_tools
22
33 import (
44 "context"
@@ -9,6 +9,7 @@ import (
99 "strings"
1010
1111 tea "github.com/charmbracelet/bubbletea"
12+ "github.com/xonecas/symb/internal/mcp"
1213 )
1314
1415 // OpenForUserArgs represents arguments for Open tool.
@@ -26,7 +27,7 @@ type OpenForUserMsg struct {
2627 }
2728
2829 // NewOpenForUserTool creates the Open tool definition.
29-func NewOpenForUserTool() Tool {
30+func NewOpenForUserTool() mcp.Tool {
3031 schema := map[string]interface{}{
3132 "type": "object",
3233 "properties": map[string]interface{}{
@@ -48,7 +49,7 @@ func NewOpenForUserTool() Tool {
4849
4950 schemaJSON, _ := json.Marshal(schema)
5051
51- return Tool{
52+ return mcp.Tool{
5253 Name: "Open",
5354 Description: "Opens a file (or file range) in the user's editor with correct syntax highlighting. If start/end are provided, only that line range is shown.",
5455 InputSchema: schemaJSON,
@@ -57,19 +58,19 @@ func NewOpenForUserTool() Tool {
5758
5859 // MakeOpenForUserHandler creates a handler for Open tool.
5960 // programPtr should point to the tea.Program instance (can be set after creation).
60-func MakeOpenForUserHandler(programPtr **tea.Program) ToolHandler {
61- return func(ctx context.Context, arguments json.RawMessage) (*ToolResult, error) {
61+func MakeOpenForUserHandler(programPtr **tea.Program) mcp.ToolHandler {
62+ return func(ctx context.Context, arguments json.RawMessage) (*mcp.ToolResult, error) {
6263 var args OpenForUserArgs
6364 if err := json.Unmarshal(arguments, &args); err != nil {
64- return &ToolResult{
65- Content: []ContentBlock{{Type: "text", Text: fmt.Sprintf("Invalid arguments: %v", err)}},
65+ return &mcp.ToolResult{
66+ Content: []mcp.ContentBlock{{Type: "text", Text: fmt.Sprintf("Invalid arguments: %v", err)}},
6667 IsError: true,
6768 }, nil
6869 }
6970
7071 if args.File == "" {
71- return &ToolResult{
72- Content: []ContentBlock{{Type: "text", Text: "File path cannot be empty"}},
72+ return &mcp.ToolResult{
73+ Content: []mcp.ContentBlock{{Type: "text", Text: "File path cannot be empty"}},
7374 IsError: true,
7475 }, nil
7576 }
@@ -77,8 +78,8 @@ func MakeOpenForUserHandler(programPtr **tea.Program) ToolHandler {
7778 // Security: Convert to absolute path and validate
7879 absPath, err := filepath.Abs(args.File)
7980 if err != nil {
80- return &ToolResult{
81- Content: []ContentBlock{{Type: "text", Text: fmt.Sprintf("Invalid file path: %v", err)}},
81+ return &mcp.ToolResult{
82+ Content: []mcp.ContentBlock{{Type: "text", Text: fmt.Sprintf("Invalid file path: %v", err)}},
8283 IsError: true,
8384 }, nil
8485 }
@@ -86,8 +87,8 @@ func MakeOpenForUserHandler(programPtr **tea.Program) ToolHandler {
8687 // Get current working directory for validation
8788 workingDir, err := os.Getwd()
8889 if err != nil {
89- return &ToolResult{
90- Content: []ContentBlock{{Type: "text", Text: fmt.Sprintf("Failed to get working directory: %v", err)}},
90+ return &mcp.ToolResult{
91+ Content: []mcp.ContentBlock{{Type: "text", Text: fmt.Sprintf("Failed to get working directory: %v", err)}},
9192 IsError: true,
9293 }, nil
9394 }
@@ -95,8 +96,8 @@ func MakeOpenForUserHandler(programPtr **tea.Program) ToolHandler {
9596 // Security: Prevent path traversal - only allow files within or below working directory
9697 relPath, err := filepath.Rel(workingDir, absPath)
9798 if err != nil || strings.HasPrefix(relPath, "..") || filepath.IsAbs(relPath) {
98- return &ToolResult{
99- Content: []ContentBlock{{Type: "text", Text: "Access denied: path outside working directory"}},
99+ return &mcp.ToolResult{
100+ Content: []mcp.ContentBlock{{Type: "text", Text: "Access denied: path outside working directory"}},
100101 IsError: true,
101102 }, nil
102103 }
@@ -104,8 +105,8 @@ func MakeOpenForUserHandler(programPtr **tea.Program) ToolHandler {
104105 // Read file content
105106 content, err := os.ReadFile(absPath)
106107 if err != nil {
107- return &ToolResult{
108- Content: []ContentBlock{{Type: "text", Text: fmt.Sprintf("Failed to read file: %v", err)}},
108+ return &mcp.ToolResult{
109+ Content: []mcp.ContentBlock{{Type: "text", Text: fmt.Sprintf("Failed to read file: %v", err)}},
109110 IsError: true,
110111 }, nil
111112 }
@@ -125,8 +126,8 @@ func MakeOpenForUserHandler(programPtr **tea.Program) ToolHandler {
125126
126127 // Validate start is in range
127128 if start < 1 || start > len(lines) {
128- return &ToolResult{
129- Content: []ContentBlock{{Type: "text", Text: fmt.Sprintf("Start line %d out of range (file has %d lines)", start, len(lines))}},
129+ return &mcp.ToolResult{
130+ Content: []mcp.ContentBlock{{Type: "text", Text: fmt.Sprintf("Start line %d out of range (file has %d lines)", start, len(lines))}},
130131 IsError: true,
131132 }, nil
132133 }
@@ -138,8 +139,8 @@ func MakeOpenForUserHandler(programPtr **tea.Program) ToolHandler {
138139
139140 // Validate range
140141 if start > end {
141- return &ToolResult{
142- Content: []ContentBlock{{Type: "text", Text: fmt.Sprintf("Invalid range: start (%d) > end (%d)", start, end)}},
142+ return &mcp.ToolResult{
143+ Content: []mcp.ContentBlock{{Type: "text", Text: fmt.Sprintf("Invalid range: start (%d) > end (%d)", start, end)}},
143144 IsError: true,
144145 }, nil
145146 }
@@ -162,8 +163,8 @@ func MakeOpenForUserHandler(programPtr **tea.Program) ToolHandler {
162163 })
163164 }
164165
165- return &ToolResult{
166- Content: []ContentBlock{{Type: "text", Text: fmt.Sprintf("Opened %s in editor", args.File)}},
166+ return &mcp.ToolResult{
167+ Content: []mcp.ContentBlock{{Type: "text", Text: fmt.Sprintf("Opened %s in editor", args.File)}},
167168 IsError: false,
168169 }, nil
169170 }