mcpserver

package
v1.7.14 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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: projectsHandler,
}
View Source
var ListProjectsTool = &Tool{
	Name:        "list_projects",
	Description: "List the projects managed by " + util.AppName,
	Fn:          projectsHandler,
}
View Source
var ProjectForgeResource = &Resource{
	Name:        "projectforge",
	Description: "Description, purpose, and basic usage instructions for Project Forge (this MCP server)",
	URI:         "project://projectforge",
	MIMEType:    "text/markdown",
	Content:     "# Project Forge\n\n[Project Forge](https://projectforge.dev) is an application that allows you to generate, manage, and grow web applications built using the Go programming language.",
}
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,
	Fn: func(ctx context.Context, as *app.State, req mcp.GetPromptRequest, args util.ValueMap, logger util.Logger) (string, error) {
		return `This application is written using Go, and is a web application managed by Project Forge.`, nil
	},
}

Functions

func AddDefaultTools added in v1.7.12

func AddDefaultTools(ts ...*Tool)

func ClearDefaultTools added in v1.7.12

func ClearDefaultTools()

func UsageCLI added in v1.7.12

func UsageCLI() string

func UsageHTTP added in v1.7.12

func UsageHTTP() string

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"`
	Args        util.FieldDescs `json:"args,omitempty"`
	Fn          PromptHandler   `json:"-"`
}

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 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 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"`
	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) 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) (string, 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