ConduitMcp.Endpoint (ConduitMCP v0.9.0)

Copy Markdown View Source

Aggregates ConduitMcp.Component modules into a full MCP server.

The Endpoint implements the ConduitMcp.Server behaviour by generating all required callbacks at compile time from registered components. It also carries declarative configuration for rate limiting, message limiting, and authentication that transports auto-extract.

Example

defmodule MyApp.MCPServer do
  use ConduitMcp.Endpoint,
    name: "My Server",
    version: "1.0.0",
    rate_limit: [backend: MyApp.RateLimiter, limit: 60, scale: 60_000],
    message_rate_limit: [backend: MyApp.RateLimiter, limit: 50, scale: 300_000]

  component MyApp.Echo
  component MyApp.ReadUser
  component MyApp.CodeReviewPrompt
end

Then wire it up with a transport — the Endpoint config is auto-extracted:

{Bandit,
 plug: {ConduitMcp.Transport.StreamableHTTP, server_module: MyApp.MCPServer},
 port: 4001}

Options

  • :name — Server name for the MCP initialize response
  • :version — Server version for the MCP initialize response
  • :rate_limit — HTTP rate limiting config (same format as transport opts)
  • :message_rate_limit — Message-level rate limiting config
  • :auth — Authentication config (same format as transport opts)

How It Works

At compile time, the @before_compile hook:

  1. Validates all registered components (existence, uniqueness, types)
  2. Groups components by type (tool, resource, prompt)
  3. Generates all ConduitMcp.Server callbacks:
    • handle_list_tools/1, handle_call_tool/3
    • handle_list_resources/1, handle_read_resource/2
    • handle_list_prompts/1, handle_get_prompt/3
  4. Generates validation schema lookups for the existing validation pipeline
  5. Generates __endpoint_config__/0 for transport auto-extraction
  6. Generates __capabilities__/0 for selective capability advertisement

Because the Endpoint implements ConduitMcp.Server, it works with the existing ConduitMcp.Handler and all transports without modification.

Summary

Functions

Registers a component module with the endpoint.

Functions

component(module)

(macro)

Registers a component module with the endpoint.

The component must use ConduitMcp.Component and implement execute/2.

Examples

component MyApp.Echo
component MyApp.ReadUser
component MyApp.CodeReviewPrompt