mcp

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2025 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package mcp provides a Terminal implementation for the MCP (Model Context Protocol) server.

This tool enables execution of terminal commands on both local and remote (SSH) hosts, and integrates with the MCP tool registry via JSON-RPC. It supports secure credential loading through Viant's scy/cred system.

Key Components:

  • Target: Describes the host and credentials for remote access.
  • Command: Represents a list of shell commands to execute.
  • Terminal: Manages remote and local terminal sessions, supporting concurrent usage.

Features:

  • Local and remote terinal command execution
  • Secure SSH credential handling via scy.Resource and cred.SSH
  • JSON-RPC integration for remote tool invocation

Registration:

Use Register to bind the tool to a MCP server:

import "github.com/viant/mcp-tools/mcp"

err := mcp.Register(implementer)

This registers the tool under the "terminal" name.

Example:

cmd := &mcp.Command{
    Target: &mcp.Target{Host: "remote-host", Secret: ...},
    Commands: []string{"ls", "pwd"},
}

result, err := terminalTool.Call(ctx, cmd)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(implementer *server.DefaultImplementer, options ...runner.Option) error

Register binds the Terminal tool to the MCP server

Types

type Command

type Command struct {
	Target   *Target           `json:"target,omitempty"`
	Commands []string          `json:"commands"`
	Env      map[string]string `json:"env,omitempty"`
}

Command represents a request to run shell commands on a target

type Target

type Target struct {
	Host   string        `json:"host"`
	Secret *scy.Resource `json:"secret"`
}

Target specifies a host and its associated credentials

type Terminal

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

func New

func New(options ...runner.Option) (*Terminal, error)

New creates a new Terminal instance

func (*Terminal) Call

func (t *Terminal) Call(ctx context.Context, input *Command) (*schema.CallToolResult, *jsonrpc.Error)

func (*Terminal) TargetTerminal

func (t *Terminal) TargetTerminal(ctx context.Context, target *Target) (*gosh.Service, error)

Jump to

Keyboard shortcuts

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