Data Access Service
Semantic database proxy for AI agents. Access 12+ databases through one API with business context, governed queries, and a five-layer knowledge architecture that turns raw schemas into business intelligence.
Why It Matters
AI agents that just run SQL are dangerous and dumb. Dangerous because SQL injection is trivial — one
malformed string and an agent can drop tables, exfiltrate data, or bypass every access control you have.
Dumb because they have no business context. They see column names like acct_nbr
and trx_dt with no idea what they mean, no understanding of
which tables relate to which business processes, and no awareness of your fiscal calendar or domain rules.
The Data Access Service solves both problems. Structured AST queries are SQL injection immune by construction — no raw SQL ever touches your database unless you explicitly allow it. And the five-layer semantic architecture teaches AI agents the business meaning of your data: what a "high-value customer" is, how your quarterly close process works, and which columns contain PII that should never appear in a response.
Key Capabilities
- Multi-Database Access: 12+ backends (PostgreSQL, MySQL, SQL Server, Oracle, Snowflake, BigQuery, Databricks, SQLite, and more) through one API
- AST Query API: Structured JSON queries that are SQL injection immune — no raw SQL ever touches your database
- Semantic Dictionary: Layer business descriptions, categories, and metadata on top of raw database schemas
- Ontology: Map business entities, concepts, and relationships so agents understand your domain
- Process Model: Define business workflows, rules, timing constraints, and calendar context
- Stored Definitions: Create virtual views, scalar UDFs, and table-valued functions without modifying source databases
- Governance & ACL: Identity-based access control with table/column deny lists, function blacklists, and parameter-level WHERE constraints
- Scratch Pad: Per-agent SQLite workspaces for staging intermediate query results
- Schema Introspection: Automatic catalog discovery with cached metadata and dictionary annotations
- 70+ Function Translations: Write functions once, translate automatically across SQL dialects
How It Works
An agent sends a structured AST query as JSON. The Data Access Service validates it against ACL rules, checks table and column permissions, enforces complexity limits, resolves stored view references, and translates the query to the target database dialect. The generated SQL is executed with parameterized bindings, and typed results are returned.
Before querying, agents call the semantic layer APIs to understand the data. GetOntologyContext
returns a snapshot of business entities, relationships, and column semantics for the agent's prompt context.
ResolveEntity maps business terms like "high-value customer" to specific database
tables and columns. GetBusinessRules explains timing constraints and workflow logic.
Together, these layers give agents the business intelligence they need to formulate correct queries.
For multi-database workflows, staged queries let agents pull data from multiple connections and join results using the scratch pad. All queries — whether single-database or federated — pass through the same ACL validation pipeline with full audit logging.
AST Query Pipeline: parse, validate, serialize, execute
Five-Layer Knowledge Architecture
Each layer adds progressively richer business context on top of raw databases
Scratch Pad
Per-agent SQLite workspaces for staging intermediate results
Process
Business rules, workflows, timing constraints, calendar context
Ontology
Business entities, relationships, column semantics, concepts
Dictionary
Stored views, reusable query fragments, business metadata
Catalog
Connection registry, schemas, tables, columns, cached metadata
Database Support
Complete feature support, connection pooling, full E2E test coverage
- PostgreSQL
- MySQL
- SQLite
Core query support with dialect-specific adapters and function translation
- SQL Server
- Oracle
- Snowflake
- BigQuery
- Databricks
Compatible with standard database protocols for seamless integration
- MariaDB
- SingleStore
- CockroachDB
- Greenplum
- Redshift
AST Query Example
Structured queries expressed as JSON. No raw SQL on the wire — SQL injection immune by construction.
import { DataAccessClient } from '@firefoundry/data-access-client';
const client = new DataAccessClient({ baseUrl: 'https://das.firefoundry.io' });
// Structured AST query — SQL injection immune
const result = await client.queryAST({
connectionId: 'prod-analytics',
select: {
columns: [
{ expr: { column: { table: 'orders', column: 'customer_id' } } },
{ expr: { function: { name: 'SUM', args: [{ column: { column: 'amount' } }] } }, alias: 'total' }
],
from: { table: 'orders', schema: 'public' },
where: {
binary: {
op: 'BINARY_OP_GTE',
left: { column: { column: 'order_date' } },
right: { literal: { stringValue: '2025-01-01' } }
}
},
groupBy: [{ expr: { column: { table: 'orders', column: 'customer_id' } } }],
orderBy: [{ expr: { column: { column: 'total' } }, direction: 'SORT_DESC' }],
limit: 100
}
});
console.log(`${result.rows.length} rows, ${result.executionTimeMs}ms`);
Semantic Layer Example
Agents query the dictionary, ontology, and process layers to understand data before accessing it.
// Discover what data is available
const schema = await client.getSchema({ connectionId: 'prod-analytics' });
console.log(schema.tables.map(t => `${t.name}: ${t.description}`));
// Resolve a business entity to database columns
const entity = await client.resolveEntity({
connectionId: 'prod-analytics',
entityType: 'customer',
searchTerm: 'high-value accounts'
});
// Get business rules for a process
const rules = await client.getBusinessRules({
connectionId: 'prod-analytics',
processId: 'quarterly-close'
});
Governance & Access Control
Every request carries an identity header (X-On-Behalf-Of).
The ACL engine evaluates five layers of rules before any query reaches the database:
-
Connection-level access — Control which identities can query which databases
-
Table/column deny lists — Hide sensitive tables or specific columns (e.g., salary data, SSN)
-
Function blacklists — Prevent dangerous operations like DROP, TRUNCATE, or custom functions
-
Raw SQL gating — Disable raw SQL endpoints for untrusted agents, forcing AST-only access
-
Identity-based WHERE constraints — Automatically inject filters so agents only see their own data (e.g., department = caller's department)
// ACL rules — define who can access what
const aclRules = [
{
identity: 'app:sales-agent',
connections: ['analytics-db'],
tables_deny: ['salary_data', 'employee_reviews'],
columns_deny: {
customers: ['ssn', 'credit_card']
},
allow_raw_sql: false // Force AST-only queries
},
{
identity: 'dept:finance',
connections: ['*'], // Access all databases
allow_raw_sql: true,
parameter_constraints: [
{
table: 'transactions',
require_filter: 'department',
match_identity_field: 'department' // Auto-inject WHERE clause
}
]
}
];
Related Content — 3-Part Blog Series
Use Cases
Chat With Your Data
Let users ask questions in natural language, translated to governed database queries. The semantic layer ensures agents understand business terms, not just column names, turning "show me top customers last quarter" into the correct AST query automatically.
Multi-Database Intelligence
Query across PostgreSQL, Snowflake, and BigQuery through a single semantic layer. Staged queries federate data across connections, and the scratch pad lets agents join results from different databases without exposing raw credentials.
Governed Agent Access
Give AI agents database access with fine-grained ACL rules and audit trails. Table deny lists, column masking, function blacklists, and identity-based WHERE filters ensure agents only see the data they are authorized to access.
Business Context for AI
Teach agents your domain vocabulary so they understand "quarterly close" and "high-value customer." The ontology and process layers provide the business context that raw schemas never can — including fiscal calendars, workflow rules, and entity relationships.