-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.go
More file actions
63 lines (55 loc) · 1.92 KB
/
Copy pathserver.go
File metadata and controls
63 lines (55 loc) · 1.92 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package main
import (
"github.com/mark3labs/mcp-go/mcp"
"github.com/mark3labs/mcp-go/server"
)
// NewMCPServer creates a configured MCP server with all tools registered.
func NewMCPServer(version string, client *SandboxClient) *server.MCPServer {
s := server.NewMCPServer(
"sandboxapi",
version,
server.WithToolCapabilities(true),
)
tools := &ToolHandlers{client: client}
s.AddTool(executeCodeTool(), tools.ExecuteCode)
s.AddTool(executeBatchTool(), tools.ExecuteBatch)
s.AddTool(listLanguagesTool(), tools.ListLanguages)
return s
}
// executeCodeTool defines the execute_code tool schema.
func executeCodeTool() mcp.Tool {
return mcp.NewTool("execute_code",
mcp.WithDescription("Execute code in a sandboxed container. Supports Python, JavaScript, TypeScript, Bash, Java, C++, C, and Go."),
mcp.WithString("language",
mcp.Required(),
mcp.Description("Programming language to execute"),
mcp.Enum("python3", "javascript", "typescript", "bash", "java", "cpp", "c", "go"),
),
mcp.WithString("code",
mcp.Required(),
mcp.Description("Source code to execute"),
),
mcp.WithNumber("timeout",
mcp.Description("Execution timeout in seconds (default 10, max 300)"),
),
mcp.WithString("stdin",
mcp.Description("Standard input to pass to the program"),
),
)
}
// executeBatchTool defines the execute_batch tool schema.
func executeBatchTool() mcp.Tool {
return mcp.NewTool("execute_batch",
mcp.WithDescription("Execute multiple code snippets in sandboxed containers. Each execution runs independently."),
mcp.WithArray("executions",
mcp.Required(),
mcp.Description("Array of execution requests, each with language, code, and optional timeout/stdin"),
),
)
}
// listLanguagesTool defines the list_languages tool schema.
func listLanguagesTool() mcp.Tool {
return mcp.NewTool("list_languages",
mcp.WithDescription("List all supported programming languages with their versions and examples"),
)
}