Connecting the AI to Data
User Defined Tools let you use UDFs as tools to provide the AI with extra context about your data. This enables the AI to query your databases, search your documents, or interact with any data source you configure.
Try it out
See the demo canvas below with all the live demos:
Or try this one out, asking any questions about Population & Income from Census data:
"What is the population of Brooklyn, NY in 2024?"
Setting up AI profiles
Profiles are a way of "scoping" your AI's data access. You can connect specific data sources, rules, and tools to a profile, allowing you to create different configurations for different use cases.
Accessing the profile settings
- Open the AI chat window
- Click the profile dropdown menu
- Hover over any profile and click the edit icon to configure your tools

User defined tools

Inside a profile, you can configure what we call "MCP JSON" - a configuration format that tells the AI how to call your UDFs as tools. Despite the name, this isn't actual MCP (Model Context Protocol) JSON, but uses a similar concept to make it easy to understand: it defines how the AI can call your UDFs to fetch data.
How it works
- Create a UDF that acts as a pure function - it takes some input and returns a response
- Generate the MCP JSON configuration for your UDF
- Add the configuration to your AI profile
The input to your UDF can be:
- An SQL query for database lookups
- A plain text query for RAG (Retrieval Augmented Generation) searches
- Any other structured input that determines the query result
Example: RAG search tool
A common use case is creating a RAG search tool that queries your vector database. Here's how it works:
- Create a UDF that takes a string query parameter
- The UDF queries your vector database and returns relevant results
- Generate the MCP JSON for this UDF
- The AI can now search your data using natural language
@fused.udf
def udf(query: str = "how does fused.cache work?"):
"""
Fused SDK search function for finding methods, types, and functions.
Searches through the Fused SDK documentation using vector embeddings
to return relevant code examples and function signatures.
"""
TABLE_NAME = "fused_sdk_chunker_demo"
TOP_K = 5
rag = fused.load("https://github.com/fusedio/udfs/tree/5c526cc/community/joey/RAG_Utils_new/")
print(f"Searching for: {query}")
query_embedding = rag.embed_text(query, provider="qwen")
results = rag.search_vector_table(
table_name=TABLE_NAME,
query_vec=query_embedding,
top_k=TOP_K,
)
display_cols = ['method', 'signature', 'similarity']
available_cols = [c for c in display_cols if c in results.columns]
return results[available_cols + ['content']]
Generating MCP JSON
To generate the MCP JSON configuration for your UDF, simply ask the AI chat:
"Generate an MCP JSON for this UDF"
The AI will create a JSON configuration like this:
{
"udf_name": "census_income_fetch",
"link": "https://udf.ai/fsh_RSuSMvR2wc3uf2CX3TjIc/run",
"description": "This UDF fetches demographic and income data from the US Census API for a specific state and county. It accepts parameters for state_fips (default 13 for Georgia), county_fips (default 121 for a specific county), and year (default 2023). The function returns a pandas DataFrame containing population and median income data along with the geographic name.",
"parameters": {
"state_fips": "str",
"county_fips": "str",
"year": "int"
}
}
Paste this configuration into your profile settings to enable the tool.
Best practices
- Write detailed docstrings: The AI uses docstrings to decide when and how to call your tool. Be specific about use cases and expected inputs/outputs.
- Keep UDFs focused: Each tool should do one thing well
- Use descriptive parameter names: This helps the AI understand what inputs are expected
- Return structured data: JSON or tabular formats work best for AI consumption