Movatterモバイル変換


[0]ホーム

URL:


mcp

package
v0.2.0Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2025 License:AGPL-3.0Imports:14Imported by:1

Details

Repository

github.com/coder/aibridge

Links

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

funcEncodeToolID

func EncodeToolID(server, toolstring)string

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

Init concurrently initializes all of its [ServerProxier]s.

func (*ServerProxyManager)ListTools

func (s *ServerProxyManager) ListTools() []*Tool

func (*ServerProxyManager)Shutdown

func (s *ServerProxyManager) Shutdown(ctxcontext.Context)error

Shutdown concurrently shuts down all known proxiers and waits for them *all* to complete.

typeStreamableHTTPServerProxy

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

funcNewStreamableHTTPServerProxy

func NewStreamableHTTPServerProxy(loggerslog.Logger, serverName, serverURLstring, headers map[string]string, allowlist, denylist *regexp.Regexp) (*StreamableHTTPServerProxy,error)

func (*StreamableHTTPServerProxy)CallTool

func (*StreamableHTTPServerProxy)GetTool

func (p *StreamableHTTPServerProxy) GetTool(namestring) *Tool

func (*StreamableHTTPServerProxy)Init

func (*StreamableHTTPServerProxy)ListTools

func (p *StreamableHTTPServerProxy) ListTools() []*Tool

func (*StreamableHTTPServerProxy)Name

func (*StreamableHTTPServerProxy)Shutdown

typeTool

type Tool struct {ClientToolCallerIDstringNamestringServerNamestringServerURLstringDescriptionstringParams      map[string]anyRequired    []string}

func (*Tool)Call

func (t *Tool) Call(ctxcontext.Context, inputany) (*mcp.CallToolResult,error)

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.

Source Files

View all Source files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f orF : Jump to
y orY : Canonical URL
go.dev uses cookies from Google to deliver and enhance the quality of its services and to analyze traffic.Learn more.

[8]ページ先頭

©2009-2025 Movatter.jp