Skip to content

Commit afa7e78

Browse files
committed
cleanup
1 parent 36192c8 commit afa7e78

File tree

21 files changed

+62
-62
lines changed

21 files changed

+62
-62
lines changed

README.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
# JavaScript Executor MCP Server
22

3-
This MCP server provides JavaScript execution capabilities with ski runtime.
3+
This MCP server provides JavaScript execution capabilities with a modern runtime.
44

55
## Features
66

77
The `executeJS` tool provides:
88

99
- **Console API**: `console.log()`, `console.error()`, `console.warn()` (built-in)
10-
- **HTTP Server**: `serve()` for server creation (via `require('ski/http/server')`)
10+
- **HTTP Server**: `serve()` for server creation (via `require('http/server')`)
1111
- **Fetch API**: Modern `fetch()` with Request, Response, Headers, FormData (global)
1212
- **Timers**: `setTimeout()`, `setInterval()`, `clearTimeout()`, `clearInterval()` (global)
1313
- **Buffer**: Buffer, Blob, File APIs for binary data handling (global)
@@ -47,7 +47,7 @@ codebench-mcp --help
4747
```
4848

4949
**Available modules:**
50-
- `http` - HTTP server creation and client requests (import serve from 'ski/http/server')
50+
- `http` - HTTP server creation and client requests (require('http/server'))
5151
- `fetch` - Modern fetch API with Request, Response, Headers, FormData (available globally)
5252
- `timers` - setTimeout, setInterval, clearTimeout, clearInterval (available globally)
5353
- `buffer` - Buffer, Blob, File APIs for binary data handling (available globally)
@@ -68,13 +68,13 @@ package main
6868
import (
6969
"log"
7070

71-
"github.com/mark3labs/codebench-mcp/jsserver"
71+
"github.com/mark3labs/codebench-mcp/server"
7272
"github.com/mark3labs/mcp-go/server"
7373
)
7474

7575
func main() {
7676
// Create a new JavaScript executor server
77-
jss, err := jsserver.NewJSServer()
77+
jss, err := server.NewJSServer()
7878
if err != nil {
7979
log.Fatalf("Failed to create server: %v", err)
8080
}
@@ -95,17 +95,17 @@ import (
9595
"context"
9696
"log"
9797

98-
"github.com/mark3labs/codebench-mcp/jsserver"
98+
"github.com/mark3labs/codebench-mcp/server"
9999
"github.com/mark3labs/mcp-go/client"
100100
"github.com/mark3labs/mcp-go/mcp"
101101
)
102102

103103
func main() {
104104
// Create the JS server with custom module configuration
105-
config := jsserver.ModuleConfig{
105+
config := server.ModuleConfig{
106106
EnabledModules: []string{"fetch", "crypto", "buffer"},
107107
}
108-
jsServer, err := jsserver.NewJSServerWithConfig(config)
108+
jsServer, err := server.NewJSServerWithConfig(config)
109109
if err != nil {
110110
log.Fatalf("Failed to create server: %v", err)
111111
}
@@ -207,7 +207,7 @@ To integrate the Docker image with apps that support MCP:
207207

208208
### executeJS
209209

210-
Execute JavaScript code with ski runtime environment.
210+
Execute JavaScript code with a modern runtime environment.
211211

212212
**Parameters:**
213213
- `code` (required): JavaScript code to execute
@@ -225,7 +225,7 @@ const response = await fetch('https://api.example.com/data');
225225
const data = await response.json();
226226

227227
// HTTP server (require import)
228-
const serve = require('ski/http/server');
228+
const serve = require('http/server');
229229
serve(8000, async (req) => {
230230
return new Response('Hello World');
231231
});
@@ -255,7 +255,7 @@ console.log('Pathname:', url.pathname);
255255

256256
## Limitations
257257

258-
- **No fs or process modules** - File system and process APIs are not available in ski runtime
258+
- **No fs or process modules** - File system and process APIs are not available in the runtime
259259
- **Module access varies** - Some modules are global (fetch, http), others may need require()
260260
- **Each execution creates a fresh VM** - For isolation, each execution starts with a clean state
261261
- **Module filtering** - Configuration exists but actual runtime filtering not fully implemented

cmd/root.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import (
77
"strings"
88

99
"github.com/mark3labs/codebench-mcp/internal/logger"
10-
"github.com/mark3labs/codebench-mcp/jsserver"
11-
"github.com/mark3labs/mcp-go/server"
10+
"github.com/mark3labs/codebench-mcp/server"
11+
mcpserver "github.com/mark3labs/mcp-go/server"
1212
"github.com/spf13/cobra"
1313
)
1414

@@ -42,7 +42,7 @@ var rootCmd = &cobra.Command{
4242
Use: "codebench-mcp",
4343
Short: "JavaScript Executor MCP Server",
4444
Long: `A Model Context Protocol (MCP) server that provides JavaScript execution capabilities
45-
with ski runtime including http, fetch, timers, buffer, crypto, and other modules.`,
45+
with a modern runtime including http, fetch, timers, buffer, crypto, and other modules.`,
4646
Run: func(cmd *cobra.Command, args []string) {
4747
// Initialize logger first
4848
logger.Init(debugMode)
@@ -84,19 +84,19 @@ with ski runtime including http, fetch, timers, buffer, crypto, and other module
8484
logger.Debug("Module configuration", "enabled", modulesToEnable)
8585

8686
// Create server with module configuration
87-
config := jsserver.ModuleConfig{
87+
config := server.ModuleConfig{
8888
EnabledModules: modulesToEnable,
8989
}
9090

91-
jss, err := jsserver.NewJSServerWithConfig(config)
91+
jss, err := server.NewJSServerWithConfig(config)
9292
if err != nil {
9393
logger.Fatal("Failed to create server", "error", err)
9494
}
9595

9696
logger.Info("Starting MCP server", "modules", modulesToEnable)
9797

9898
// Serve requests
99-
if err := server.ServeStdio(jss); err != nil {
99+
if err := mcpserver.ServeStdio(jss); err != nil {
100100
logger.Fatal("Server error", "error", err)
101101
}
102102
},

jsserver/description_test.go renamed to server/description_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package jsserver
1+
package server
22

33
import (
44
"fmt"
@@ -19,7 +19,7 @@ func TestBuildToolDescription(t *testing.T) {
1919
name: "All modules enabled",
2020
enabledModules: []string{"http", "fetch", "timers", "buffer", "crypto"},
2121
expectedContent: []string{
22-
"ski runtime",
22+
"modern runtime",
2323
"Node.js-like APIs",
2424
"Available modules:",
2525
"• http: HTTP server creation and management",
@@ -34,7 +34,7 @@ func TestBuildToolDescription(t *testing.T) {
3434
name: "Only http and fetch",
3535
enabledModules: []string{"http", "fetch"},
3636
expectedContent: []string{
37-
"ski runtime",
37+
"modern runtime",
3838
"Available modules:",
3939
"• http: HTTP server creation and management",
4040
"• fetch: Modern fetch API with Request, Response, Headers, FormData",
@@ -50,7 +50,7 @@ func TestBuildToolDescription(t *testing.T) {
5050
name: "No modules enabled",
5151
enabledModules: []string{},
5252
expectedContent: []string{
53-
"ski runtime",
53+
"modern runtime",
5454
"No modules are currently enabled",
5555
"Only basic JavaScript execution is available",
5656
},

jsserver/inprocess_test.go renamed to server/inprocess_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
package jsserver_test
1+
package server_test
22

33
import (
44
"context"
55
"testing"
66

7-
"github.com/mark3labs/codebench-mcp/jsserver"
7+
"github.com/mark3labs/codebench-mcp/server"
88
"github.com/mark3labs/mcp-go/client"
99
"github.com/mark3labs/mcp-go/mcp"
1010
"github.com/stretchr/testify/assert"
@@ -13,7 +13,7 @@ import (
1313

1414
func TestInProcessTransport(t *testing.T) {
1515
// Create the JS server
16-
jsServer, err := jsserver.NewJSServer()
16+
jsServer, err := server.NewJSServer()
1717
require.NoError(t, err)
1818

1919
// Create an in-process client
@@ -34,7 +34,7 @@ func TestInProcessTransport(t *testing.T) {
3434
}
3535
result, err := mcpClient.Initialize(context.Background(), initRequest)
3636
require.NoError(t, err)
37-
assert.Equal(t, "javascript-executor", result.ServerInfo.Name)
37+
assert.Equal(t, "codebench-mcp", result.ServerInfo.Name)
3838

3939
// List tools to verify executeJS is available
4040
toolsResult, err := mcpClient.ListTools(context.Background(), mcp.ListToolsRequest{})
@@ -76,7 +76,7 @@ func TestInProcessTransport(t *testing.T) {
7676

7777
func TestInProcessTransport_ErrorHandling(t *testing.T) {
7878
// Create the JS server
79-
jsServer, err := jsserver.NewJSServer()
79+
jsServer, err := server.NewJSServer()
8080
require.NoError(t, err)
8181

8282
// Create an in-process client

jsserver/module_test.go renamed to server/module_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package jsserver
1+
package server
22

33
import (
44
"context"
@@ -75,7 +75,7 @@ func TestModuleConfiguration_DisabledModules(t *testing.T) {
7575
}
7676

7777
func TestModuleConfiguration_NoConsole(t *testing.T) {
78-
// Test with basic execution - console.log should work in ski runtime
78+
// Test with basic execution - console.log should work in the runtime
7979
config := ModuleConfig{
8080
EnabledModules: []string{}, // No modules enabled
8181
}

jsserver/modules/buffer/buffer.go renamed to server/modules/buffer/buffer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"encoding/hex"
66

77
"github.com/grafana/sobek"
8-
"github.com/mark3labs/codebench-mcp/jsserver/vm"
8+
"github.com/mark3labs/codebench-mcp/server/vm"
99
)
1010

1111
// BufferModule provides Buffer global for binary data handling

jsserver/modules/cache/cache.go renamed to server/modules/cache/cache.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"time"
77

88
"github.com/grafana/sobek"
9-
"github.com/mark3labs/codebench-mcp/jsserver/vm"
9+
"github.com/mark3labs/codebench-mcp/server/vm"
1010
)
1111

1212
// CacheModule provides in-memory caching with TTL support
File renamed without changes.

jsserver/modules/crypto/crypto.go renamed to server/modules/crypto/crypto.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
"hash"
1313

1414
"github.com/grafana/sobek"
15-
"github.com/mark3labs/codebench-mcp/jsserver/vm"
15+
"github.com/mark3labs/codebench-mcp/server/vm"
1616
)
1717

1818
// CryptoModule provides cryptographic functions

jsserver/modules/encoding/encoding.go renamed to server/modules/encoding/encoding.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package encoding
22

33
import (
44
"github.com/grafana/sobek"
5-
"github.com/mark3labs/codebench-mcp/jsserver/vm"
5+
"github.com/mark3labs/codebench-mcp/server/vm"
66
)
77

88
// EncodingModule provides TextEncoder and TextDecoder

0 commit comments

Comments
 (0)