Files
servers-modelcontextprotocol-1/src/everything/tools/get-env.ts
cliffhall 03d3da0d55 [WIP] Refactor everything server to be more modular and use recommended APIs.
Refactor/rename `print-env` tool to `get-env`

* Updated architecture.md

* Refactor rename print-env.ts to get-env.ts

* In tools/index.ts
  - reorder tools alphabetically
2025-12-09 19:24:39 -05:00

34 lines
1000 B
TypeScript

import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
// Tool configuration
const name = "get-env";
const config = {
title: "Print Environment Tool",
description:
"Prints all environment variables, helpful for debugging MCP server configuration",
inputSchema: {},
};
/**
* Registers the 'get-env' tool with the given MCP server.
*
* The registered tool Retrieves and returns the environment variables
* of the current process as a JSON-formatted string encapsulated in a text response.
*
* @param {McpServer} server - The MCP server instance where the Echo Tool is to be registered.
* @returns {void}
*/
export const registerGetEnvTool = (server: McpServer) => {
server.registerTool(name, config, async (args): Promise<CallToolResult> => {
return {
content: [
{
type: "text",
text: JSON.stringify(process.env, null, 2),
},
],
};
});
};