mcp-server
v0.1.3Fractale MCP server — AI agent access to open data, gathered and structured with clear provenance
MCP server for Fractale, giving AI agents access to datasets, their evidence, and permitted data retrieval through the shared data service. A verified email and current beta approval are required. Publishing requires authorization and an enabled upload environment. Use a compatible MCP client. A working SDK connection does not establish that every AI app supports OAuth, attached-file delivery, local file access, or HTTP PUT; verify the operations you need in your client. This README describes version 0.1.0 in this repository (15 tools, Node.js 18 or later).
Summary extracted from the README.
Fractale MCP Server
MCP server for Fractale, giving AI agents access to datasets, their evidence, and permitted data retrieval through the shared data service. A verified email and current beta approval are required. Publishing requires authorization and an enabled upload environment.
Use a compatible MCP client. A working SDK connection does not establish that every AI app supports OAuth, attached-file delivery, local file access, or HTTP PUT; verify the operations you need in your client.
Install / Run
This README describes version 0.1.0 in this repository (15 tools, Node.js 18 or later). Publishing it to npm is a separate release decision. Until then the npm registry has only 0.0.1, published on 2026-07-12, which predates fractale_account and the receipt-based upload tools (first added on 2026-09-20), so its tools and rules differ from this README. Check npm view @fractale/mcp-server version before relying on a registry release, the target environment's tools/list, and STATUS for what each environment runs. For shell scripts and local files, the Fractale CLI uses the same REST API and API keys.
Remote MCP (primary connection)
- URL:
/mcpon the Fractale environment you use. Copy the complete endpoint from that environment's/account?panel=accesspage. - Transport: Streamable HTTP
- Reads: OAuth
fractale:reador a read-capable API key tied to a verified, approved beta account. Anonymous reads are unavailable. - Shared/private reads: explicit OAuth
fractale:read:privateconsent, or an API key issued withallowPrivateRead: true, and your current permission for the data. Existing keys keep private reads disabled. - Uploads: OAuth
fractale:readplusfractale:publish(including prepare, file, receipt, and commit tools) or a publish/admin API key, permission for the destination, enabled intake, and healthy safety processing. - API key compatibility:
Authorization: Bearer <API_KEY>orX-API-Key: <API_KEY>. - Remote and local stdio register the same tools.
Connect with your client's Remote MCP setting and authorize your own account with OAuth. Then initialize, list tools, search for a small result set, and inspect one returned handle. Initialize and tool discovery require the approved connection but do not count toward monthly operation usage. A GET request in a browser returns 405 and is not an MCP connection test. Do not treat tool discovery or OAuth consent as proof that uploads are accepting files.
Local stdio (compatibility and development)
The following template is for clients that support this stdio configuration shape. Replace both placeholders locally; keep the credential in private client configuration. npx -y @fractale/mcp-server runs the newest version on npm; while the registry has only 0.0.1, that is the July release, not this checkout. To run this checkout, build it as shown under Local development and point command / args at node and the built dist/index.js.
{
"mcpServers": {
"fractale": {
"command": "npx",
"args": ["-y", "@fractale/mcp-server"],
"env": {
"FRACTALE_API_URL": "<your-fractale-environment-origin>",
"FRACTALE_AUTH_TOKEN": "<read-capable-api-key>"
}
}
}
}
Local development (install from the repository root; this package has no lockfile of its own and builds with the root's TypeScript and MCP SDK). The published package contains only the compiled dist JavaScript and type declarations, this README and the license; prepublishOnly builds and tests it first:
npm ci
cd packages/mcp-server
npm run build
npm test
echo '{"jsonrpc":"2.0","id":1,"method":"tools/list"}' | node dist/index.js
Tools
| Tool | Source | Description |
|---|---|---|
fractale_account |
/api/v1/account |
Current account, permissions and monthly usage; use purpose: "upload" to authorize and discover upload destinations; zero monthly operations |
fractale_search |
HTTP /api/v1/search |
Search datasets by optional 2-200 character query and filters. Searches original Japanese and English metadata without automatic query translation. Returns 10 results by default (limit up to 100; REST and Web keep their default of 20) |
fractale_get_dataset |
HTTP /api/v1/datasets/[id] |
Get one dataset detail |
fractale_list_files |
/api/v1/files |
List originals, derived files, and registered external files with IDs and conditions |
fractale_preview |
/api/v1/preview |
Select by file_id; bounded CSV / TSV / JSON tables or TXT (UTF-8, or Shift_JIS for labelled files and Japanese data) from storage or a registered external URL (the shared handler reads external files in the same operation) |
fractale_download |
/api/v1/download |
Get an original-file URL valid for at most five minutes; issuance costs zero operations |
fractale_list_portals |
HTTP /api/v1/portals |
Discover portals using the same region/type filters as REST. An empty result stays empty; API failure is an error |
fractale_list_organizations |
HTTP /api/v1/organizations |
Discover organizations |
fractale_realtime |
HTTP /api/v1/transit/realtime/by-dataset |
Fetch GTFS-RT realtime data. The tool argument is named dataset_id for compatibility, but the value is a public dataset handle |
fractale_upload_prepare |
POST /api/v1/intake/receipts |
Save explicit visibility, metadata, and the complete file list before transferring bytes |
fractale_upload_file |
POST /api/v1/intake/import |
Optional attached-file delivery for one new dataset; client-specific end-to-end verification is pending |
fractale_upload_receipt |
GET /api/v1/intake/receipts/[id] |
Inspect or resume the saved upload request, including each file's processing status and quarantine reason |
fractale_upload_commit |
POST /api/v1/intake/receipts/[id] |
Commit all prepared files as one version with the already chosen visibility |
fractale_upload_create |
HTTP POST /api/v1/intake/uploads |
Create a signed PUT slot for a file in an existing receipt, sending the same fields as Web and CLI. Requires authorized publishing and enabled intake |
fractale_upload_complete |
HTTP POST /api/v1/intake/uploads/[id]/complete |
Notify Fractale after the exact bytes have been PUT to the signed URL |
AI clients load tools/list into context on every turn, so tool definitions carry only what a model needs to choose and call a tool. Rules that apply to every tool are in the server instructions; output schemas name the main top-level fields as open objects, and the nested shapes are documented here and in the API spec. src/__tests__/context-budget.test.ts holds the size budgets.
All tools declare outputSchema and return structuredContent on success. Search uses a compact discovery schema shared by Remote and stdio, about 1 KB per result: unchanged dataset IDs, titles, descriptions capped at 240 UTF-8 bytes (about 80 Japanese characters; description_truncated when shortened), update time, language, regions, formats, file count, saved-original presence, the trust block, and an evidence summary (trust_evidence.source.{primary_url,status}, license.{id,name,status}, retrieved_at.{value,status}). has_stored_original: null means unknown; true does not grant download permission. License terms URLs, scope and evidence links, full README, files and legacy duplicate fields remain available through fractale_get_dataset, rather than being repeated for every search hit. Two-line text fallbacks retain candidate IDs, titles, primary sources, license status, retrieval date, trust, saved-original presence and formats for text-only clients. Filter formats with formats (an array or a comma-separated string); the older format argument is accepted as an undescribed alias and filters the same way. REST search retains its existing shape. Dataset detail and file lists include the full trust_evidence; organization list includes field_evidence. Dataset detail text also includes the primary source, license terms and evidence status, scope, and retrieval time so clients that show only text retain the evidence needed for citation. Unknown retrieval time is not replaced by the dataset update time.
While an upload receipt is receiving, files[].status and clientCompletedAt distinguish unfinished transfers from files waiting for checks, and quarantineReason explains a rejected file with a fixed code (infected, size_mismatch, too_large, type_mismatch, unsupported_type, unsafe_archive, blocked_content, processing_error); scanner output is never returned. All are null before an asset exists; existingFileId identifies a reused original. Do not resend completed or processing files. Once every new file is published, retry receipt commit if needed. Cancelling an uncommitted receipt remains available.
For a new dataset, choose an available metadata.slug within the account. Existing and retired handles return 409 DATASET_HANDLE_UNAVAILABLE before transfer; a conflicting concurrent commit ends the receipt as conflict without overwriting existing data or retrying indefinitely. Use a new receipt with another ID. Receipt reservations are released, while stored unlinked originals remain counted until existing cleanup removes them. Choose another ID for a different dataset, even when the file names match. Updating a dataset instead requires dataset_id and base_revision_id.
API errors remain tool errors (isError: true). Error text preserves only recognized public access/license reason codes and a valid retry delay from Retry-After or error.details.retryAfter. It explains when to wait, correct credentials, or inspect access conditions. Arbitrary diagnostic fields and non-JSON upstream error bodies are not copied into the result. Calls are not retried automatically.
When fractale_search receives a query, its text output and structuredContent.search echo the HTTP API's interpretation as { normalized_query, terms, match_mode: "all" }. Browse mode without a query omits search. Paging stops where the API does: offset + limit up to 1,000 with a query and 10,000 without. Past that, narrow the query or filters.
API-First Rule
Remote MCP and REST call the same data handlers directly with the verified identity and permissions. The local stdio package calls the authenticated REST API. It does not use a local catalog as a fallback source of truth.
fractale_searchcalls/api/v1/search.fractale_get_datasetcalls/api/v1/datasets/[id].- Preview, download, files, organizations, and realtime use the same handlers: direct calls in Remote MCP, authenticated REST calls in the local package.
- An empty or failed portal API response is never replaced by an embedded portal list.
Environment
| Variable | Default | Purpose |
|---|---|---|
FRACTALE_API_URL |
https://fractale.online when no credential is configured |
Fractale environment origin; explicit value required with an API key |
FRACTALE_AUTH_TOKEN |
unset | Approved account's read-capable API key for data use. Uploads require publish permission |
Safety (S13): when FRACTALE_AUTH_TOKEN is set, FRACTALE_API_URL must be set explicitly — the server fails fast at startup instead of silently writing to the implicit production default. Without a token, no data use is authorized. The resolved target URL and mode are always printed to stderr at startup.
Identity, usage, and retries
Account admission is checked again on every data request. A valid key or OAuth token does not bypass beta suspension, revoked consent, or current dataset permissions. A malformed explicit credential is not replaced with an ambient browser session. Remote MCP does not accept cookie authentication.
New DCR registrations that omit scope allow requesting the three MCP scopes, alongside openid and profile. Registration is not user consent: authorization defaults to fractale:read, and extra access needs explicit authorization. Existing clients, consents, tokens, and explicitly limited registration scopes are not expanded.
API and MCP successful search, detail, and preview operations use the same per-person UTC calendar-month pool. Normal website browsing, account controls, initialize, tools/list, and issuing a download URL do not consume operations. A successful file delivery start counts once; transfer bytes and stored files use separate capacity limits. No default free monthly allocation is inferred from legacy daily limits. Unconfigured required limits reject operations with 503.
Use one Idempotency-Key for communication retries of the same logical operation. Search, detail and preview retries are allowed for five minutes from admission, with the original recorded month and deadline held fixed. Current permissions are checked again; results may be refreshed without another operation. Changed operation/input returns 409 USAGE_REQUEST_CONFLICT; expiry returns 410. Success responses provide X-Fractale-Request-Expires. Use an explicit dataset version when you need the same version. Short reads do not reserve allowance or bind response hashes. Downloads retain the 24-hour retry lifetime, fixed file/version and Range continuation.
REST accepts 1–128 characters; Remote MCP accepts 1–110, using letters, digits, dots, hyphens, underscores, and colons. A JSON-RPC request id alone is not a stable retry key. An expired retry returns 410. Follow Retry-After on rate limits or temporary failures. If success-commit communication is uncertain, retry with the same ID; a possibly committed success is not refunded speculatively. Download reservations remain recoverable after expiry.
X-Fractale-Usage-Period and X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset describe monthly operation usage when returned. Reset is the next UTC month boundary as epoch seconds. Check the account page on your current environment for configured usage. Keys and connections share the account pool.
Uploads
- Ask the user to choose
private,shared, orpublicif they have not specified visibility. Callfractale_account({purpose: "upload"})before creating an upload. It requestsfractale:readplusfractale:publishwhen needed, without requesting private-read access or creating files. After authorization, repeat it and use a returnedupload_namespaces[].handle; never invent a namespace to trigger authorization. Then callfractale_upload_preparewith a stablerequest_id, metadata, and the complete file list. Existing dataset edits also requiredataset_idandbase_revision_id. Omitting purpose keeps the account read behavior; an empty destination list without publish permission is not evidence that the user has no upload destination. API keys still need their existing publish/admin role; the check does not upgrade a key. - Call
fractale_upload_createfor each new file using itsreceipt_idandfile_id. PUT the exact original bytes toputUrlwith allrequiredHeaders, includingIf-None-Match: *. Do not attach Fractale credentials. OnalreadyUploadedor HTTP 412, do not overwrite; check that file's status withfractale_upload_receipt. - Call
fractale_upload_completefor each file, then check each file's status and the whole upload withfractale_upload_receipt. Resume with the same receipt. - After every file passes processing, call
fractale_upload_commit. Confirm receiptstate="committed"andresultRevisionId. All selected files form one version. Private/shared commits are not public publication; an asset'spublishedstate alone is not a committed dataset.
Originals remain unchanged and separate from derived files. A changed editing base conflicts instead of overwriting another editor's version. Intake configuration, available storage, and working safety processing are required across Web, REST, CLI, and MCP. OAuth/API-key uploads do not implicitly become public.
Clients that support attached-file delivery can optionally call fractale_upload_file for one new dataset with file: { download_url, file_id, mime_type?, file_name? }, explicit visibility, and metadata. The server reads at most 20 MiB from an allowlisted HTTPS file origin without redirects or Fractale credentials, then uses the same receipt processing and explicit commit. The tool declares openai/fileParams. Native ChatGPT has been verified on staging with one CSV through receipt processing and private commit; other clients and file formats are not implied. Unsupported hosts, multiple files, and existing edits use the normal receipt flow or Web/CLI. FILE_ORIGIN_UNSUPPORTED names only the delivery host; do not include the signed URL in the answer. The direct PUT flow still needs client-side file access and HTTP PUT support.
The tools do not expose template, watch, votes, or correction submission.
Useful Flow
fractale_searchto find candidates.fractale_get_datasetto inspect provenance, license, and the actual delivery type.- Inspect
preview_availableon dataset detail orfractale_list_files, then pass its fileidasfile_idtofractale_preview. The tool chooses the stored or registered external source. - For a stored original, pass its
file_idtofractale_downloadafter checking file-specific conditions. An issued URL is not a completed download, and the client may not support that file format. Checkfiles[].url_kind:apidenotes a source API andlanding_pagea source page. A saved capabilities XML describes a service; it does not contain the underlying map or measurements and is not offered as the dataset's original file. Intentionally uploaded HTML/XML originals remain downloadable. - A registered external file can use the same preview tool when supported. If Fractale has no saved original, report the official link rather than promising a Fractale download.
- A landing page alone cannot be previewed or downloaded through MCP; use its source URL as provenance only.
- For uploads, save visibility and the complete file list in a receipt, transfer and inspect each file, then commit the receipt with authorized publishing credentials.
The download result uses response_format: "json" for its response mode, replacing the ambiguous output field format. This does not describe or convert the original. file_name and content_type come from the delivery handler and are null when absent; do not infer another format from them. The tool has no format input; it always requests the JSON response mode.
REST uses dataset_handle as the formal parameter name for preview, files, download, external preview, and realtime-by-dataset. Some MCP tool schemas still use dataset_id for compatibility; pass the same public handle value.
@latest follows the current version. A retained dated revision selects that saved version under current access rules. Missing or deleted revisions return 404; current content or a current external URL is never substituted. Legacy rows with unknown versions or physical storage locations may remain unavailable until verified.
CSV and TSV previews read at most 256 KiB and show at most 10 rows. JSON previews accept at most 4 MiB both before and after decompression and show at most 10 rows. TXT returns original text with preserved line endings, at most 8,000 characters and 10 lines from a 256 KiB prefix. Text is read as strict UTF-8 (including ASCII). Only when that is invalid, and only for a file labelled Shift_JIS or a Japanese dataset (language ja, geo_country JP, or a JP- region), is it read as strict Shift_JIS; the result names the decoding used, and the original bytes are unchanged. Invalid bytes and other encodings are not repaired, guessed, or converted. HTML, XML, and PDF previews are not provided. Archived originals still require processing permission. preview_available states eligibility, not verified upstream availability or successful reading.
Downloads preserve original bytes, without CSV conversion or dynamic multi-file ZIP creation. An original ZIP remains downloadable when allowed. The URL lasts at most five minutes, possibly less if the original credential expires first. Each delivery rechecks current credentials, beta admission, ACL, version, rights, physical storage, and object identity. The first delivered byte counts one operation; empty files count zero. The same grant's Range requests and retries do not add operation counts, while all actual transferred bytes count separately. Keep the handle and source URL for citation; do not persist the temporary URL or forward Fractale credentials with it.
Before using results in analysis, check trust_evidence.source.primary_url, trust_evidence.license, and trust_evidence.retrieved_at, then follow the delivery-specific checks above. Treat status: "verified" as checked evidence, status: "present" as information that exists but is not verified, and status: "unknown" as no record. Unknown values should not be guessed.
Related Docs
- API contract
- Response envelope
- Dataset contract
- Shared read implementation decision
- MCP tools and structured output (implemented protocol revision 2025-11-25)
The installed SDK currently negotiates revisions through 2025-11-25. The 2026-07-28 protocol changes discovery and request metadata; adopting it requires SDK and client compatibility tests, not just adding a version string to the allowlist.
Dataset detail and fractale_list_files return one file page (default 50, maximum 100). If files_page.has_more is true, pass files_page.next_cursor as files_cursor to fractale_list_files; set files_limit only when needed. Cursors retain the saved version and recheck current access. On 409, restart from the first page. Page counts are not dataset totals; partial total bytes and record counts are null. File URLs are no longer duplicated in access_methods.files. Use file_reference with file_id for preview and download. It includes the saved revision when the file belongs to one; unversioned legacy files retain the bare handle and do not promise historical reproducibility.