Skip to main content
POST
https://sandbox.open-metadata.org/api
/
mcp
POST /mcp (call tool)
from ai_sdk import AISdk, AISdkConfig

config = AISdkConfig.from_env()
client = AISdk.from_config(config)

# List available tools
tools = client.mcp.list_tools()
for tool in tools:
    print(f"{tool.name}: {tool.description}")

# Search for tables
result = client.mcp.call_tool("search_metadata", {
    "query": "customers",
    "entity_type": "table",
    "limit": 5
})

# Get entity details
result = client.mcp.call_tool("get_entity_details", {
    "entity_id": "sample_data.ecommerce_db.shopify.customers",
    "entity_type": "table",
    "fields": "columns,tags,owners"
})

# Get lineage
result = client.mcp.call_tool("get_entity_lineage", {
    "entity_id": "sample_data.ecommerce_db.shopify.customers",
    "entity_type": "table",
    "depth": 2
})
{
  "content": [
    {
      "type": "text",
      "text": "[{\"name\": \"customers\", \"fullyQualifiedName\": \"sample_data.ecommerce_db.shopify.customers\", \"entityType\": \"table\", \"description\": \"Customer master data including contact info and account details.\", \"owners\": [\"data-team\"], \"tags\": [\"PII.Sensitive\"]}]"
    }
  ]
}

MCP Tools

OpenMetadata exposes an MCP server at /mcp that turns your metadata into a set of tools any LLM can use. Unlike generic MCP connectors that only read raw database schemas, OpenMetadata’s MCP tools give your AI access to the full context of your data platform — descriptions, owners, lineage, glossary terms, tags, and data quality results.

Available Tools

ToolDescription
search_metadataSearch across your OpenMetadata instance
semantic_searchAI-powered semantic search that understands meaning and context beyond keyword matching
get_entity_detailsGet detailed information about an entity
get_entity_lineageGet lineage information for an entity
create_glossaryCreate a new glossary
create_glossary_termCreate a new glossary term
create_lineageCreate lineage between entities
patch_entityUpdate an entity’s metadata
get_test_definitionsList available data quality test definitions
create_test_caseCreate a data quality test case for an entity
root_cause_analysisAnalyze root causes of data quality failures

Tool Call Parameters

tool_name
string
required
Name of the MCP tool to invoke. Must be one of the available tools listed above.
arguments
object
required
Tool-specific arguments. Each tool accepts different parameters.

Calling Tools Directly

POST /mcp (call tool)
from ai_sdk import AISdk, AISdkConfig

config = AISdkConfig.from_env()
client = AISdk.from_config(config)

# List available tools
tools = client.mcp.list_tools()
for tool in tools:
    print(f"{tool.name}: {tool.description}")

# Search for tables
result = client.mcp.call_tool("search_metadata", {
    "query": "customers",
    "entity_type": "table",
    "limit": 5
})

# Get entity details
result = client.mcp.call_tool("get_entity_details", {
    "entity_id": "sample_data.ecommerce_db.shopify.customers",
    "entity_type": "table",
    "fields": "columns,tags,owners"
})

# Get lineage
result = client.mcp.call_tool("get_entity_lineage", {
    "entity_id": "sample_data.ecommerce_db.shopify.customers",
    "entity_type": "table",
    "depth": 2
})
{
  "content": [
    {
      "type": "text",
      "text": "[{\"name\": \"customers\", \"fullyQualifiedName\": \"sample_data.ecommerce_db.shopify.customers\", \"entityType\": \"table\", \"description\": \"Customer master data including contact info and account details.\", \"owners\": [\"data-team\"], \"tags\": [\"PII.Sensitive\"]}]"
    }
  ]
}

LangChain Integration

Convert MCP tools to LangChain format with a single method call:
pip install data-ai-sdk[langchain]
from ai_sdk import AISdk, AISdkConfig
from langchain_openai import ChatOpenAI
from langchain.agents import AgentExecutor, create_tool_calling_agent
from langchain_core.prompts import ChatPromptTemplate

config = AISdkConfig.from_env()
client = AISdk.from_config(config)

# Convert MCP tools to LangChain format
tools = client.mcp.as_langchain_tools()

llm = ChatOpenAI(model="gpt-4")
prompt = ChatPromptTemplate.from_messages([
    ("system", "You are an OpenMetadata assistant."),
    ("human", "{input}"),
    ("placeholder", "{agent_scratchpad}"),
])

agent = create_tool_calling_agent(llm, tools, prompt)
executor = AgentExecutor(agent=agent, tools=tools, verbose=True)

result = executor.invoke({
    "input": "Find tables related to customers and show their lineage"
})
print(result["output"])

OpenAI Integration

Convert MCP tools to OpenAI function calling format:
import json
from openai import OpenAI
from ai_sdk import AISdk, AISdkConfig

config = AISdkConfig.from_env()
om_client = AISdk.from_config(config)
openai_client = OpenAI()

tools = om_client.mcp.as_openai_tools()
executor = om_client.mcp.create_tool_executor()

response = openai_client.chat.completions.create(
    model="gpt-4",
    messages=[{"role": "user", "content": "Find customer tables"}],
    tools=tools,
)

message = response.choices[0].message
if message.tool_calls:
    for tool_call in message.tool_calls:
        result = executor(
            tool_call.function.name,
            json.loads(tool_call.function.arguments)
        )
        print(f"Tool: {tool_call.function.name}")
        print(f"Result: {result}")

Tool Filtering

You can filter which tools are exposed to your LLM to restrict its capabilities:
from ai_sdk.mcp.models import MCPTool

# Only include read-only tools
tools = client.mcp.as_langchain_tools(
    include=[
        MCPTool.SEARCH_METADATA,
        MCPTool.SEMANTIC_SEARCH,
        MCPTool.GET_ENTITY_DETAILS,
        MCPTool.GET_ENTITY_LINEAGE,
        MCPTool.GET_TEST_DEFINITIONS,
    ]
)

# Or exclude mutation tools
tools = client.mcp.as_langchain_tools(
    exclude=[MCPTool.PATCH_ENTITY, MCPTool.CREATE_GLOSSARY, MCPTool.CREATE_GLOSSARY_TERM]
)
The same include and exclude parameters work with as_openai_tools():
tools = client.mcp.as_openai_tools(
    include=[MCPTool.SEARCH_METADATA, MCPTool.GET_ENTITY_DETAILS]
)

Error Handling

CodeError TypeDescription
400BAD_REQUESTInvalid tool name or missing required arguments
401UNAUTHORIZEDInvalid or missing authentication token
403FORBIDDENUser lacks permission to call the requested tool
404TOOL_NOT_FOUNDThe requested tool does not exist
422INVALID_ARGUMENTSTool arguments failed validation
500TOOL_EXECUTION_ERRORTool encountered an internal error during execution