mirror of
https://github.com/modelcontextprotocol/servers.git
synced 2026-04-19 08:43:28 +02:00
[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
This commit is contained in:
33
src/everything/tools/get-env.ts
Normal file
33
src/everything/tools/get-env.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
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),
|
||||
},
|
||||
],
|
||||
};
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user