Elysia MCP Adapterelysia-mcp-adapter
API Reference

Route-backed Tools

TypeScript contracts for route exposure, route matching, invocation inputs, and route operations.

Route-backed primitives are configured through the route's mcp option. Tools are the default route kind; resources and prompts require explicit metadata.

Route option

type McpRouteOptions =
  | false
  | {
      expose?: boolean
      kind?: 'tool' | 'resource' | 'prompt'
      name?: string
      title?: string
      description?: string
      inputSchema?: unknown
      outputSchema?: unknown
      annotations?: McpToolAnnotations
      icons?: McpIcon[]
      resource?: McpRouteResourceOptions
      prompt?: McpRoutePromptOptions
      marshal?: McpResponseMarshalOptions
    }
app.post('/reports', createReport, {
  body: t.Object({ range: t.String() }),
  detail: { operationId: 'reports.create' },
  mcp: {
    expose: true,
    annotations: { destructiveHint: false }
  }
})

false and { expose: false } remove a route from MCP discovery. inputSchema and outputSchema override inferred Elysia schemas only for MCP.

Route matching

type McpRouteMatcher =
  | string
  | RegExp
  | {
      method?: HTTPMethod | HTTPMethod[]
      path: string | RegExp
    }

Matchers are used by allowedRoutes and excludedRoutes. String paths support the adapter's exact and wildcard matching rules; object matchers also constrain HTTP methods.

Inspected route operation

McpRouteOperation is supplied to operationNameResolver and schema mapping callbacks.

Prop

Type

Invocation input

The adapter converts tool arguments into the internal Elysia request using this envelope. The default inputMode: 'envelope' preserves these boundaries; flatten merges compatible properties.

Prop

Type

Invocation context

Prop

Type

Tool result

A route response is normalized to this MCP result shape after Elysia response mapping completes.

Prop

Type

For route discovery and OpenAPI reuse, see Route-backed Tools.

On this page