Skip to content

Commit fe3a840

Browse files
authored
Mcp sse (#2148)
1 parent 55f0521 commit fe3a840

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

cmd/micro-mcp/mcp.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ func handler(ctx context.Context, r mcp.CallToolRequest) (*mcp.CallToolResult, e
4545
}
4646

4747
func Run(c *cli.Context) error {
48+
useSSE := c.Bool("sse")
49+
4850
// Create MCP server
4951
s := server.NewMCPServer(
5052
"micro",
@@ -121,6 +123,11 @@ func Run(c *cli.Context) error {
121123
return mcp.NewToolResultText(string(b)), nil
122124
})
123125

126+
if useSSE {
127+
// Use the SSE server from the mcp-go/server package, passing the MCP server
128+
return server.NewSSEServer(s).Start(":8081")
129+
}
130+
124131
// Start the stdio server
125132
if err := server.ServeStdio(s); err != nil {
126133
fmt.Printf("Server error: %v\n", err)
@@ -132,7 +139,13 @@ func Run(c *cli.Context) error {
132139
func init() {
133140
cmd.Register(&cli.Command{
134141
Name: "mcp",
135-
Usage: "Run MCP server on stdio",
142+
Usage: "Run MCP server on stdio or SSE (with --sse)",
143+
Flags: []cli.Flag{
144+
&cli.BoolFlag{
145+
Name: "sse",
146+
Usage: "Run as SSE server on :8081 instead of stdio",
147+
},
148+
},
136149
Action: Run,
137150
})
138151
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy