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
| Name | Required | Description | Default |
|---|---|---|---|
| filter | No | Filter pattern (grep) |
Implementation Reference
- src/index.ts:160-183 (handler)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, }; } },
- src/index.ts:148-155 (schema)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, }; } }, );