getTime
Retrieve the current server time from the Example MCP Server to synchronize applications or check system time.
Instructions
Get the current server time
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "getTime"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- index.js:46-51 (handler)The handler function for the 'getTime' tool. It generates the current date in ISO format and returns it as text content.
async () => { const now = new Date().toISOString(); return { content: [{ type: "text", text: now }], }; } - index.js:45-45 (schema)Input schema for 'getTime' tool using Zod. Empty object indicates no input parameters are required.
{}, - index.js:42-52 (registration)Registration of the 'getTime' tool on the MCP server using server.tool(). Includes name, description, schema, and handler.
server.tool( "getTime", "Get the current server time", {}, async () => { const now = new Date().toISOString(); return { content: [{ type: "text", text: now }], }; } );