Skip to main content

MCP

VEF has first-class support for MCP (Model Context Protocol) server integration.

Runtime Behavior

The MCP module is always part of the boot sequence, but the MCP server only activates when:

ConfigMeaning
vef.mcp.enabled = trueMCP server and endpoint become active

When enabled, the HTTP endpoint is mounted at:

/mcp

What The Module Provides

When enabled, the MCP module provides:

Runtime pieceMeaning
MCP server constructionbuilds the MCP server instance
HTTP handleradapts the MCP server to HTTP
app middlewaremounts /mcp into the Fiber app
built-in tooldatabase_query
built-in promptsdata-dict-assistant, naming-master

The module does not currently ship built-in static MCP resources or built-in resource templates.

Public Provider Interfaces

The public mcp package exposes these provider interfaces:

InterfacePurpose
mcp.ToolProviderregister MCP tools
mcp.ResourceProviderregister static MCP resources
mcp.ResourceTemplateProviderregister MCP resource templates
mcp.PromptProviderregister MCP prompts

Supporting definition types:

TypePurpose
mcp.ToolDefinitiontool + handler
mcp.ResourceDefinitionstatic resource + handler
mcp.ResourceTemplateDefinitionresource template + handler
mcp.PromptDefinitionprompt + handler
mcp.ServerInfoserver name, version, and instructions

Dependency-Injection Extension Points

Applications can register custom MCP capabilities through:

HelperRegisters into
vef.ProvideMCPTools(...)vef:mcp:tools
vef.ProvideMCPResources(...)vef:mcp:resources
vef.ProvideMCPResourceTemplates(...)vef:mcp:templates
vef.ProvideMCPPrompts(...)vef:mcp:prompts
vef.SupplyMCPServerInfo(...)optional server info override

Built-In Tool: database_query

The built-in MCP tool currently exposed by the framework is:

Tool namePurpose
database_queryexecute a parameterized SQL query and return JSON rows

Input arguments:

ArgumentMeaning
sqlSQL query string using ? placeholders
paramsoptional positional parameters

Behavior notes:

  • results are returned as JSON text content
  • UTF-8 byte slices are converted to strings before JSON encoding
  • the query runs through mcp.DBWithOperator(...), so the current MCP principal is bound as the operator when possible

Built-In Prompts

The framework currently registers these built-in prompts:

Prompt namePurpose
data-dict-assistantdata dictionary management assistant
naming-masternaming assistant for code and database naming

Schema Helpers

The public mcp package also provides JSON Schema helpers for MCP tool and prompt contracts:

HelperPurpose
mcp.SchemaFor[T]()generate schema from a generic type
mcp.SchemaOf(v)generate schema from a runtime value
mcp.MustSchemaFor[T]()panic-on-error schema generation
mcp.MustSchemaOf(v)panic-on-error schema generation

These helpers are suitable for tool input schemas.

Authentication

When vef.mcp.require_auth = true, the HTTP handler applies Bearer-token verification through the application auth manager.

That matters because the built-in database_query tool can already inspect live database state.

Minimal Example

package appmcp

import (
"github.com/coldsmirk/vef-framework-go"
"github.com/coldsmirk/vef-framework-go/mcp"
)

var Module = vef.Module(
"app:mcp",
vef.ProvideMCPTools(NewToolProvider),
vef.SupplyMCPServerInfo(&mcp.ServerInfo{
Name: "my-app",
Version: "v1.0.0",
Instructions: "Internal assistant surface for My App",
}),
)

In many apps, the first step is even smaller:

var Module = vef.Module(
"app:mcp",
vef.ProvideMCPTools(NewToolProvider),
)

What To Document For Your Own App

If you expose custom MCP features, document:

  • which tools are registered
  • whether auth is required
  • which domain data your resources or prompts expose
  • whether any prompt or tool performs side effects

Next Step

Read Extension Points for the full list of MCP-related DI groups and helpers.