mirror of
https://github.com/modelcontextprotocol/servers.git
synced 2026-04-18 00:03:23 +02:00
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
34 lines
1000 B
TypeScript
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),
|
|
},
|
|
],
|
|
};
|
|
});
|
|
};
|