mcp_server

package
v1.9.8-beta Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2026 License: Apache-2.0 Imports: 11 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ServiceBasePath = "mcp/service"
	GlobalBasePath  = "mcp/global"
	AppBasePath     = "mcp/app"

	OpenGlobalMCPPath  = "/openapi/v1/global/mcp"
	OpenAppMCPPath     = "/openapi/v1/app/mcp"
	OpenServiceMCPPath = "/openapi/v1/service/mcp"
)

Functions

func DelServer

func DelServer(sid string)

func ServeHTTP

func ServeHTTP(w http.ResponseWriter, r *http.Request)

func SetServer

func SetServer(sid string, name string, version string, tools ...ITool)

func SetServerByOpenapi

func SetServerByOpenapi(sid, name, version, content string) error

Types

type API

type API struct {
	Path        string                 `json:"path"`
	Method      string                 `json:"method"`
	ContentType string                 `json:"content_type"`
	Summary     string                 `json:"summary"`
	Description string                 `json:"description"`
	Params      []*openapi3.Parameter  `json:"params"`
	Body        map[string]interface{} `json:"body"`
}

type BodyParam

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

func NewBodyParam

func NewBodyParam(contentType string) *BodyParam

func (*BodyParam) Encode

func (p *BodyParam) Encode() (string, error)

func (*BodyParam) Set

func (p *BodyParam) Set(k string, v interface{})

type ContentType

type ContentType string
const (
	ContentTypeJSON ContentType = "application/json"
	ContentTypeXML  ContentType = "application/xml"
	ContentTypeHTML ContentType = "text/html"
	ContentTypeText ContentType = "text/plain"
	ContentTypeForm ContentType = "application/x-www-form-urlencoded"
	ContentTypeFile ContentType = "multipart/form-data"
)

type Handler

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

func (*Handler) ServeHTTP

func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*Handler) Server

func (h *Handler) Server() *mcp.Server

type ITool

type ITool interface {
	// Tool 获取Tool
	Tool() *mcp.Tool
	Handler() mcp.ToolHandler
}

func NewTool

func NewTool(name string, description string, inputSchema any, uri string, method string, contentType string, params map[string]*Param) ITool

type MCPConfig

type MCPConfig struct {
	Type        TransportType     `json:"type"`
	URL         string            `json:"url"`
	Headers     map[string]string `json:"headers,omitempty"`
	AlwaysAllow []string          `json:"alwaysAllow,omitempty"`
}

func NewMCPConfig

func NewMCPConfig(typ TransportType, url string, headers map[string]string, alwaysAllow []string) *MCPConfig

func (*MCPConfig) ToString

func (c *MCPConfig) ToString(name string) string

type MCPInfo

type MCPInfo struct {
	Name        string
	Description string
	Apis        []*API
}

func ConvertMCPFromOpenAPI3Data

func ConvertMCPFromOpenAPI3Data(data []byte) (*MCPInfo, error)

type Param

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

func NewParam

func NewParam(position Position, required bool, description string) *Param

func (*Param) Description

func (p *Param) Description() string

func (*Param) Required

func (p *Param) Required() bool

type Position

type Position string
const (
	PositionHeader Position = "header"
	PositionBody   Position = "body"
	PositionQuery  Position = "query"
	PositionPath   Position = "path"
)

type Server

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

func DefaultMCPServer

func DefaultMCPServer() *Server

func NewServer

func NewServer() *Server

func (*Server) Del

func (s *Server) Del(id string)

func (*Server) Get

func (s *Server) Get(id string) (*Handler, bool)

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*Server) Set

func (s *Server) Set(id string, ser *mcp.Server)

type Tool

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

func (*Tool) Handler

func (t *Tool) Handler() mcp.ToolHandler

func (*Tool) Tool

func (t *Tool) Tool() *mcp.Tool

type TransportType

type TransportType string
const (
	TransportTypeStreamableHTTP TransportType = "streamable-http"
	TransportTypeSSE            TransportType = "sse"
)

Jump to

Keyboard shortcuts

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