Optionaldescription?: stringAn optional human-readable description of what this implementation does.
This can be used by clients or servers to provide context about their purpose and capabilities. For example, a server might describe the types of resources or tools it provides, while a client might describe its intended use case.
Optionalicons?: { mimeType?: string; sizes?: string[]; src: string; theme?: "light" | "dark" }[]Optional set of sized icons that the client can display in a user interface.
Clients that support rendering icons MUST support at least the following MIME types:
image/png - PNG images (safe, universal compatibility)image/jpeg (and image/jpg) - JPEG images (safe, universal compatibility)Clients that support rendering icons SHOULD also support:
image/svg+xml - SVG images (scalable but requires security precautions)image/webp - WebP images (modern, efficient format)Intended for programmatic or logical use, but used as a display name in past specs or fallback
Optionaltitle?: stringIntended for UI and end-user contexts — optimized to be human-readable and easily understood, even by those unfamiliar with domain-specific terminology.
If not provided, the name should be used for display (except for Tool,
where annotations.title should be given precedence over using name,
if present).
OptionalwebsiteUrl?: stringAn optional URL of the website for this implementation.
Optionaloptions: ServerOptionsReadonlyserverThe underlying Server instance, useful for advanced operations like sending notifications.
ExperimentalAccess experimental features.
WARNING: These APIs are experimental and may change without notice.
Closes the connection.
Attaches to the given transport, starts it, and starts listening for messages.
The server object assumes ownership of the Transport, replacing any callbacks that have already been set, and expects that it is the only user of the Transport instance going forward.
Checks if the server is connected to a transport.
true if the server is connected
Registers a prompt with a config object and callback.
server.registerPrompt(
'review-code',
{
title: 'Code Review',
description: 'Review code for best practices',
argsSchema: z.object({ code: z.string() })
},
({ code }) => ({
messages: [
{
role: 'user' as const,
content: {
type: 'text' as const,
text: `Please review this code:\n\n${code}`
}
}
]
})
);
Registers a resource with a config object and callback.
For static resources, use a URI string. For dynamic resources, use a ResourceTemplate.
Registers a resource with a config object and callback.
For static resources, use a URI string. For dynamic resources, use a ResourceTemplate.
Registers a tool with a config object and callback.
server.registerTool(
'calculate-bmi',
{
title: 'BMI Calculator',
description: 'Calculate Body Mass Index',
inputSchema: z.object({
weightKg: z.number(),
heightM: z.number()
}),
outputSchema: z.object({ bmi: z.number() })
},
async ({ weightKg, heightM }) => {
const output = { bmi: weightKg / (heightM * heightM) };
return {
content: [{ type: 'text', text: JSON.stringify(output) }],
structuredContent: output
};
}
);
Sends a logging message to the client, if connected. Note: You only need to send the parameters object, not the entire JSON-RPC message.
Optional_meta?: {See MCP specification
for notes on _meta usage.
Optionalio.modelcontextprotocol/related-task?: { taskId: string }If specified, this request is related to the provided task.
OptionalprogressToken?: string | numberIf specified, the caller is requesting out-of-band progress notifications for this request (as represented by notifications/progress). The value of this parameter is an opaque token that will be attached to any subsequent notifications. The receiver is not obligated to provide these notifications.
The data to be logged, such as a string message or an object. Any JSON serializable type is allowed here.
The severity of this log message.
Optionallogger?: stringAn optional name of the logger issuing this message.
OptionalsessionId: stringOptional for stateless transports and backward compatibility.
Sends a prompt list changed event to the client, if connected.
Sends a resource list changed event to the client, if connected.
Sends a tool list changed event to the client, if connected.
High-level MCP server that provides a simpler API for working with resources, tools, and prompts. For advanced usage (like sending notifications or setting custom request handlers), use the underlying
Serverinstance available via theserverproperty.Example