Skip to content

Commit 9f46a54

Browse files
committed
feat: add HTTP transport option
1 parent 720730a commit 9f46a54

5 files changed

Lines changed: 115 additions & 7 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
.claude/
2+
.claude-sessions/
23
bin/
34
.DS_Store

Dockerfile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,13 @@ FROM gcr.io/distroless/base-debian12
2121
WORKDIR /server
2222
# Copy the binary from the build stage
2323
COPY --from=build /bin/v1-mcp-server .
24+
25+
# Transport configuration: stdio (default) or http
26+
ENV TRANSPORT=stdio
27+
# Address to listen on when using http transport (AgentCore expects port 8000)
28+
ENV ADDR=:8000
29+
# Expose port for http transport
30+
EXPOSE 8000
31+
2432
# Command to run the server
2533
ENTRYPOINT ["./v1-mcp-server"]

README.md

Lines changed: 54 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ This allows users to harness the power of Large Language Models (LLM) to interpr
1313

1414
## Security
1515

16-
1. Your Trend Vision One API keys should be configured with minimial permissions.
16+
1. Your Trend Vision One API keys should be configured with minimal permissions.
1717
2. By default the MCP server runs in read-only mode. Be careful when running the server with `readonly=false` as it may have irreversible consequences.
1818
3. Data retrieved using the MCP server is processed by the LLM configured in your AI tooling. It is your responsibility to ensure that this LLM is approved by your company for processing sensitive data.
19-
4. This MCP server is only intended to be used with local integrations and command-line tools via the Standard Input/Output transport. You should never expose this tool to the network.
19+
4. When using HTTP transport, ensure the server is deployed behind appropriate authentication and network controls. The HTTP transport is intended for managed cloud deployments (e.g., AWS AgentCore) with proper security measures in place.
2020

2121
## Getting Started
2222

@@ -80,11 +80,58 @@ Alternatively, copy the following into your `settings.json`.
8080

8181
### Server Options
8282

83-
| Option | Description |
84-
| ------ | ----------- |
85-
| `-readonly` | Specify whether or not the server should run in readonly mode `readonly=true`, `readonly=false`. Default `true`. |
86-
| `-region` | Specify the Trend Vision One region. Regions are: `au`, `jp`, `eu`, `sg`, `in`, `us` or `mea`. |
87-
| `-host` | Set the Trend Vision One endpoint you want to use. Useful for interacting with internal environments. |
83+
| Option | Environment Variable | Description |
84+
| ------ | -------------------- | ----------- |
85+
| `-readonly` | | Specify whether or not the server should run in readonly mode `readonly=true`, `readonly=false`. Default `true`. |
86+
| `-region` | | Specify the Trend Vision One region. Regions are: `au`, `jp`, `eu`, `sg`, `in`, `us` or `mea`. |
87+
| `-host` | | Set the Trend Vision One endpoint you want to use. Useful for interacting with internal environments. |
88+
| `-transport` | `TRANSPORT` | Transport type: `stdio` or `http`. Default `stdio`. |
89+
| `-addr` | `ADDR` | Address to listen on when using HTTP transport. Default `:8000`. |
90+
91+
### Transport Modes
92+
93+
The MCP server supports two transport modes:
94+
95+
#### Standard I/O (stdio) - Default
96+
97+
Used for local integrations with Claude Desktop, VSCode, and other MCP clients that communicate via stdin/stdout.
98+
99+
```bash
100+
./v1-mcp-server -region us
101+
```
102+
103+
#### HTTP (Streamable HTTP)
104+
105+
Used for remote deployments such as AWS Bedrock AgentCore. The server exposes a `/mcp` endpoint for MCP communication using the streamable HTTP transport.
106+
107+
```bash
108+
./v1-mcp-server -region us -transport http -addr :8000
109+
```
110+
111+
Or using environment variables (recommended for containerized deployments):
112+
113+
```bash
114+
TRANSPORT=http ADDR=:8000 ./v1-mcp-server -region us
115+
```
116+
117+
**Docker with HTTP transport:**
118+
119+
```bash
120+
docker run -p 8000:8000 \
121+
-e TREND_VISION_ONE_API_KEY=your-api-key \
122+
-e TRANSPORT=http \
123+
ghcr.io/trendmicro/vision-one-mcp-server \
124+
-region us
125+
```
126+
127+
**Testing locally:**
128+
129+
```bash
130+
# List available tools
131+
curl -X POST http://localhost:8000/mcp \
132+
-H "Content-Type: application/json" \
133+
-d '{"jsonrpc": "2.0", "id": 1, "method": "tools/list"}'
134+
```
88135

