adapter

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

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 adapter provides adapters to integrate MCP with Loom's existing systems. This package bridges MCP tools to Loom's shuttle.Tool interface.

Index

Constants

View Source
const (
	// DefaultMaxResultBytes is the maximum size of tool results before truncation
	// 20KB matches MaxPreviewChars in storage package (20,000 chars ≈ 5K tokens)
	DefaultMaxResultBytes = 20000

	// DefaultMaxResultRows is the maximum number of rows to return from SQL results
	DefaultMaxResultRows = 500

	// SchemaCacheTTL is how long schema results are cached
	SchemaCacheTTL = 5 * time.Minute
)

Result truncation and caching configuration

Variables

This section is empty.

Functions

func AdaptMCPTools

func AdaptMCPTools(ctx context.Context, mcpClient *client.Client, serverName string) ([]shuttle.Tool, error)

AdaptMCPTools converts all tools from an MCP client to shuttle.Tool instances

func ClearSchemaCache

func ClearSchemaCache()

ClearSchemaCache clears the global schema cache (useful for testing or cache invalidation)

func GetSchemaCacheStats

func GetSchemaCacheStats() (entries int, oldestAge time.Duration)

GetSchemaCacheStats returns cache statistics

Types

type MCPToolAdapter

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

MCPToolAdapter wraps an MCP tool as a shuttle.Tool

func NewMCPToolAdapter

func NewMCPToolAdapter(client *client.Client, tool protocol.Tool, serverName string) *MCPToolAdapter

NewMCPToolAdapter creates a new adapter that wraps an MCP tool

func NewMCPToolAdapterWithConfig

func NewMCPToolAdapterWithConfig(client *client.Client, tool protocol.Tool, serverName string, config TruncationConfig) *MCPToolAdapter

NewMCPToolAdapterWithConfig creates a new adapter with custom truncation config

func (*MCPToolAdapter) Backend

func (a *MCPToolAdapter) Backend() string

Backend implements shuttle.Tool

func (*MCPToolAdapter) Description

func (a *MCPToolAdapter) Description() string

Description implements shuttle.Tool

func (*MCPToolAdapter) Execute

func (a *MCPToolAdapter) Execute(ctx context.Context, params map[string]interface{}) (*shuttle.Result, error)

Execute implements shuttle.Tool

func (*MCPToolAdapter) InputSchema

func (a *MCPToolAdapter) InputSchema() *shuttle.JSONSchema

InputSchema implements shuttle.Tool

func (*MCPToolAdapter) Name

func (a *MCPToolAdapter) Name() string

Name implements shuttle.Tool

func (*MCPToolAdapter) SetSQLResultStore

func (a *MCPToolAdapter) SetSQLResultStore(store *storage.SQLResultStore)

SetSQLResultStore configures SQL result store for this adapter. Enables automatic storage of large SQL results.

func (*MCPToolAdapter) SetSharedMemory

func (a *MCPToolAdapter) SetSharedMemory(store *storage.SharedMemoryStore)

SetSharedMemory configures shared memory store for this adapter. Enables automatic storage of large non-SQL data.

type TruncationConfig

type TruncationConfig struct {
	MaxResultBytes int  // Maximum result size in bytes (0 = use default)
	MaxResultRows  int  // Maximum rows for SQL results (0 = use default)
	Enabled        bool // Whether truncation is enabled
}

TruncationConfig configures how tool results are truncated

Jump to

Keyboard shortcuts

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