mcp_server

package
v1.9.6-beta Latest Latest
Warning

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

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

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 {
	*server.MCPServer
	// contains filtered or unexported fields
}

func (*Handler) ServeHTTP

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

type ITool

type ITool interface {
	Tool() server.ServerTool
}

func NewTool

func NewTool(name string, uri string, method string, contentType string, params map[string]*Param, opts ...mcp.ToolOption) 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 *server.MCPServer)

type Tool

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

func (*Tool) Tool

func (t *Tool) Tool() server.ServerTool

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