Skip to main content
Glama
inprocess.go1.35 kB
package client import ( "context" "github.com/mark3labs/mcp-go/client/transport" "github.com/mark3labs/mcp-go/mcp" "github.com/mark3labs/mcp-go/server" ) // NewInProcessClient connect directly to a mcp server object in the same process func NewInProcessClient(server *server.MCPServer) (*Client, error) { inProcessTransport := transport.NewInProcessTransport(server) return NewClient(inProcessTransport), nil } // NewInProcessClientWithSamplingHandler creates an in-process client with sampling support func NewInProcessClientWithSamplingHandler(server *server.MCPServer, handler SamplingHandler) (*Client, error) { // Create a wrapper that implements server.SamplingHandler serverHandler := &inProcessSamplingHandlerWrapper{handler: handler} inProcessTransport := transport.NewInProcessTransportWithOptions(server, transport.WithSamplingHandler(serverHandler)) client := NewClient(inProcessTransport) client.samplingHandler = handler return client, nil } // inProcessSamplingHandlerWrapper wraps client.SamplingHandler to implement server.SamplingHandler type inProcessSamplingHandlerWrapper struct { handler SamplingHandler } func (w *inProcessSamplingHandlerWrapper) CreateMessage(ctx context.Context, request mcp.CreateMessageRequest) (*mcp.CreateMessageResult, error) { return w.handler.CreateMessage(ctx, request) }

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/mozillazg/kube-audit-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server