Skip to main content
Glama

get_environment

Retrieve current server environment details including operating system, Node.js version, process info, CPU, memory usage, and hostname.

Instructions

Get information about the current server environment.

Returns:

  • Operating system details (platform, arch, release)

  • Node.js version

  • Server process info (PID, uptime, memory usage)

  • CPU information

  • Memory (total, free, used)

  • Network hostname

This tool does not require any parameters. No sensitive environment variables or secrets are exposed.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The `registerEnvironmentTool` function calls `server.tool("get_environment", ...)` to register the tool on the MCP server. This is where the tool name, description, schema (empty object — no params), and handler are all defined.
    export function registerEnvironmentTool(server: McpServer): void {
      server.tool(
        "get_environment",
        `Get information about the current server environment.
    
    Returns:
      - Operating system details (platform, arch, release)
      - Node.js version
      - Server process info (PID, uptime, memory usage)
      - CPU information
      - Memory (total, free, used)
      - Network hostname
    
    This tool does not require any parameters. No sensitive environment
    variables or secrets are exposed.`,
        {},
        async () => {
          try {
            const cpus = os.cpus();
            const totalMem = os.totalmem();
            const freeMem = os.freemem();
    
            return {
              content: [
                {
                  type: "text" as const,
                  text: JSON.stringify(
                    {
                      server: {
                        name: "mcp-toolkit-server",
                        version: "1.0.0",
                        pid: process.pid,
                        uptime: formatUptime(process.uptime()),
                      },
                      runtime: {
                        name: process.release.name,
                        version: process.version,
                        versions: process.versions,
                      },
                      os: {
                        platform: os.platform(),
                        arch: os.arch(),
                        release: os.release(),
                        hostname: os.hostname(),
                        type: os.type(),
                        totalMemory: formatBytes(totalMem),
                        freeMemory: formatBytes(freeMem),
                        usedMemory: formatBytes(totalMem - freeMem),
                        memoryUsagePercent: (
                          ((totalMem - freeMem) / totalMem) *
                          100
                        ).toFixed(1) + "%",
                      },
                      cpu: {
                        model: cpus[0]?.model || "unknown",
                        cores: cpus.length,
                        speed: cpus[0]?.speed || 0,
                      },
                      processMemory: {
                        rss: formatBytes(process.memoryUsage().rss),
                        heapUsed: formatBytes(process.memoryUsage().heapUsed),
                        heapTotal: formatBytes(process.memoryUsage().heapTotal),
                        external: formatBytes(process.memoryUsage().external),
                      },
                    },
                    null,
                    2
                  ),
                },
              ],
            };
          } catch (err: any) {
            return {
              content: [
                {
                  type: "text" as const,
                  text: `Environment Error: ${err.message}`,
                },
              ],
              isError: true,
            };
          }
        }
      );
    }
  • The async handler function that executes the tool logic. It gathers OS details (platform, arch, release, hostname), CPU info (model, cores, speed), memory info (total/free/used with percent), Node.js version and process versions, server identity, and process memory (rss, heap, external), then returns them as a JSON string in a text content block.
    async () => {
      try {
        const cpus = os.cpus();
        const totalMem = os.totalmem();
        const freeMem = os.freemem();
    
        return {
          content: [
            {
              type: "text" as const,
              text: JSON.stringify(
                {
                  server: {
                    name: "mcp-toolkit-server",
                    version: "1.0.0",
                    pid: process.pid,
                    uptime: formatUptime(process.uptime()),
                  },
                  runtime: {
                    name: process.release.name,
                    version: process.version,
                    versions: process.versions,
                  },
                  os: {
                    platform: os.platform(),
                    arch: os.arch(),
                    release: os.release(),
                    hostname: os.hostname(),
                    type: os.type(),
                    totalMemory: formatBytes(totalMem),
                    freeMemory: formatBytes(freeMem),
                    usedMemory: formatBytes(totalMem - freeMem),
                    memoryUsagePercent: (
                      ((totalMem - freeMem) / totalMem) *
                      100
                    ).toFixed(1) + "%",
                  },
                  cpu: {
                    model: cpus[0]?.model || "unknown",
                    cores: cpus.length,
                    speed: cpus[0]?.speed || 0,
                  },
                  processMemory: {
                    rss: formatBytes(process.memoryUsage().rss),
                    heapUsed: formatBytes(process.memoryUsage().heapUsed),
                    heapTotal: formatBytes(process.memoryUsage().heapTotal),
                    external: formatBytes(process.memoryUsage().external),
                  },
                },
                null,
                2
              ),
            },
          ],
        };
      } catch (err: any) {
        return {
          content: [
            {
              type: "text" as const,
              text: `Environment Error: ${err.message}`,
            },
          ],
          isError: true,
        };
      }
    }
  • Two helper functions used by the handler: `formatUptime` (converts seconds to a human-readable duration string like '1d 2h 30m 15s') and `formatBytes` (converts bytes to a human-readable string with units like '1.5 GB').
    function formatUptime(seconds: number): string {
      const days = Math.floor(seconds / 86400);
      const hours = Math.floor((seconds % 86400) / 3600);
      const minutes = Math.floor((seconds % 3600) / 60);
      const secs = Math.floor(seconds % 60);
    
      const parts: string[] = [];
      if (days > 0) parts.push(`${days}d`);
      if (hours > 0) parts.push(`${hours}h`);
      if (minutes > 0) parts.push(`${minutes}m`);
      parts.push(`${secs}s`);
    
      return parts.join(" ");
    }
    
    function formatBytes(bytes: number): string {
      const units = ["B", "KB", "MB", "GB", "TB"];
      let index = 0;
      let size = bytes;
    
      while (size >= 1024 && index < units.length - 1) {
        size /= 1024;
        index++;
      }
    
      return `${size.toFixed(1)} ${units[index]}`;
    }
  • The schema for get_environment: an empty object `{}` meaning no parameters are required. The description documents that it returns OS details, Node.js version, PID, uptime, memory usage, CPU info, and hostname, and notes no sensitive info is exposed.
        "get_environment",
        `Get information about the current server environment.
    
    Returns:
      - Operating system details (platform, arch, release)
      - Node.js version
      - Server process info (PID, uptime, memory usage)
      - CPU information
      - Memory (total, free, used)
      - Network hostname
    
    This tool does not require any parameters. No sensitive environment
    variables or secrets are exposed.`,
        {},
  • src/index.ts:13-13 (registration)
    Import of the `registerEnvironmentTool` function from `./tools/environment.js` in the main server file. Called on line 56 to register the tool on startup.
    import { registerEnvironmentTool } from "./tools/environment.js";
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries full burden. It discloses 'No sensitive environment variables or secrets are exposed,' which is important safety information. It also enumerates return categories, aiding understanding of tool behavior. No contradictions or omissions noted.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is concise: three sentences that front-load the main purpose, then bullet-like list of returns, then a clarifying note about safety. Every sentence adds value without redundancy.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple environment inspection tool with no output schema, the description adequately covers the key return categories (OS, Node.js, process, CPU, memory, hostname) and the safety guarantee. No gaps are apparent given the tool's simplicity and lack of parameters.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The tool has zero parameters and schema coverage is 100%. The description adds value by explicitly confirming no parameters are required, which reinforces the schema. Baseline for zero-param tools is 4, and this is met.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states 'Get information about the current server environment' and lists specific categories of returned data (OS, Node.js, process, CPU, memory, hostname). It uniquely identifies the tool's purpose and distinguishes it from sibling tools like 'get_datetime' or 'calculator'.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description explicitly notes 'This tool does not require any parameters,' which is a key usage detail. However, it does not provide explicit when-to-use or when-not-to-use guidance relative to siblings, though the purpose is clear and the context implies it's for environment introspection.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/vyshnavi-nandyala/mcp-toolkit-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server