get_hostname
Retrieve the hostname of the machine running the Local Utilities MCP Server to identify the system in network operations.
Instructions
Returns the hostname of the machine running the MCP server.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/mcp/hostname.ts:16-27 (handler)The anonymous async handler function that implements the core logic of the 'get_hostname' tool. It calls getHostname() to retrieve the system hostname and returns it formatted as MCP text content.async () => { // Note: Error handling is simplified; the MCP SDK handles basic errors. // More complex tools might still need try/catch. const hostname = getHostname(); return { content: [{ type: "text", // Return plain text for simple values text: hostname }] }; }
- src/mcp/hostname.ts:12-29 (registration)The registerHostnameTool function that registers the 'get_hostname' MCP tool on the server, specifying the tool name, description, and handler function.export function registerHostnameTool(server: McpServer): void { server.tool( "get_hostname", "Returns the hostname of the machine running the MCP server.", async () => { // Note: Error handling is simplified; the MCP SDK handles basic errors. // More complex tools might still need try/catch. const hostname = getHostname(); return { content: [{ type: "text", // Return plain text for simple values text: hostname }] }; } ); }
- src/mcp/hostname.ts:8-10 (helper)Helper utility function that retrieves the hostname using Node.js 'os' module.export function getHostname(): string { return os.hostname(); }
- src/index.ts:19-19 (registration)Invocation of registerHostnameTool during server initialization, effectively registering the tool.registerHostnameTool(server);