Skip to main content

Module dispatch

Module dispatch 

Source
Expand description

MCP method dispatch using command pattern.

This module implements a command pattern for MCP method dispatch, replacing string matching with type-safe enum variants.

§Architecture

McpMethod (enum)
  ├── Initialize
  ├── ListTools
  ├── CallTool
  ├── ListResources
  ├── ReadResource
  ├── ListPrompts
  ├── GetPrompt
  ├── Ping
  └── Unknown(String)

§Open/Closed Principle

To add a new method:

  1. Add a variant to McpMethod
  2. Update [McpMethod::from_str] parsing
  3. Add handler in [McpServer::dispatch_method]

The dispatch logic is centralized and type-safe.

Enums§

McpMethod
MCP method identifier.