Documentation
¶
Overview ¶
Copyright 2026 Teradata
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Package client implements the MCP client for connecting to MCP servers.
Copyright 2026 Teradata ¶
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2026 Teradata ¶
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Package client implements MCP client prompts support.
Copyright 2026 Teradata ¶
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Package client implements MCP client resources support.
Copyright 2026 Teradata ¶
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Package client implements MCP client tools support.
Index ¶
- type Client
- func (c *Client) CallTool(ctx context.Context, name string, arguments map[string]interface{}) (interface{}, error)
- func (c *Client) Close() error
- func (c *Client) GetPrompt(ctx context.Context, name string, arguments map[string]interface{}) (*protocol.GetPromptResult, error)
- func (c *Client) Initialize(ctx context.Context, clientInfo protocol.Implementation) error
- func (c *Client) IsInitialized() bool
- func (c *Client) ListPrompts(ctx context.Context) ([]protocol.Prompt, error)
- func (c *Client) ListResources(ctx context.Context) ([]protocol.Resource, error)
- func (c *Client) ListTools(ctx context.Context) ([]protocol.Tool, error)
- func (c *Client) Ping(ctx context.Context) error
- func (c *Client) ReadResource(ctx context.Context, uri string) (*protocol.ReadResourceResult, error)
- func (c *Client) ServerCapabilities() protocol.ServerCapabilities
- func (c *Client) ServerInfo() protocol.Implementation
- func (c *Client) SetSamplingHandler(handler SamplingHandler)
- func (c *Client) SubscribeResource(ctx context.Context, uri string) error
- func (c *Client) UnsubscribeResource(ctx context.Context, uri string) error
- type Config
- type InstrumentedClient
- func (ic *InstrumentedClient) CallTool(ctx context.Context, name string, arguments map[string]interface{}) (interface{}, error)
- func (ic *InstrumentedClient) Close() error
- func (ic *InstrumentedClient) GetPrompt(ctx context.Context, name string, arguments map[string]interface{}) (*protocol.GetPromptResult, error)
- func (ic *InstrumentedClient) Initialize(ctx context.Context, clientInfo protocol.Implementation) error
- func (ic *InstrumentedClient) IsInitialized() bool
- func (ic *InstrumentedClient) ListPrompts(ctx context.Context) ([]protocol.Prompt, error)
- func (ic *InstrumentedClient) ListResources(ctx context.Context) ([]protocol.Resource, error)
- func (ic *InstrumentedClient) ListTools(ctx context.Context) ([]protocol.Tool, error)
- func (ic *InstrumentedClient) Ping(ctx context.Context) error
- func (ic *InstrumentedClient) ReadResource(ctx context.Context, uri string) (*protocol.ReadResourceResult, error)
- func (ic *InstrumentedClient) SetSamplingHandler(handler SamplingHandler)
- func (ic *InstrumentedClient) SubscribeResource(ctx context.Context, uri string) error
- func (ic *InstrumentedClient) UnsubscribeResource(ctx context.Context, uri string) error
- type Notification
- type ProgressHandler
- type SamplingHandler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client represents an MCP client connection to a server
func (*Client) CallTool ¶
func (c *Client) CallTool(ctx context.Context, name string, arguments map[string]interface{}) (interface{}, error)
CallTool invokes a tool with given arguments Returns interface{} to avoid import cycles in shuttle package (actual type is *protocol.CallToolResult)
func (*Client) GetPrompt ¶
func (c *Client) GetPrompt(ctx context.Context, name string, arguments map[string]interface{}) (*protocol.GetPromptResult, error)
GetPrompt retrieves a prompt with arguments
func (*Client) Initialize ¶
Initialize performs the MCP handshake
func (*Client) IsInitialized ¶
IsInitialized returns whether the client is initialized
func (*Client) ListPrompts ¶
ListPrompts returns all available prompts from the server
func (*Client) ListResources ¶
ListResources returns all available resources from the server
func (*Client) ReadResource ¶
func (c *Client) ReadResource(ctx context.Context, uri string) (*protocol.ReadResourceResult, error)
ReadResource reads a resource by URI
func (*Client) ServerCapabilities ¶
func (c *Client) ServerCapabilities() protocol.ServerCapabilities
ServerCapabilities returns the server capabilities
func (*Client) ServerInfo ¶
func (c *Client) ServerInfo() protocol.Implementation
ServerInfo returns the server implementation info
func (*Client) SetSamplingHandler ¶
func (c *Client) SetSamplingHandler(handler SamplingHandler)
SetSamplingHandler registers a handler for sampling requests
func (*Client) SubscribeResource ¶
SubscribeResource subscribes to resource changes
type Config ¶
type Config struct {
Transport transport.Transport
Logger *zap.Logger
// Client info
Name string
Version string
// Capabilities
SupportsSampling bool
SupportsRoots bool
// Timeouts
RequestTimeout time.Duration // Default: 30s
}
Config configures the MCP client
type InstrumentedClient ¶
type InstrumentedClient struct {
// contains filtered or unexported fields
}
InstrumentedClient wraps an MCP Client with observability instrumentation. It captures detailed traces and metrics for every MCP operation, including: - Operation type and parameters - Execution duration and success/failure - Result data and errors - Server identification
This wrapper is transparent and can wrap any Client.
func NewInstrumentedClient ¶
func NewInstrumentedClient(client *Client, tracer observability.Tracer, serverName string) *InstrumentedClient
NewInstrumentedClient creates a new instrumented MCP client.
func (*InstrumentedClient) CallTool ¶
func (ic *InstrumentedClient) CallTool(ctx context.Context, name string, arguments map[string]interface{}) (interface{}, error)
CallTool calls a tool with observability instrumentation. Returns interface{} to avoid import cycles (actual type is *protocol.CallToolResult)
func (*InstrumentedClient) Close ¶
func (ic *InstrumentedClient) Close() error
Close delegates to the underlying client.
func (*InstrumentedClient) GetPrompt ¶
func (ic *InstrumentedClient) GetPrompt(ctx context.Context, name string, arguments map[string]interface{}) (*protocol.GetPromptResult, error)
GetPrompt gets a prompt with observability instrumentation.
func (*InstrumentedClient) Initialize ¶
func (ic *InstrumentedClient) Initialize(ctx context.Context, clientInfo protocol.Implementation) error
Initialize performs the MCP handshake with observability instrumentation.
func (*InstrumentedClient) IsInitialized ¶
func (ic *InstrumentedClient) IsInitialized() bool
IsInitialized delegates to the underlying client.
func (*InstrumentedClient) ListPrompts ¶
ListPrompts lists available prompts with observability instrumentation.
func (*InstrumentedClient) ListResources ¶
ListResources lists available resources with observability instrumentation.
func (*InstrumentedClient) ListTools ¶
ListTools lists available tools with observability instrumentation.
func (*InstrumentedClient) Ping ¶
func (ic *InstrumentedClient) Ping(ctx context.Context) error
Ping delegates to the underlying client.
func (*InstrumentedClient) ReadResource ¶
func (ic *InstrumentedClient) ReadResource(ctx context.Context, uri string) (*protocol.ReadResourceResult, error)
ReadResource reads a resource with observability instrumentation.
func (*InstrumentedClient) SetSamplingHandler ¶
func (ic *InstrumentedClient) SetSamplingHandler(handler SamplingHandler)
SetSamplingHandler delegates to the underlying client.
func (*InstrumentedClient) SubscribeResource ¶
func (ic *InstrumentedClient) SubscribeResource(ctx context.Context, uri string) error
SubscribeResource subscribes to resource updates with observability instrumentation.
func (*InstrumentedClient) UnsubscribeResource ¶
func (ic *InstrumentedClient) UnsubscribeResource(ctx context.Context, uri string) error
UnsubscribeResource delegates to the underlying client.
type Notification ¶
type Notification struct {
Method string
Params json.RawMessage
}
Notification represents a notification from the server
type ProgressHandler ¶
type ProgressHandler func(progress, total float64)
ProgressHandler is called for progress updates
type SamplingHandler ¶
type SamplingHandler func(ctx context.Context, params protocol.SamplingParams) (*protocol.SamplingResult, error)
SamplingHandler is called when server requests LLM completion