mcpserver

package
v1.7.15 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	AllTools             = Tools{ListProjectsTool, GetProjectTool}
	AllResources         = Resources{}
	AllResourceTemplates = ResourceTemplates{ProjectContentResource}
	AllPrompts           = Prompts{ProjectPrompt}
)
View Source
var ExampleTool = &Tool{
	Name:        "example_mcp_server",
	Description: "Returns a random integer",
	Args:        util.FieldDescs{{Key: "max", Description: "Maximum possible random int (exclusive), defaults to 100"}},
	Fn:          exampleHandler,
}
View Source
var GetProjectTool = &Tool{
	Name:        "get_project",
	Description: "Get details of a specific project managed by " + util.AppName,
	Args: util.FieldDescs{
		{Key: "id", Description: "Optional project id. If omitted, all projects will be returned"},
	},
	Fn: getProjectHandler,
}
View Source
var ListProjectsTool = &Tool{
	Name:        "list_projects",
	Description: "List the projects managed by " + util.AppName,
	Fn:          listProjectsHandler,
}
View Source
var ProjectContentResource = &ResourceTemplate{
	Name:        "project_content",
	Description: "Get details of a specific file within a project managed by " + util.AppName,
	URI:         fmt.Sprintf(uriTemplate, "{id}", "{path*}"),
	Args: util.FieldDescs{
		{Key: "id", Description: "Project ID", Type: "string"},
		{Key: "path", Description: "Path to the file within the project"},
	},
	Fn: projectContentHandler,
}
View Source
var ProjectPrompt = &Prompt{
	Name:        "project_usage",
	Description: "A simple prompt that helps the system build, test, and work with an application managed by Project Forge" + util.AppName,
	Content:     `This application is written using Go, and is a web application managed by Project Forge.`,
}
View Source
var ResourceTemplateArgs = util.FieldDescs{{Key: "uri", Description: "URI to request", Type: "string"}}

Functions

func AddDefaultTools added in v1.7.12

func AddDefaultTools(ts ...*Tool)

func ClearDefaultTools added in v1.7.12

func ClearDefaultTools()

func ResultString added in v1.7.15

func ResultString(r any) string

func UsageCLI added in v1.7.12

func UsageCLI() string

func UsageHTTP added in v1.7.12

func UsageHTTP() string

func WireLibrary added in v1.7.15

func WireLibrary(s *Server, as *app.State, logger util.Logger) error

Types

type Prompt added in v1.7.14

type Prompt struct {
	Name        string `json:"name"`
	Description string `json:"description,omitempty"`
	Icon        string `json:"icon,omitempty"`
	Content     string `json:"content,omitempty"`
}

func NewStaticPrompt added in v1.7.14

func NewStaticPrompt(name string, description string, content string) *Prompt

func (*Prompt) Handler added in v1.7.14

func (p *Prompt) Handler(as *app.State, logger util.Logger) server.PromptHandlerFunc

func (*Prompt) IconSafe added in v1.7.14

func (p *Prompt) IconSafe() string

func (*Prompt) ToMCP added in v1.7.14

func (p *Prompt) ToMCP() (mcp.Prompt, error)

type PromptHandler added in v1.7.14

type PromptHandler func(ctx context.Context, as *app.State, req mcp.GetPromptRequest, args util.ValueMap, logger util.Logger) (string, error)

type Prompts added in v1.7.14

type Prompts []*Prompt

func (Prompts) Get added in v1.7.14

func (r Prompts) Get(n string) *Prompt

type Resource added in v1.7.14

type Resource struct {
	Name        string `json:"name"`
	Description string `json:"description,omitempty"`
	Icon        string `json:"icon,omitempty"`
	URI         string `json:"uri"`
	MIMEType    string `json:"mimeType"`
	Content     string `json:"content"`
	Binary      bool   `json:"binary,omitempty"`
}

func NewBlobResource added in v1.7.14

func NewBlobResource(name string, description string, uri string, mimeType string, content []byte) *Resource

func NewResourceTemplate added in v1.7.15

func NewResourceTemplate(name string, description string, uri string, mimeType string, content string) *Resource

func NewTextResource added in v1.7.14

func NewTextResource(name string, description string, uri string, mimeType string, content string) *Resource

