Forge
1.x
Docs/Forge/Functions
Open

Reading1 min
Updated31 Jul 2026
Sourcev1/extensions/mcp/functions.mdx

Extension Entry Points01

FunctionDescription
NewExtension(opts ...ConfigOption) forge.ExtensionCreate the MCP extension with functional options
NewExtensionWithConfig(config Config) forge.ExtensionCreate the MCP extension with a complete config
DefaultConfig() ConfigReturns the default configuration

Server -- Tool Operations02

MethodDescription
RegisterTool(tool Tool) errorRegister a tool with name, description, schema, and handler
ListTools() []ToolList all registered tools
ExecuteTool(ctx, name, arguments) (*ToolResult, error)Execute a named tool with arguments
GenerateToolFromRoute(route) (*Tool, error)Generate a tool definition from a Forge HTTP route

Server -- Resource Operations03

MethodDescription
RegisterResource(resource Resource, reader ResourceReader) errorRegister a resource with a reader function
ListResources() []ResourceList all registered resources
ReadResource(ctx, uri) (*ResourceContents, error)Read a resource by URI

Server -- Prompt Operations04

MethodDescription
RegisterPrompt(prompt Prompt, generator PromptGenerator) errorRegister a prompt template with a generator function
ListPrompts() []PromptList all registered prompts
GetPrompt(ctx, name, arguments) ([]PromptMessage, error)Generate prompt messages from a template

Server -- Info05

MethodDescription
GetServerInfo() ServerInfoGet server name, version, and capabilities

Middleware06

FunctionDescription
AuthMiddleware(config, logger) forge.PureMiddlewareCreate authentication middleware for MCP endpoints
RateLimitMiddleware(config, logger, metrics) forge.PureMiddlewareCreate rate limiting middleware

Key Types07

Tool

FieldTypePurpose
NamestringTool identifier
DescriptionstringHuman-readable description for AI agents
InputSchemaJSONSchemaJSON Schema describing expected arguments

Resource

FieldTypePurpose
URIstringResource identifier (e.g. file:///path)
NamestringDisplay name
DescriptionstringHuman-readable description
MimeTypestringContent type

Prompt

FieldTypePurpose
NamestringPrompt identifier
DescriptionstringHuman-readable description
Arguments[]PromptArgumentTyped arguments the prompt accepts

PromptMessage

FieldTypePurpose
RolestringMessage role (user, assistant, system)
ContentContentMessage content (text, image, or resource)