Skip to main content
Glama

get_environment

Retrieve WSL environment variables with optional filtering to view or export system settings for development workflows.

Instructions

Get WSL environment variables

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filterNoFilter pattern (grep)

Implementation Reference

  • The handler function for the 'get_environment' tool. It runs 'env' or 'env | grep -i "filter"' in WSL via command_executor, formats the output using format_output, and returns it as text content or an error.
    async ({ filter }) => { try { const cmd = filter ? `env | grep -i "${filter}"` : 'env'; const result = await this.command_executor.execute_command(cmd); return { content: [ { type: 'text' as const, text: this.format_output(result), }, ], }; } catch (error) { return { content: [ { type: 'text' as const, text: `Error: ${error instanceof Error ? error.message : String(error)}`, }, ], isError: true, }; } },
  • Valibot schema defining the optional 'filter' input parameter for the get_environment tool.
    schema: v.object({ filter: v.optional( v.pipe( v.string(), v.description('Filter pattern (grep)'), ), ), }),
  • src/index.ts:144-184 (registration)
    Registration of the 'get_environment' tool on the MCP server, including name, description, read-only annotation, input schema, and inline handler function.
    this.server.tool( { name: 'get_environment', description: 'Get WSL environment variables', schema: v.object({ filter: v.optional( v.pipe( v.string(), v.description('Filter pattern (grep)'), ), ), }), annotations: { readOnlyHint: true, }, }, async ({ filter }) => { try { const cmd = filter ? `env | grep -i "${filter}"` : 'env'; const result = await this.command_executor.execute_command(cmd); return { content: [ { type: 'text' as const, text: this.format_output(result), }, ], }; } catch (error) { return { content: [ { type: 'text' as const, text: `Error: ${error instanceof Error ? error.message : String(error)}`, }, ], isError: true, }; } }, );

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/spences10/mcp-wsl-exec'

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