func (*Resource) Extension added in v1.7.14

func (r *Resource) Extension() string

func (*Resource) Handler added in v1.7.14

func (r *Resource) Handler(as *app.State, logger util.Logger) server.ResourceHandlerFunc

func (*Resource) IconSafe added in v1.7.14

func (r *Resource) IconSafe() string

func (*Resource) ToMCP added in v1.7.14

func (r *Resource) ToMCP() (mcp.Resource, error)

type ResourceTemplate added in v1.7.15

type ResourceTemplate struct {
	Name        string                  `json:"name"`
	Description string                  `json:"description,omitempty"`
	Icon        string                  `json:"icon,omitempty"`
	URI         string                  `json:"uri"`
	MIMEType    string                  `json:"mimeType"`
	Args        util.FieldDescs         `json:"args,omitempty"`
	Fn          ResourceTemplateHandler `json:"-"`
}

func (*ResourceTemplate) Handler added in v1.7.15

func (*ResourceTemplate) IconSafe added in v1.7.15

func (r *ResourceTemplate) IconSafe() string

func (*ResourceTemplate) ToMCP added in v1.7.15

type ResourceTemplateHandler added in v1.7.15

type ResourceTemplateHandler func(ctx context.Context, as *app.State, req mcp.ReadResourceRequest, args util.ValueMap, logger util.Logger) (string, string, any, error)

type ResourceTemplates added in v1.7.15

type ResourceTemplates []*ResourceTemplate

func (ResourceTemplates) Get added in v1.7.15

type Resources added in v1.7.14

type Resources []*Resource

func (Resources) Get added in v1.7.14

func (r Resources) Get(n string) *Resource

type Server

type Server struct {
	MCP               *server.MCPServer `json:"-"`
	State             *app.State        `json:"-"`
	Resources         Resources         `json:"resources"`
	ResourceTemplates ResourceTemplates `json:"resourceTemplates"`
	Prompts           Prompts           `json:"prompts"`
	Tools             Tools             `json:"tools"`
	HTTP              http.Handler      `json:"-"`
}

func CurrentDefaultServer added in v1.7.13

func CurrentDefaultServer() *Server

func GetDefaultServer added in v1.7.12

func GetDefaultServer(ctx context.Context, as *app.State, logger util.Logger) (*Server, error)

func NewServer

func NewServer(ctx context.Context, as *app.State, logger util.Logger) (*Server, error)

func (*Server) AddPrompts added in v1.7.14

func (s *Server) AddPrompts(as *app.State, logger util.Logger, prompts ...*Prompt) error

func (*Server) AddResourceTemplates added in v1.7.15

func (s *Server) AddResourceTemplates(as *app.State, logger util.Logger, resources ...*ResourceTemplate) error

func (*Server) AddResources added in v1.7.14

func (s *Server) AddResources(as *app.State, logger util.Logger, resources ...*Resource) error

func (*Server) AddTools

func (s *Server) AddTools(as *app.State, logger util.Logger, tools ...*Tool) error

func (*Server) ServeCLI added in v1.7.12

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

func (*Server) ServeHTTP added in v1.7.12

func (s *Server) ServeHTTP(ctx context.Context, w http.ResponseWriter, r *http.Request, logger util.Logger)

type Tool

type Tool struct {
	Name        string          `json:"name"`
	Description string          `json:"description,omitempty"`
	Icon        string          `json:"icon,omitempty"`
	Args        util.FieldDescs `json:"args,omitempty"`
	Fn          ToolHandler     `json:"-"`
}

func (*Tool) Handler

func (t *Tool) Handler(as *app.State, logger util.Logger) server.ToolHandlerFunc

func (*Tool) IconSafe added in v1.7.12

func (t *Tool) IconSafe() string

func (*Tool) ToMCP

func (t *Tool) ToMCP() (mcp.Tool, error)

type ToolHandler

type ToolHandler func(ctx context.Context, as *app.State, req mcp.CallToolRequest, args util.ValueMap, logger util.Logger) (any, error)

type Tools added in v1.6.18

type Tools []*Tool

func (Tools) Get added in v1.7.12

func (t Tools) Get(n string) *Tool

Jump to

Keyboard shortcuts

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