mcpserver

package
v2.3.0 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2026 License: BSD-3-Clause Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultMaxResultBytes 是检查工具默认允许内联返回的最大字节数 / DefaultMaxResultBytes is the default maximum number of bytes returned inline by the inspect tool
	DefaultMaxResultBytes int64 = 2 << 20
	// DefaultMaxWriteBytes 是转换和提取工具默认允许写入的最大字节数 / DefaultMaxWriteBytes is the default maximum number of bytes written by conversion and extraction tools
	DefaultMaxWriteBytes = application.DefaultMaxOutputBytes
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Engine 执行格式检测、转换、校验和归档操作 / Engine performs format detection, conversion, validation, and archive operations
	Engine *application.Engine
	// Roots 保存受限模式公开的可读写根目录 / Roots stores readable and writable roots exposed in restricted mode
	Roots *application.RootSet
	// FilesystemMode 选择受限根目录路径或直接文件系统路径 / FilesystemMode selects confined root paths or direct filesystem paths
	FilesystemMode FilesystemMode
	// Logger 接收 MCP SDK 和服务器诊断信息 / Logger receives MCP SDK and server diagnostics
	Logger *slog.Logger
	// Version 是 MCP 实现公开的应用版本 / Version is the application version advertised by the MCP implementation
	Version string
	// MaxResultBytes 限制检查和归档列表工具的内联结果大小 / MaxResultBytes limits inline results from inspect and archive-list tools
	MaxResultBytes int64
	// MaxWriteBytes 限制转换或提取制品的合计写入大小 / MaxWriteBytes limits aggregate bytes written for converted or extracted artifacts
	MaxWriteBytes int64
}

Config 配置 MCP 序列化服务器的依赖、文件系统模式和资源限制 / Config configures dependencies, filesystem mode, and resource limits for an MCP serialization server

type FilesystemMode

type FilesystemMode string

FilesystemMode 控制 MCP 工具公开受限根目录路径还是直接文件系统路径 / FilesystemMode controls whether MCP tools expose confined root paths or direct filesystem paths

const (
	// FilesystemModeRestricted 将全部 MCP 文件操作限制在配置根目录内 / FilesystemModeRestricted confines all MCP file operations to configured roots
	FilesystemModeRestricted FilesystemMode = "restricted"
	// FilesystemModeUnrestricted 允许使用服务器进程账户可访问的直接路径 / FilesystemModeUnrestricted permits direct paths accessible to the server process account
	FilesystemModeUnrestricted FilesystemMode = "unrestricted"
)

type Server

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

Server 将应用引擎公开为带资源、提示和文件工具的 MCP 服务器 / Server exposes the application engine as an MCP server with resources, prompts, and file tools

func New

func New(config Config) (*Server, error)

New 校验配置并创建已注册工具、资源和提示的 MCP 服务器 New validates configuration and creates an MCP server with tools, resources, and prompts registered

func (*Server) MCPServer

func (s *Server) MCPServer() *mcp.Server

MCPServer 返回底层 SDK 服务器以供嵌入和测试 MCPServer returns the underlying SDK server for embedding and tests

func (*Server) Run

func (s *Server) Run(ctx context.Context) error

Run 通过标准输入输出传输运行 MCP 服务器直到上下文结束 Run serves MCP over standard input and output until the context ends

Jump to

Keyboard shortcuts

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