mcp

package
v0.4.3 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2026 License: AGPL-3.0, Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package mcp integrates Model Context Protocol tools (FR-10). It speaks JSON-RPC 2.0 over a newline-delimited stdio transport to external MCP servers and also supports in-process servers (Go functions). Every MCP tool is adapted to a tool.CoreTool named mcp__<server>__<tool> (FR-10.2/10.3).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InProcessServer

func InProcessServer(server string, tools []InProcessTool) []tool.CoreTool

InProcessServer adapts a set of in-process tools to CoreTools (FR-10.3).

func ToolName

func ToolName(server, name string) string

ToolName builds the three-segment MCP tool name.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is a connection to one MCP server.

func NewStdioClient

func NewStdioClient(ctx context.Context, server, command string, env map[string]string, args ...string) (*Client, error)

NewStdioClient spawns an MCP server as a subprocess, performs the handshake, and returns a connected Client (FR-10.1). Call Close to terminate it.

env holds extra environment variables (e.g. API tokens an MCP server needs) applied on top of the parent process environment; pass nil for none.

func (*Client) Close

func (c *Client) Close() error

Close shuts down the client's transport.

func (*Client) Tools

func (c *Client) Tools(ctx context.Context) ([]tool.CoreTool, error)

Tools lists the server's tools and adapts them to CoreTools.

type InProcessTool

type InProcessTool struct {
	Name        string
	Description string
	Schema      map[string]any
	Handler     func(ctx context.Context, args json.RawMessage) (string, error)
}

InProcessTool is a Go-native tool exposed under the MCP naming convention.

Jump to

Keyboard shortcuts

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