# 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.
Parameters:
| Name | Type | Description |
|---|---|---|
mcp |
FastMCP.<Auth>
|
The underlying FastMCP instance used to register and run tools. |
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.
# log
Uses the Logging facility to create a context-aware Logger bound to this instance.
Lazily obtains a logger instance for this protocol wrapper.
# static Builder
Exposes the builder type to consumers to enable typed construction of ModelContextProtocol instances.
Alias to the inner Builder class for external access.
# static builder
Creates a new builder to fluently configure and construct a ModelContextProtocol.
Factory accessor for a new Builder instance.
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.
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.
A new builder instance.
# 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. |
The normalized semantic version string.
string