MCP
Functions
Public API reference for the MCP extension
| Function | Description |
|---|
NewExtension(opts ...ConfigOption) forge.Extension | Create the MCP extension with functional options |
NewExtensionWithConfig(config Config) forge.Extension | Create the MCP extension with a complete config |
DefaultConfig() Config | Returns the default configuration |
| Method | Description |
|---|
RegisterTool(tool Tool) error | Register a tool with name, description, schema, and handler |
ListTools() []Tool | List 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 |
| Method | Description |
|---|
RegisterResource(resource Resource, reader ResourceReader) error | Register a resource with a reader function |
ListResources() []Resource | List all registered resources |
ReadResource(ctx, uri) (*ResourceContents, error) | Read a resource by URI |
| Method | Description |
|---|
RegisterPrompt(prompt Prompt, generator PromptGenerator) error | Register a prompt template with a generator function |
ListPrompts() []Prompt | List all registered prompts |
GetPrompt(ctx, name, arguments) ([]PromptMessage, error) | Generate prompt messages from a template |
| Method | Description |
|---|
GetServerInfo() ServerInfo | Get server name, version, and capabilities |
| Function | Description |
|---|
AuthMiddleware(config, logger) forge.PureMiddleware | Create authentication middleware for MCP endpoints |
RateLimitMiddleware(config, logger, metrics) forge.PureMiddleware | Create rate limiting middleware |
| Field | Type | Purpose |
|---|
Name | string | Tool identifier |
Description | string | Human-readable description for AI agents |
InputSchema | JSONSchema | JSON Schema describing expected arguments |
| Field | Type | Purpose |
|---|
URI | string | Resource identifier (e.g. file:///path) |
Name | string | Display name |
Description | string | Human-readable description |
MimeType | string | Content type |
| Field | Type | Purpose |
|---|
Name | string | Prompt identifier |
Description | string | Human-readable description |
Arguments | []PromptArgument | Typed arguments the prompt accepts |
| Field | Type | Purpose |
|---|
Role | string | Message role (user, assistant, system) |
Content | Content | Message content (text, image, or resource) |
How is this guide?