1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
package tools
import (
"context"
"encoding/json"
"fmt"
"github.com/opencode-ai/opencode/internal/lsp/discovery/tool"
)
// ConfigureLspServerTool is a tool for configuring LSP servers
type ConfigureLspServerTool struct{}
// NewConfigureLspServerTool creates a new ConfigureLspServerTool
func NewConfigureLspServerTool() *ConfigureLspServerTool {
return &ConfigureLspServerTool{}
}
// Info returns information about the tool
func (t *ConfigureLspServerTool) Info() ToolInfo {
return ToolInfo{
Name: "configureLspServer",
Description: "Searches for an LSP server for the given language",
Parameters: map[string]any{
"language": map[string]any{
"type": "string",
"description": "The language identifier (e.g., \"go\", \"typescript\", \"python\")",
},
},
Required: []string{"language"},
}
}
// Run executes the tool
func (t *ConfigureLspServerTool) Run(ctx context.Context, params ToolCall) (ToolResponse, error) {
result, err := tool.ConfigureLspServer(ctx, json.RawMessage(params.Input))
if err != nil {
return NewTextErrorResponse(err.Error()), nil
}
// Convert the result to JSON
resultJSON, err := json.MarshalIndent(result, "", " ")
if err != nil {
return NewTextErrorResponse(fmt.Sprintf("Failed to marshal result: %v", err)), nil
}
return NewTextResponse(string(resultJSON)), nil
}
|