.db files using sql.js (a pure JavaScript/WASM SQLite implementation). Resources are the second MCP primitive supported by FlowMCP v3.0.0.
Resources are optional. Most schemas only need tools. Add resources when your schema benefits from fast local data lookups that do not require network calls.
When to Use Resources
| Use Case | Tool or Resource? |
|---|---|
| Fetch live data from an API | Tool |
| Look up static reference data (chain IDs, token lists) | Resource |
| Query historical data that changes infrequently | Resource |
| Perform calculations on cached data | Resource |
| Call external services | Tool |
Schema Format
Resources are declared in theresources key of the main export:
Resource Fields
| Field | Type | Required | Description |
|---|---|---|---|
description | string | Yes | What data this resource provides. Visible to AI clients. |
source | string | Yes | Must be 'sqlite'. Only SQLite is supported in v3.0.0. |
database | string | Yes | Path to the .db file, relative to the schema file. Must end in .db. |
queries | object | Yes | Named queries with SQL and parameters. Max 4 queries per resource. |
Query Fields
Each query is a named entry in thequeries object:
| Field | Type | Required | Description |
|---|---|---|---|
description | string | Yes | What this query returns. Used by AI clients for query selection. |
sql | string | Yes | SQL query string with ? placeholders. Must start with SELECT. |
parameters | array | No | Query parameters corresponding to ? placeholders. Can be empty []. |
tests | array | No | Test cases with example parameter values. |
Query Parameters
Resource query parameters use a simplified flat format (noposition/z blocks):
| Field | Type | Required | Description |
|---|---|---|---|
key | string | Yes | Parameter name (camelCase). Maps to a ? placeholder in order. |
type | string | Yes | Must be string, number, or boolean. |
description | string | Yes | What this parameter controls. |
required | boolean | Yes | Whether the parameter must be provided. |
? placeholders in the SQL query.
SQL Security Enforcement
Resources enforce strict read-only access. The following patterns are blocked at validation time:| Blocked Pattern | Reason |
|---|---|
INSERT, UPDATE, DELETE, DROP | Write operations not allowed |
CREATE TABLE, ALTER TABLE | Schema modifications not allowed |
ATTACH DATABASE | Cross-database access not allowed |
LOAD_EXTENSION | Extension loading not allowed |
PRAGMA (most) | Configuration changes not allowed |
| String interpolation | All values must use ? placeholders |
| Subqueries with writes | Nested write operations not allowed |
Runtime
Resources usesql.js, a pure JavaScript/WASM implementation of SQLite. This means:
- No native dependencies — works on any platform that supports WASM
- No SQLite installation required — everything is bundled
- Read-only mode — databases are opened in read-only mode by default
- Memory-safe — each query runs in an isolated context
Constraints
| Constraint | Value | Rationale |
|---|---|---|
| Max resources per schema | 2 | Resources are supplementary, not primary output |
| Max queries per resource | 4 | Keeps resource scope focused |
| Source type | sqlite only | Future versions may add other sources |
| Database file extension | .db | Standard SQLite extension |
| SQL must start with | SELECT | Read-only enforcement |
| Parameter placeholders | ? only | Prevents SQL injection |
| Parameter types | string, number, boolean | Simple types only |
Complete Example
A schema with both tools and resources:- Tool (
getContractAbi) — fetches live ABI data from the Etherscan API (requires network and API key) - Resource (
verifiedContracts) — queries a local SQLite database of contract metadata (instant, no network, no API key)
Validation Rules
Resources are validated by rules RES001-RES023. Key rules include:| Code | Rule |
|---|---|
| RES003 | Maximum 2 resources per schema |
| RES005 | Source must be 'sqlite' |
| RES006 | Database path must end in .db |
| RES008 | Maximum 4 queries per resource |
| RES012 | SQL must start with SELECT |
| RES013 | SQL must not contain blocked patterns |
| RES014 | SQL must use ? placeholders |
| RES015 | Placeholder count must match parameter count |