mcp
packageThis package is not in the latest version of its module.
Details
Validgo.mod file
The Go module system was introduced in Go 1.11 and is the official dependency management solution for Go.
Redistributable license
Redistributable licenses place minimal restrictions on how software can be used, modified, and redistributed.
Tagged version
Modules with tagged versions give importers more predictable builds.
Stable version
When a project reaches major version v1 it is considered stable.
- Learn more about best practices
Repository
Links
Documentation¶
Index¶
- func EncodeToolID(server, tool string) string
- func FilterAllowedTools(logger slog.Logger, tools map[string]*Tool, allowlist *regexp.Regexp, ...) map[string]*Tool
- func GetClientInfo() mcp.Implementation
- type ServerProxier
- type ServerProxyManager
- func (s *ServerProxyManager) CallTool(ctx context.Context, name string, input any) (*mcp.CallToolResult, error)
- func (s *ServerProxyManager) GetTool(name string) *Tool
- func (s *ServerProxyManager) Init(ctx context.Context) error
- func (s *ServerProxyManager) ListTools() []*Tool
- func (s *ServerProxyManager) Shutdown(ctx context.Context) error
- type StreamableHTTPServerProxy
- func (p *StreamableHTTPServerProxy) CallTool(ctx context.Context, name string, input any) (*mcp.CallToolResult, error)
- func (p *StreamableHTTPServerProxy) GetTool(name string) *Tool
- func (p *StreamableHTTPServerProxy) Init(ctx context.Context) error
- func (p *StreamableHTTPServerProxy) ListTools() []*Tool
- func (p *StreamableHTTPServerProxy) Name() string
- func (p *StreamableHTTPServerProxy) Shutdown(ctx context.Context) error
- type Tool
- type ToolCaller
Constants¶
This section is empty.
Variables¶
This section is empty.
Functions¶
funcEncodeToolID¶
EncodeToolID namespaces the given tool name with a prefix to identify tools injected by this library.Claude Code, for example, prefixes the tools it includes from defined MCP servers with the "mcp__" prefix.We have to namespace the tools we inject to prevent clashes.
We stick to 5 prefix chars ("bmcp_") like "mcp__" since names can only be up to 64 chars:
See:-https://community.openai.com/t/function-call-description-max-length/529902-https://github.com/anthropics/claude-code/issues/2326
funcFilterAllowedTools¶
func FilterAllowedTools(loggerslog.Logger, tools map[string]*Tool, allowlist *regexp.Regexp, denylist *regexp.Regexp) map[string]*Tool
FilterAllowedTools filters tools based on the given allow/denylists.Filtering acts on tool names, and uses tool IDs for tracking.The denylist supersedes the allowlist in the case of any conflicts.If an allowlist is provided, tools must match it to be allowed.If only a denylist is provided, tools are allowed unless explicitly denied.
funcGetClientInfo¶
func GetClientInfo()mcp.Implementation
GetClientInfo returns the MCP client information to use when initializing MCP connections.This provides a consistent way for all proxy implementations to report client information.
Types¶
typeServerProxier¶
type ServerProxier interface {// Init initializes the proxier, establishing a connection with the upstream server and fetching resources.Init(context.Context)error// Gracefully shut down connections to the MCP server. Session management will vary per transport.// Seehttps://modelcontextprotocol.io/specification/2025-06-18/basic/transports#session-management.Shutdown(ctxcontext.Context)error// ListTools lists all known tools.ListTools() []*Tool// GetTool returns a given tool, if known, or returns nil.GetTool(idstring) *Tool// CallTool invokes an injected MCP toolCallTool(ctxcontext.Context, namestring, inputany) (*mcp.CallToolResult,error)}ServerProxier provides an abstraction to communicate with MCP Servers regardless of their transport.The ServerProxier is expected to, at least, fetch any available MCP tools.
typeServerProxyManager¶
type ServerProxyManager struct {// contains filtered or unexported fields}ServerProxyManager can act on behalf of multiple [ServerProxier]s.It aggregates all server resources (currently just tools) across all MCP serversfor the purpose of injection into bridged requests and invocation.
funcNewServerProxyManager¶
func NewServerProxyManager(proxiers map[string]ServerProxier) *ServerProxyManager
func (*ServerProxyManager)CallTool¶
func (s *ServerProxyManager) CallTool(ctxcontext.Context, namestring, inputany) (*mcp.CallToolResult,error)
CallTool locates the proxier to which the requested tool is associated anddelegates the tool call to it.
func (*ServerProxyManager)GetTool¶
func (s *ServerProxyManager) GetTool(namestring) *Tool
func (*ServerProxyManager)Init¶
func (s *ServerProxyManager) Init(ctxcontext.Context)error
Init concurrently initializes all of its [ServerProxier]s.
func (*ServerProxyManager)ListTools¶
func (s *ServerProxyManager) ListTools() []*Tool
typeStreamableHTTPServerProxy¶
type StreamableHTTPServerProxy struct {// contains filtered or unexported fields}func (*StreamableHTTPServerProxy)CallTool¶
func (p *StreamableHTTPServerProxy) CallTool(ctxcontext.Context, namestring, inputany) (*mcp.CallToolResult,error)
func (*StreamableHTTPServerProxy)GetTool¶
func (p *StreamableHTTPServerProxy) GetTool(namestring) *Tool
func (*StreamableHTTPServerProxy)Init¶
func (p *StreamableHTTPServerProxy) Init(ctxcontext.Context)error
func (*StreamableHTTPServerProxy)ListTools¶
func (p *StreamableHTTPServerProxy) ListTools() []*Tool
func (*StreamableHTTPServerProxy)Name¶
func (p *StreamableHTTPServerProxy) Name()string
typeTool¶
typeToolCaller¶
type ToolCaller interface {CallTool(ctxcontext.Context, requestmcp.CallToolRequest) (*mcp.CallToolResult,error)}ToolCaller is the narrowest interface which describes the behaviour required frommcp.Client,which will normally be passed intoTool for interaction with an MCP server.TODO: don't expose github.com/mark3labs/mcp-go outside this package.