product_get

Gets detailed information about a specific data product, including its schema, permissions, allowed purposes, and configuration.

Overview

The product_get method returns comprehensive details about a data product, including the exposed schema, read/write permissions, allowed purposes, and any restrictions or configurations. This is essential for understanding how to use a data product correctly.

Request

Parameters

ParameterTypeRequiredDescription
productstringYesData product identifier (e.g., "pg_customers_v1")

Example Request

json
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "product_get",
    "arguments": {
      "product": "pg_customers_v1"
    }
  }
}

Response

Success Response

json
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "content": [
      {
        "type": "text",
        "text": "{\"product_id\": \"pg_customers_v1\", \"name\": \"Customer Accounts\", \"schema\": [...], \"permissions\": [\"read\"], \"allowed_purposes\": [\"order_processing\", \"support\"], \"restrictions\": {...}}"
      }
    ]
  }
}

Response Fields

FieldTypeDescription
product_idstringUnique identifier for the data product
namestringHuman-readable name
schemaarrayExposed schema (fields, types, constraints)
permissionsarrayAvailable permissions: "read", "write", or both
allowed_purposesarrayList of purposes allowed for this data product
restrictionsobjectRestrictions and configurations (read/write rules, validation, etc.)

Example Response Structure

json
{
  "product_id": "pg_orders_v1",
  "name": "Order Management",
  "schema": [
    {
      "name": "order_id",
      "type": "integer",
      "primary_key": true,
      "nullable": false
    },
    {
      "name": "customer_id",
      "type": "integer",
      "nullable": false
    },
    {
      "name": "total_amount",
      "type": "decimal",
      "nullable": false
    },
    {
      "name": "status",
      "type": "string",
      "nullable": false
    },
    {
      "name": "created_at",
      "type": "timestamp",
      "nullable": false
    }
  ],
  "permissions": ["read", "write"],
  "allowed_purposes": ["order_processing", "order_fulfillment", "order_validation"],
  "restrictions": {
    "read": {
      "allowed_purposes": ["order_processing", "order_fulfillment", "order_validation"]
    },
    "write": {
      "allowed_purposes": ["order_creation", "order_update"],
      "insert_config": {
        "column_config": {
          "order_id": {
            "required": false,
            "allowed": false,
            "default_behavior": "db_default"
          },
          "customer_id": {
            "required": true,
            "allowed": true
          },
          "total_amount": {
            "required": true,
            "allowed": true
          }
        },
        "return_created": true
      }
    }
  }
}

Error Cases

Missing Product Parameter

Error Code: -32600 (Invalid Request)

json
{
  "jsonrpc": "2.0",
  "id": 1,
  "error": {
    "code": -32600,
    "message": "Invalid Request",
    "data": "product is required"
  }
}

Product Not Found

Error Code: -32603 (Internal error)

json
{
  "jsonrpc": "2.0",
  "id": 1,
  "error": {
    "code": -32603,
    "message": "Internal error",
    "data": "Data product 'pg_customers_v1' not found or not accessible"
  }
}

Common causes:

  • Product doesn't exist
  • Agent doesn't have permission to access this product
  • Product ID is misspelled

Permission Denied

HTTP Status: 403 Forbidden

json
{
  "jsonrpc": "2.0",
  "id": 1,
  "error": {
    "code": -32603,
    "message": "Internal error",
    "data": "Permission denied: agent does not have access to this data product"
  }
}

Authentication Errors

HTTP Status: 401 Unauthorized

Occurs when:

  • API key is missing
  • API key is invalid
  • API key has been revoked

Usage Examples

Get Product Details

python
import requests
import json

def get_product(product_id, api_key=None):
    response = requests.post('https://mcp.tracemem.com',
        headers={'Authorization': f'Agent {api_key}'},
        json={
            "jsonrpc": "2.0",
            "id": 1,
            "method": "tools/call",
            "params": {
                "name": "product_get",
                "arguments": {
                    "product": product_id
                }
            }
        })
    
    result = response.json()
    if "error" in result:
        raise Exception(result["error"]["data"])
    
    product_data = json.loads(result["result"]["content"][0]["text"])
    return product_data

# Get product details
product = get_product("pg_orders_v1", api_key="YOUR_API_KEY")

print(f"Product: {product['name']} ({product['product_id']})")
print(f"Permissions: {', '.join(product['permissions'])}")
print(f"Allowed purposes: {', '.join(product['allowed_purposes'])}")
print(f"Schema fields: {len(product['schema'])}")

Check Write Requirements

python
def check_write_requirements(product_id, api_key):
    """Check what's required for writing to a product"""
    product = get_product(product_id, api_key)
    
    if "write" not in product["permissions"]:
        return {"error": "Product does not support write operations"}
    
    restrictions = product.get("restrictions", {})
    write_config = restrictions.get("write", {})
    insert_config = write_config.get("insert_config", {})
    column_config = insert_config.get("column_config", {})
    
    required_fields = [
        name for name, config in column_config.items()
        if config.get("required", False)
    ]
    
    allowed_fields = [
        name for name, config in column_config.items()
        if config.get("allowed", True)
    ]
    
    return {
        "required_fields": required_fields,
        "allowed_fields": allowed_fields,
        "allowed_purposes": write_config.get("allowed_purposes", [])
    }

# Check requirements before writing
requirements = check_write_requirements("pg_orders_v1", api_key)
print(f"Required fields: {requirements['required_fields']}")
print(f"Allowed fields: {requirements['allowed_fields']}")

Validate Purpose Before Read

python
def validate_purpose(product_id, purpose, api_key):
    """Check if a purpose is allowed for a product"""
    product = get_product(product_id, api_key)
    
    if purpose not in product["allowed_purposes"]:
        raise ValueError(
            f"Purpose '{purpose}' not allowed for product '{product_id}'. "
            f"Allowed purposes: {', '.join(product['allowed_purposes'])}"
        )
    
    return True

# Validate before reading
try:
    validate_purpose("pg_customers_v1", "order_processing", api_key)
    # Proceed with read
except ValueError as e:
    print(f"Error: {e}")

Understand Schema

python
def analyze_schema(product_id, api_key):
    """Analyze product schema for understanding"""
    product = get_product(product_id, api_key)
    
    schema_info = {
        "fields": [],
        "primary_keys": [],
        "required_fields": []
    }
    
    for field in product["schema"]:
        field_info = {
            "name": field["name"],
            "type": field["type"],
            "nullable": field.get("nullable", True)
        }
        
        if field.get("primary_key", False):
            schema_info["primary_keys"].append(field["name"])
        
        if not field.get("nullable", True):
            schema_info["required_fields"].append(field["name"])
        
        schema_info["fields"].append(field_info)
    
    return schema_info

# Analyze schema
schema = analyze_schema("pg_orders_v1", api_key)
print(f"Primary keys: {schema['primary_keys']}")
print(f"Required fields: {schema['required_fields']}")

Best Practices

  1. Check before use: Get product details before reading or writing to understand requirements

  2. Validate purposes: Verify that your intended purpose is in the allowed_purposes list

  3. Understand schema: Review the schema to know what fields are available and their types

  4. Check write requirements: For write operations, review restrictions.write to understand validation rules

  5. Cache product info: Product configurations don't change frequently, so cache results

  6. Handle missing products: Be prepared for products that don't exist or aren't accessible

  7. Review restrictions: Pay attention to restrictions, especially for write operations

Important Notes

  • Agent-specific: Product details reflect your agent's permissions and may differ from other agents

  • Schema is exposed only: The schema shows only fields that are exposed by the data product, not all fields in the underlying data source

  • Restrictions apply: All restrictions and configurations must be followed when using the product

  • Purpose-based access: You must use an allowed purpose when reading or writing

  • Write validation: Write operations are validated according to the product's insert_config or update_config

  • Real-time: Product configurations may change, so don't assume they're static

Related Methods

TraceMem is trace-native infrastructure for AI agents