Integrations

MCP Integration

Connect AI assistants to your Redelay application via Model Context Protocol.

MCP Integration

The MCP module turns your Redelay application into an MCP server — any AI assistant that speaks the Model Context Protocol can discover your modules, validate flows, scaffold code, and invoke API operations.

How it works

text
┌──────────────┐   JSON-RPC / HTTP    ┌─────────────────────────┐
│  AI Client   │ ──────────────────▶  │  Redelay MCP Server     │
│  (VS Code,   │                      │  POST /mcp              │
│   Claude,    │ ◀──────────────────  │                         │
│   Cursor)    │   tools/resources    │  ┌─ Introspection (9)   │
└──────────────┘                      │  ├─ Dev tools (5)       │
                                      │  ├─ Route tools (auto)  │
                                      │  └─ Module tools (ext)  │
                                      └─────────────────────────┘
  1. Introspection tools — list_modules, describe_module, list_flowdsl_nodes, describe_flowdsl_node, list_events, describe_event, list_packets, describe_packet, search_redelay
  2. Developer tools — validate_flowdsl, validate_module, scaffold_module, list_api_routes, explain_flowdsl_node
  3. Route tools — every HTTP route from RoutesProvider modules becomes a callable tool
  4. Module-contributed tools — any module implementing MCPProvider adds its own tools

Setup

1. Enable the MCP module

go
import _ "github.com/redelay/go-framework/modules/mcp"

The module auto-mounts at POST /mcp.

2. Connect your IDE

VS Code — create .vscode/mcp.json in your project:

json
{
  "servers": {
    "my-app": {
      "type": "http",
      "url": "http://localhost:8000/mcp"
    }
  }
}

Claude Desktop — add to claude_desktop_config.json:

json
{
  "mcpServers": {
    "my-app": {
      "transport": "http",
      "url": "http://localhost:8000/mcp"
    }
  }
}

3. Verify connection

Once connected, your AI assistant can call tools like list_modules to explore the application.

Extending MCP from your module

Implement MCPProvider to contribute tools and resources:

go
func (m *Module) MCPTools() []modules.MCPTool {
    return []modules.MCPTool{
        {
            Name:        "search_products",
            Description: "Search products by name or category",
            InputSchema: map[string]any{
                "type":     "object",
                "required": []string{"query"},
                "properties": map[string]any{
                    "query": map[string]any{
                        "type":        "string",
                        "description": "Search term",
                    },
                    "category": map[string]any{
                        "type":        "string",
                        "description": "Filter by category",
                    },
                },
            },
            Handler: func(ctx context.Context, args map[string]any) (any, error) {
                query, _ := args["query"].(string)
                return m.service.Search(ctx, query)
            },
        },
    }
}

func (m *Module) MCPResources() []modules.MCPResource { return nil }

Guidelines for MCP tools

  • Name — use snake_case, prefix with your module name for uniqueness (e.g. products_search)
  • Description — write for AI consumption: explain when to use the tool, not just what it does
  • InputSchema — use JSON Schema with description on each property so the AI knows what to pass
  • Handler — return structured data (maps, slices, structs); the MCP server serializes it as JSON

Exposing resources

Resources are read-only data that AI clients can fetch by URI:

go
func (m *Module) MCPResources() []modules.MCPResource {
    return []modules.MCPResource{
        {
            URI:         "products://catalog",
            Name:        "product-catalog",
            MimeType:    "application/json",
            Description: "Full product catalog with pricing and availability",
            Handler: func(ctx context.Context) (any, error) {
                return m.service.FullCatalog(ctx)
            },
        },
    }
}

Protocol

The MCP server implements the Streamable HTTP transport (protocol version 2025-03-26):

MethodDescription
initializeHandshake — returns protocol version, capabilities, server info
notifications/initializedAccepted silently (202)
pingReturns {}
tools/listReturns {tools: [...]}
tools/callReturns {content: [{type: "text", text: "..."}]}
resources/listReturns {resources: [...]}
resources/readReturns {contents: [{uri, mimeType, text}]}

Tool reference

Introspection tools

ToolParametersDescription
list_modules—Summary of every module with event/route/node counts
describe_modulenameFull IR for a single module
list_flowdsl_nodeskind?, module?All FlowDSL nodes, optionally filtered
describe_flowdsl_nodeidFull node spec with settings schema and ports
list_events—All events with entity type, action, topic
describe_eventnameFull event definition with payload schema
list_packets—All packet/schema definitions
describe_packetnameFull packet with fields
search_redelayquery, limit?Keyword search across all entities

Developer tools

ToolParametersDescription
validate_flowdslyamlParse and validate FlowDSL YAML (codes FDL001–FDL062)
validate_moduleyamlValidate module YAML (codes MV001–MV072)
scaffold_moduleyaml, package?, framework_module?Generate Go module code from YAML
list_api_routesmodule?HTTP routes with request types and security
explain_flowdsl_nodeidHuman-friendly explanation with usage snippet