mcp

package
v0.50.1 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2026 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Overview

Unused symbols here are intentional: artifact_build is deliberately not registered (see the note at the end of this file). The code is kept so it can be re-enabled.

Index

Constants

View Source
const LoginRequiredMessage = "please run 'ivcap context login' in your terminal to continue"

LoginRequiredMessage is returned when an MCP tool invocation requires auth but no usable access token is available.

Variables

View Source
var ErrLoginRequired = errors.New(LoginRequiredMessage)

ErrLoginRequired is a sentinel error used to signal that authentication is required.

Functions

func MapToRaw

func MapToRaw(m map[string]any) json.RawMessage

func NewLoginRequiredResult added in v0.47.5

func NewLoginRequiredResult() *mcpgo.CallToolResult

NewLoginRequiredResult creates a CallToolResult with isError=true for authentication failures. This returns a proper MCP tool result instead of a JSON-RPC error, providing a better user experience for AI agents.

func NewServer

func NewServer(cfg Config) *mcpserver.MCPServer

NewServer constructs an MCP server exposing IVCAP tools.

func Register added in v0.50.1

func Register(t BuiltInTool)

Register adds a built-in tool. Registering the same name twice is a programming error.

func ServeStdioWithLogging added in v0.47.5

func ServeStdioWithLogging(s *server.MCPServer, logDir string) (string, error)

ServeStdioWithLogging starts an MCP server in STDIO mode with JSON-RPC logging enabled. It returns the path to the log file.

Types

type BuiltInTool added in v0.50.1

type BuiltInTool struct {
	Tool    mcp.Tool
	Handler server.ToolHandlerFunc
	// ReadOnly is true if the tool only reads: it never changes data on the platform.
	ReadOnly bool
	// Instruction is an optional line of server instructions that tells the model when to use the tool.
	Instruction string
}

BuiltInTool describes a tool that the server always offers. The server derives everything else from these descriptors: the tools/list entries, their order, the session filter, the server instructions and the search index.

func GenomeImportTool added in v0.50.1

func GenomeImportTool(fn GenomeImportFunc) BuiltInTool

GenomeImportTool returns the genome_import tool. The CLI supplies fn, which runs the import.

func GenomeListTool added in v0.50.1

func GenomeListTool(fn GenomeListFunc) BuiltInTool

GenomeListTool returns the genome_list tool. The CLI supplies fn, which runs the listing.

type Config

type Config struct {
	Logger *log.Logger

	// Version is reported to MCP clients as the server's version (serverInfo.version).
	// The CLI should set this to match the ivcap-cli build version.
	Version string

	// ToolSchema is the schema URN prefix used when discovering tool aspects.
	ToolSchema string

	// TimeoutSec is used both for adapter construction and request timeouts.
	TimeoutSec int

	// ChunkSize is used by artifact uploads.
	ChunkSize int64

	// CreateAdapter must return an authenticated adapter.
	CreateAdapter func(timeoutSec int) (*a.Adapter, error)

	// WithLogging enables JSON-RPC request/response logging to a file.
	WithLogging bool

	// LogDir specifies the directory for MCP log files (defaults to /tmp).
	LogDir string
}

Config provides CLI-owned dependencies and settings to the MCP server.

Note: the MCP server itself lives in pkg/ so it does not depend on cmd/. Any CLI-specific concerns (config files, flags, env var resolution) should be handled by cmd/ and injected here.

type GenomeImportArgs added in v0.50.1

type GenomeImportArgs struct {
	Accession       string   `json:"accession"`
	Include         []string `json:"include,omitempty"`
	Chromosomes     []string `json:"chromosomes,omitempty"`
	AssemblyVersion string   `json:"assembly_version,omitempty"`
	Name            string   `json:"name,omitempty"`
	Policy          string   `json:"policy,omitempty"`
	License         string   `json:"license,omitempty"`
}

GenomeImportArgs are the arguments of the genome_import tool.

type GenomeImportFunc added in v0.50.1

type GenomeImportFunc func(ctxt context.Context, adapter *a.Adapter, args GenomeImportArgs) (any, error)

GenomeImportFunc imports one NCBI genome into IVCAP and returns a JSON-serialisable result. Nothing may be written to stdout: in STDIO mode it carries the MCP protocol.

type GenomeListArgs added in v0.50.1

type GenomeListArgs struct {
	Limit int    `json:"limit,omitempty"`
	Page  string `json:"page,omitempty"`
}

GenomeListArgs are the arguments of the genome_list tool.

type GenomeListFunc added in v0.50.1

type GenomeListFunc func(ctxt context.Context, adapter *a.Adapter, args GenomeListArgs) (any, error)

GenomeListFunc lists the genomes imported into IVCAP and returns a JSON-serialisable result.

type JobWaitResult added in v0.47.5

type JobWaitResult struct {
	JobID      string
	Status     string
	Result     map[string]any
	IsComplete bool
	Message    string
}

JobWaitResult encapsulates the result of waiting for a job with timeout

type ToolDefinition

type ToolDefinition struct {
	Name        string         `json:"name"`
	Description string         `json:"description"`
	Schema      map[string]any `json:"fn_schema"`
}

Jump to

Keyboard shortcuts

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