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
| Name | Required | Description | Default |
|---|---|---|---|
| serverId | Yes | The ID of the server |
Implementation Reference
- index.ts:1174-1191 (handler)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), }, ], }; }
- index.ts:700-730 (helper)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; } }
- index.ts:968-981 (schema)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"], }, };
- index.ts:46-48 (schema)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, ], }; });