89136
## Tools
90137

cmd/v1-mcp-server/main.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ func run() error {
2424
v1Region := flag.String("region", "", "set the region of your vision one account.")
2525
showVersion := flag.Bool("version", false, "print version information")
2626
host := flag.String("host", "", "set the Trend Vision One endpoint you want to use. Only useful for interacting with internal environments.")
27+
transport := flag.String("transport", getEnvOrDefault("TRANSPORT", "stdio"), "transport type: stdio or http")
28+
addr := flag.String("addr", getEnvOrDefault("ADDR", ":8000"), "address to listen on when using http transport")
2729

2830
flag.Parse()
2931

@@ -47,6 +49,10 @@ func run() error {
4749
}
4850
}
4951

52+
if *transport != "stdio" && *transport != "http" {
53+
return fmt.Errorf("invalid transport %q, must be stdio or http", *transport)
54+
}
55+
5056
version := getVersion()
5157

5258
serverCfg := v1mcp.ServerConfig{
@@ -57,6 +63,10 @@ func run() error {
5763
Host: *host,
5864
}
5965

66+
if *transport == "http" {
67+
return v1mcp.RunMcpHttpServer(serverCfg, *addr)
68+
}
69+
6070
return v1mcp.RunMcpStdioServer(serverCfg)
6171
}
6272

@@ -100,3 +110,10 @@ func getVersion() string {
100110
func printVersion() {
101111
fmt.Fprintf(os.Stderr, "%s\n", getVersion())
102112
}
113+
114+
func getEnvOrDefault(key, defaultValue string) string {
115+
if value := os.Getenv(key); value != "" {
116+
return value
117+
}
118+
return defaultValue
119+
}

internal/v1mcp/server.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,41 @@ func RunMcpStdioServer(cfg ServerConfig) error {
8888
return nil
8989
}
9090

91+
func RunMcpHttpServer(cfg ServerConfig, addr string) error {
92+
ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM)
93+
defer stop()
94+
95+
s, err := NewMcpServer(cfg)
96+
if err != nil {
97+
return fmt.Errorf("error creating mcp server: %w", err)
98+
}
99+
100+
// Use StreamableHTTPServer for AgentCore compatibility (POST /mcp endpoint)
101+
httpServer := mcpserver.NewStreamableHTTPServer(s,
102+
mcpserver.WithEndpointPath("/mcp"),
103+
mcpserver.WithStateLess(true),
104+
)
105+
106+
serverError := make(chan error)
107+
go func() {
108+
serverError <- httpServer.Start(addr)
109+
}()
110+
111+
fmt.Fprintf(os.Stderr, "server listening on %s...\n", addr)
112+
113+
select {
114+
case <-ctx.Done():
115+
fmt.Fprintf(os.Stderr, "shutting down server...\n")
116+
if err := httpServer.Shutdown(context.Background()); err != nil {
117+
return fmt.Errorf("error shutting down server: %w", err)
118+
}
119+
case e := <-serverError:
120+
return fmt.Errorf("server encountered error: %w", e)
121+
}
122+
123+
return nil
124+
}
125+
91126
func addReadOnlyToolset(
92127
s *mcpserver.MCPServer,
93128
client *v1client.V1ApiClient,

0 commit comments

Comments
 (0)