Class

ModelContextProtocol

ModelContextProtocol(mcp)

Constructor

# new ModelContextProtocol(mcp)

Encapsulates a configured FastMCP instance and exposes factory utilities via a static Builder for constructing MCPs with tools, versioning, and naming semantics.

A thin wrapper around FastMCP providing a typed interface for model-centric protocols.

sequenceDiagram participant Dev as Developer participant B as ModelContextProtocol.Builder participant MCP as FastMCP participant Proto as ModelContextProtocol Dev->>B: setName()/setVersion()/addTool() Dev->>B: build() B->>MCP: new FastMCP({ name, version }) B->>MCP: addTool(tool...) B->>Proto: new ModelContextProtocol(MCP) B-->>Dev: ModelContextProtocol
Parameters:
Name Type Description
mcp FastMCP.<Auth>

The underlying FastMCP instance used to register and run tools.

View Source mcp/ModelContextProtocol.ts, line 146

Example
// Using the builder
const protocol = ModelContextProtocol.builder
  .setName("Validator")
  .setVersion("1.2.3")
  .addTool({ name: "ping", description: "", parameters: z.any(), execute: async () => "pong" })
  .build();

Classes

ModelContextProtocol

Encapsulates a configured FastMCP instance and exposes factory utilities via a static Builder for constructing MCPs with tools, versioning, and naming semantics.

Members

# Builder

Exposes the builder type to consumers to enable typed construction of ModelContextProtocol instances.

Alias to the inner Builder class for external access.

View Source mcp/ModelContextProtocol.ts, line 163

# log

Uses the Logging facility to create a context-aware Logger bound to this instance.

Lazily obtains a logger instance for this protocol wrapper.

View Source mcp/ModelContextProtocol.ts, line 153

# static Builder

Exposes the builder type to consumers to enable typed construction of ModelContextProtocol instances.

Alias to the inner Builder class for external access.

View Source mcp/ModelContextProtocol.ts, line 243

# static builder

Creates a new builder to fluently configure and construct a ModelContextProtocol.

Factory accessor for a new Builder instance.

View Source mcp/ModelContextProtocol.ts, line 169

Methods

# protected log() → {Logger}

Uses the Logging facility to create a context-aware Logger bound to this instance.

Lazily obtains a logger instance for this protocol wrapper.

View Source mcp/ModelContextProtocol.ts, line 238

A logger instance for this class.

Logger

# static builder() → {Builder}

Creates a new builder to fluently configure and construct a ModelContextProtocol.

Factory accessor for a new Builder instance.

View Source mcp/ModelContextProtocol.ts, line 250

A new builder instance.

Builder

# static validateVersion(version) → {string}

Utility wrapper around the module-level validateVersion to keep a typed validator close to the class API.

Validates a semantic version string.

Parameters:
Name Type Description
version string

The version string to validate.

View Source mcp/ModelContextProtocol.ts, line 178

The normalized semantic version string.

string