Help us shape the future of Go! Take the 2026 Go Developer Survey

mcptool

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package mcptool provides integration with the Model Context Protocol (MCP). It allows agents to connect to external MCP servers via stdio (subprocess) or HTTP (SSE / streamable HTTP) and expose their tools as tool.Tool / tool.FuncTool instances.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddTool

func AddTool(src *mcp.Server, tl tool.FuncTool)

AddTool registers a tool.FuncTool on the given mcp.Server so it is exposed to MCP clients. Native mcp.Content and []mcp.Content results are returned as MCP content blocks; they must contain content types valid in a tool response. Nil content entries are represented as the text "null". A *mcp.CallToolResult is returned as-is. Array return schemas and their structured results are wrapped in an object with a "result" property so structured output also works with older MCP clients. The text content retains the original JSON for existing clients. Explicit MCP results and MCP/framework content bypass this wrapping. When an output schema is advertised, callers returning these types must provide structured content matching that schema for successful results.

func Connect

func Connect(ctx context.Context, transport mcp.Transport) (*mcp.ClientSession, error)

Connect dials an MCP server over the given transport and returns a client session.

func ListTools

func ListTools(ctx context.Context, session *mcp.ClientSession) ([]tool.Tool, error)

ListTools enumerates all pages of the remote server's tools and wraps each as a tool.Tool.

Types

This section is empty.

Jump to

Keyboard shortcuts

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