Skip to main content
Glama

delete-server

Remove an MCP server by specifying its server ID. Use this tool to manage and free up resources by deleting servers no longer in use within the MCP Create Server environment.

Instructions

Delete a server

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
serverIdYesThe ID of the server

Implementation Reference

  • MCP tool handler for 'delete-server': validates input, delegates to ServerManager.deleteServer, and returns JSON result.
    case "delete-server": { const args = request.params .arguments as unknown as DeleteServerArgs; if (!args.serverId) { throw new Error("Missing required argument: serverId"); } const result = await serverManager.deleteServer(args.serverId); return { content: [ { type: "text", text: JSON.stringify(result), }, ], }; }
  • Core implementation in ServerManager: closes transport, kills process, removes from internal map, and deletes server directory.
    async deleteServer( serverId: string ): Promise<{ success: boolean; message: string }> { const server = this.servers.get(serverId); if (!server) { throw new Error(`Server ${serverId} not found`); } try { // Close the client connection await server.transport.close(); // Kill server process server.process.kill(); // Remove server from map this.servers.delete(serverId); // Delete server directory const serverDir = path.dirname(server.filePath); await fs.rm(serverDir, { recursive: true, force: true }); return { success: true, message: `Server ${serverId} deleted`, }; } catch (error) { console.error(`Error deleting server ${serverId}:`, error); throw error; } }
  • Tool object definition including name, description, and input schema for validation.
    const deleteServerTool: Tool = { name: "delete-server", description: "Delete a server", inputSchema: { type: "object", properties: { serverId: { type: "string", description: "The ID of the server", }, }, required: ["serverId"], }, };
  • TypeScript type definition for tool arguments.
    interface DeleteServerArgs { serverId: string; }
  • index.ts:1011-1022 (registration)
    Registers the delete-server tool (via deleteServerTool) in the ListToolsRequest handler for discovery.
    server.setRequestHandler(ListToolsRequestSchema, async () => { console.error("Received ListToolsRequest"); return { tools: [ createServerFromTemplateTool, executeToolTool, getServerToolsTool, deleteServerTool, listServersTool, ], }; });

Other Tools

Related Tools

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/tesla0225/mcp-create'

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