Skip to content

Commit 8b02eeb

Browse files
committed
feat(wasm):add wasm modules development and load
Signed-off-by: gitsrc <34047788+gitsrc@users.noreply.github.com>
1 parent d8dc1eb commit 8b02eeb

File tree

2 files changed

+14
-16
lines changed

2 files changed

+14
-16
lines changed

config/mcp_manifest.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ modules:
4141
description: "Greeting message"
4242

4343
- name: "data_validation"
44-
wasm_path: "file://wasm-examples/data-validation/validate.wasm2"
44+
wasm_path: "file://wasm-examples/data-validation/validate.wasm"
4545
tools:
4646
- name: "validate_data"
4747
description: "Validate a JSON string to ensure it contains a 'signature' key"

core/mcp/mcp.go

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@ import (
1919

2020
// MCPServer represents the core MCP server implementation
2121
type MCPServer struct {
22-
server *server.MCPServer
23-
config *Config
22+
server *server.MCPServer
23+
config *Config
24+
wasmEngine *WASMEngine
25+
registeredTools []string
2426
}
2527

2628
// Config holds MCP server configuration
@@ -135,6 +137,7 @@ func NewMCPServer(config *Config) *MCPServer {
135137

136138
// Register WASM module tools from config
137139
log.Printf("Registering %d WASM modules from config", len(config.Modules))
140+
registeredTools := []string{}
138141
for _, module := range config.Modules {
139142
log.Printf("Processing module: %s (WASM path: %s)", module.Name, module.WASMPath)
140143
log.Printf("Loading module with %d tools", len(module.Tools))
@@ -149,12 +152,17 @@ func NewMCPServer(config *Config) *MCPServer {
149152
log.Printf("Failed to register tools from WASM module %s: %v", module.WASMPath, err)
150153
} else {
151154
log.Printf("Successfully registered %d tools for module: %s", len(module.Tools), module.Name)
155+
for _, tool := range module.Tools {
156+
registeredTools = append(registeredTools, tool.Name)
157+
}
152158
}
153159
}
154160

155161
return &MCPServer{
156-
server: mcpServer,
157-
config: config,
162+
server: mcpServer,
163+
config: config,
164+
wasmEngine: wasmEngine,
165+
registeredTools: registeredTools,
158166
}
159167
}
160168

@@ -186,19 +194,9 @@ func (s *MCPServer) Start() error {
186194
return
187195
}
188196

189-
// Get all registered tools
190-
toolNames := []string{}
191-
192-
// Manually track tools from our config
193-
for _, module := range s.config.Modules {
194-
for _, tool := range module.Tools {
195-
toolNames = append(toolNames, tool.Name)
196-
}
197-
}
198-
199197
w.Header().Set("Content-Type", "application/json")
200198
json.NewEncoder(w).Encode(map[string]interface{}{
201-
"tools": toolNames,
199+
"tools": s.registeredTools,
202200
})
203201
})
204202

0 commit comments

Comments
 (0)