Skip to main content
Glama

delete_graph

Permanently remove a knowledge graph and all its data from the Mnemosyne MCP server. This action cannot be undone.

Instructions

Permanently deletes a knowledge graph and all its contents. This action cannot be undone. Use with caution.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
graph_idYes

Implementation Reference

  • The asynchronous handler function that implements the core logic of the 'delete_graph' tool: authenticates the user, validates the graph_id parameter, submits a backend job with task_type='delete_graph', polls or streams for job completion, and returns a formatted JSON response with success status, graph_id, job_id, and result details.
    async def delete_graph_tool(
        graph_id: str,
        context: Context | None = None,
    ) -> str:
        """Delete a knowledge graph."""
        auth = MCPAuthContext.from_context(context)
        auth.require_auth()
    
        if not graph_id or not graph_id.strip():
            raise ValueError("graph_id is required and cannot be empty")
    
        metadata = await submit_job(
            base_url=backend_config.base_url,
            auth=auth,
            task_type="delete_graph",
            payload={"graph_id": graph_id.strip()},
        )
    
        if context:
            await context.report_progress(10, 100)
    
        result = await _wait_for_job_result(
            job_stream, metadata, context, auth
        )
    
        return _render_json({
            "success": True,
            "graph_id": graph_id.strip(),
            "deleted": True,
            "job_id": metadata.job_id,
            **result,
        })
  • The @server.tool decorator that registers the 'delete_graph' tool on the FastMCP server, specifying the tool name, title, description, and input schema via function signature.
    @server.tool(
        name="delete_graph",
        title="Delete Knowledge Graph",
        description=(
            "Permanently deletes a knowledge graph and all its contents. "
            "This action cannot be undone. Use with caution."
        ),
    )
  • The call to register_graph_ops_tools which executes the tool registrations including 'delete_graph' on the MCP server instance.
    register_graph_ops_tools(mcp_server)
  • Dataclass McpDeleteGraphResponse providing structured output schema for delete_graph operations, with fields for operation summary, deletion confirmation, backup info, and cleanup metrics.
    class McpDeleteGraphResponse(McpResponseObject):
        """Response for graph deletion operations"""
        operation_summary: McpOperationSummary
        deletion_info: Dict[str, Any]
        backup_info: Optional[Dict[str, Any]]
        cleanup_results: Dict[str, Any]
        success: bool = True
        
        @classmethod
        def from_api_response(cls, api_response: Dict[str, Any], operation_id: str, graph_id: str, user_id: Optional[str] = None) -> 'McpDeleteGraphResponse':
            """Transform API graph deletion response to MCP format"""
            import datetime
            
            return cls(
                operation_summary=McpOperationSummary(
                    operation_type="delete_graph",
                    operation_id=operation_id,
                    timestamp=datetime.datetime.now().isoformat(),
                    user_id=user_id
                ),
                deletion_info={
                    "graph_id": graph_id,
                    "deleted_at": datetime.datetime.now().isoformat(),
                    "confirmed": True
                },
                backup_info=api_response.get("backup_info"),
                cleanup_results={
                    "files_removed": api_response.get("files_removed", 0),
                    "space_freed_mb": api_response.get("space_freed_mb", 0),
                    "cache_cleared": True
                }
            )

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/sophia-labs/mnemosyne-mcp'

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