Skip to main content
Glama
wagonbomb

Megaraptor MCP

by wagonbomb

generate_api_credentials

Create API client certificates to connect the Megaraptor MCP server to Velociraptor deployments for digital forensics and incident response workflows.

Instructions

Generate API client credentials for MCP connection.

Creates a new API client certificate for connecting this MCP server to a Velociraptor deployment.

Args: deployment_id: The deployment to generate credentials for client_name: Name for the API client validity_days: Certificate validity in days

Returns: API credentials in Velociraptor config file format. IMPORTANT: Save these credentials - they can only be displayed once.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
deployment_idYes
client_nameNomegaraptor_api
validity_daysNo

Implementation Reference

  • The implementation of the 'generate_api_credentials' tool which generates API client credentials for MCP connections.
    async def generate_api_credentials(
        deployment_id: str,
        client_name: str = "megaraptor_api",
        validity_days: int = 365,
    ) -> list[TextContent]:
        """Generate API client credentials for MCP connection.
    
        Creates a new API client certificate for connecting this MCP
        server to a Velociraptor deployment.
    
        Args:
            deployment_id: The deployment to generate credentials for
            client_name: Name for the API client
            validity_days: Certificate validity in days
    
        Returns:
            API credentials in Velociraptor config file format.
            IMPORTANT: Save these credentials - they can only be displayed once.
        """
        try:
            from ..deployment.security import CertificateManager, CredentialStore, StoredCredential
            from ..deployment.security.credential_store import generate_credential_id
            from ..deployment.deployers import DockerDeployer
    
            # Get deployment info
            deployer = DockerDeployer()
            info = await deployer.get_status(deployment_id)
    
            if not info:
                return [TextContent(
                    type="text",
                    text=json.dumps({
                        "error": f"Deployment not found: {deployment_id}",
                        "hint": "Use list_deployments tool to see available deployments"
                    }, indent=2)
                )]
    
            # Load certificates
            cert_manager = CertificateManager()
            bundle = cert_manager.load_bundle(deployment_id)
    
            if not bundle:
                return [TextContent(
                    type="text",
                    text=json.dumps({
                        "error": "Certificate bundle not found"
                    }, indent=2)
                )]
    
            # Generate API client config (Velociraptor format)
            import yaml
            api_config = {
                "api_url": info.api_url or info.server_url,
                "ca_certificate": bundle.ca_cert,
                "client_cert": bundle.api_cert,
                "client_private_key": bundle.api_key,
            }
    
            # Store credential metadata
            cred_store = CredentialStore()
            credential = StoredCredential(
                id=generate_credential_id(),
                name=client_name,
                credential_type="api_key",
                created_at=datetime.now(timezone.utc).isoformat(),
                expires_at=(datetime.now(timezone.utc) + timedelta(days=validity_days)).isoformat(),
                deployment_id=deployment_id,
                data={"client_name": client_name},
            )
            cred_store.store(credential)
    
            # Return config in YAML format (matches Velociraptor api_client format)
            return [TextContent(
                type="text",
                text=f"""# Velociraptor API Client Configuration
    # Generated for: {client_name}
    # Deployment: {deployment_id}
    # Expires: {credential.expires_at}
    #
    # IMPORTANT: Save this configuration - it cannot be displayed again!
    # Set VELOCIRAPTOR_CONFIG_PATH to this file to use with MCP.
    
    {yaml.dump(api_config, default_flow_style=False)}"""
            )]
    
        except ImportError as e:
            return [TextContent(
                type="text",
                text=json.dumps({
                    "error": f"Missing dependency: {str(e)}",
                    "hint": "Install required packages with: pip install megaraptor-mcp[deployment]"
                }, indent=2)
            )]
    
        except Exception:
            # Generic errors - don't expose internals
            return [TextContent(
                type="text",
                text=json.dumps({
                    "error": "Operation failed",
                    "hint": "Check deployment configuration and try again"
                }, indent=2)
            )]

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/wagonbomb/megaraptor-mcp'

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