mcpserver

package
v0.8.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 5, 2026 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

Package mcpserver contains minimal MCP server implementations for testing. Each transport (HTTP, SSE, stdio) implements the MCP JSON-RPC protocol just enough to: respond to initialize, list one tool, and call that tool. They exist so integration/e2e tests can verify the full pipeline without depending on external MCP servers or the full mark3labs/mcp-go SDK.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HandleMCPRequest

func HandleMCPRequest(body []byte) jsonRPCResponse

HandleMCPRequest processes a single MCP JSON-RPC request and returns the response. This is the shared handler for all three transport test servers.

func RunStdio

func RunStdio()

RunStdio reads JSON-RPC requests from stdin, one per line, and writes responses to stdout. Designed to be invoked as a subprocess (matching opencode's local MCP server execution model).

Types

type HTTPTestServer

type HTTPTestServer struct {
	URL string
	// contains filtered or unexported fields
}

HTTPTestServer is a minimal HTTP MCP server. It accepts POST requests with JSON-RPC bodies and responds with the shared handler.

func NewHTTPTestServer

func NewHTTPTestServer() *HTTPTestServer

NewHTTPTestServer starts an HTTP MCP server on a random port.

func (*HTTPTestServer) Close

func (s *HTTPTestServer) Close()

Close shuts down the HTTP server.

type SSETestServer

type SSETestServer struct {
	URL string
	// contains filtered or unexported fields
}

SSETestServer is a minimal SSE MCP server. It implements the streamable HTTP transport: the client POSTs JSON-RPC requests, the server responds with text/event-stream frames.

func NewSSETestServer

func NewSSETestServer() *SSETestServer

NewSSETestServer starts an SSE MCP server on a random port.

func (*SSETestServer) Close

func (s *SSETestServer) Close()

Close shuts down the SSE server.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL