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
| Parameter | Type | Required | Description |
|---|---|---|---|
product | string | Yes | Data product identifier (e.g., "pg_customers_v1") |
Example Request
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "product_get",
"arguments": {
"product": "pg_customers_v1"
}
}
}
Response
Success Response
{
"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
| Field | Type | Description |
|---|---|---|
product_id | string | Unique identifier for the data product |
name | string | Human-readable name |
schema | array | Exposed schema (fields, types, constraints) |
permissions | array | Available permissions: "read", "write", or both |
allowed_purposes | array | List of purposes allowed for this data product |
restrictions | object | Restrictions and configurations (read/write rules, validation, etc.) |
Example Response Structure
{
"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)
{
"jsonrpc": "2.0",
"id": 1,
"error": {
"code": -32600,
"message": "Invalid Request",
"data": "product is required"
}
}
Product Not Found
Error Code: -32603 (Internal error)
{
"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
{
"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
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
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
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
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
-
Check before use: Get product details before reading or writing to understand requirements
-
Validate purposes: Verify that your intended purpose is in the
allowed_purposeslist -
Understand schema: Review the schema to know what fields are available and their types
-
Check write requirements: For write operations, review
restrictions.writeto understand validation rules -
Cache product info: Product configurations don't change frequently, so cache results
-
Handle missing products: Be prepared for products that don't exist or aren't accessible
-
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_configorupdate_config -
Real-time: Product configurations may change, so don't assume they're static
Related Methods
products_list- List all available data productsdecision_read- Read data from a data productdecision_write- Write data to a data productcapabilities_get- Get agent capabilities