
Mini App Mcp
io.github.ynishi由 GitHub 账号 ynishi 发布v0.20.0更新于 Nov 4, 2026
Agent-First CRUD store MCP server — 1 daemon per table, schema.yaml driven, SQLite backend
概览
本地 MCP 服务器,让助手以 schema.yaml 驱动的 CRUD 方式操作 SQLite 表,并支持运行时建表、快照与查询别名。
- 可以做什么
- 在一个或多个 SQLite 表中新增、读取、更新、删除行,支持 schema 校验、UUID 前缀查找、分页与字段投影
- 用 eq/in/like/and/or 过滤器列出和筛选行,并运行已保存或带参数的查询别名
- 通过 info 工具和只读资源查看表定义,包括原始 YAML、解析后的 JSON、派生的 JSON Schema 与内置文档
- 在运行时创建、更新、删除表结构并原子批量执行,支持 dry-run 预览和自动备份 YAML 与数据库
- 对一个或全部表创建时间点 SQLite 快照,保留数量可配置
- 查看、替换、插入单个字符串字段中的行内容,每次修改都记入行历史
- 适用场景
- 适合需要让助手拥有自己的持久化结构化存储时使用,例如问题清单、笔记、关系图或代理记忆,而无需搭建 REST API 或数据库服务。适用于以 schema.yaml 描述表结构的本地单写入场景。
- 运行要求
- 以本地进程运行,通过 stdio 提供容器镜像(ghcr.io/ynishi/mini-app-mcp);README 另说明 HTTP 传输模式。表放在用户目录(默认 ~/.mini-app/)或项目目录(默认 ./.mini-app/)下,每个表需有 schema.yaml 和 SQLite 文件。可选环境变量用于设置目录、备份与快照保留数量以及旧版单表路径,也可写入 .mini-app-mcp.env 文件。
安装
在 SourceWeft 中
- 打开 控制台中的 Mini App Mcp,将其添加到工作区。
- 为需要使用其工具的对话启用该服务。
Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。
其他 MCP 客户端
参照 仓库 中的启动说明。
README
mini-app-mcp
Agent-First CRUD store MCP server — schema.yaml driven, SQLite backend, multi-table in a single daemon.
What it does
mini-app-mcp is a lightweight MCP server that manages one or more SQLite tables in a single running process. The shape of each table is defined entirely by a schema.yaml file; no migrations, no REST API, no GUI. CRUD is exposed exclusively as MCP tools, making it a natural backend for agents that need structured persistent storage.
Design principles
schema.yamlas sole schema authority — field names, types, and required constraints are read from YAML at startup. No field is hard-coded in application code.- Multi-table in one daemon — a single server process discovers and mounts all tables found under the configured User and Project scope directories. A dedicated legacy mode (
MINI_APP_SCHEMA+MINI_APP_DB) preserves the original single-table behaviour. - MCP-only entry point — there is no HTTP/REST/CLI CRUD interface. All reads and writes go through MCP tools.
- Structured JSON errors — every error response carries a machine-readable
codefield so agents can handle failures programmatically.
schema.yaml format
The optional title and description keys at the table level provide human- and AI-readable metadata about the table. Each field entry may also carry an optional description string. All three keys follow the OpenAPI 3.1 / JSON Schema 2020-12 naming convention and are included in info tool output and the schema://json resource.
Supported types: string, number, boolean, array, object.
Configuration
Multi-table mode (recommended)
Tables are discovered at startup by scanning both directories. Project-scope definitions take precedence over User-scope definitions for the same table name.
Legacy single-table mode
When MINI_APP_SCHEMA and MINI_APP_DB are set the server starts in legacy mode, mounting exactly one table. The table argument on all tools may be omitted in this mode.
All variables can also be placed in a .mini-app-mcp.env file in the working directory.
MCP tools
All tools accept an optional table argument that selects the target table. In multi-table mode the argument is required; omitting it returns error code TABLE_REQUIRED. Supplying an unknown table name returns error code TABLE_NOT_FOUND. In legacy single-table mode the argument may be omitted.
MCP resources
In addition to the tools above, the server exposes 7 read-only Resources addressable by URI. Resources are intended for agents that want to fetch the schema definition or reference documentation without invoking a mutating tool.
The info tool and schema://json resource return equivalent content but serve different purposes: info is a callable tool (good for one-off introspection in a conversation), while resources are URI-addressable and can be subscribed to or cached by the client.
Usage
Start the server via --mcp (stdio transport) or --mcp-http (streamable HTTP transport). These are the only entry points; there is no REST/CLI-CRUD surface.
Multi-table mode
Place each table's schema.yaml and <table>.db under ~/.mini-app/<table>/ (User scope) or ./.mini-app/<table>/ (Project scope), then start without any extra environment variables:
Register it once in .mcp.json to serve all mounted tables:
Multi-device mode (streamable HTTP)
Run one central daemon that owns the SQLite files, and connect from any number of devices as remote MCP clients. Because every device talks to the same single process, the single-writer storage model is preserved — no cross-device sync or conflict handling exists or is needed.
Client registration in .mcp.json (any device on the network):
Security model:
- Loopback bind (default):
MINI_APP_HTTP_TOKENis optional. The transport's built-inHostheader validation (loopback-only) guards against DNS rebinding. - Non-loopback bind:
MINI_APP_HTTP_TOKENmust be set — startup is refused otherwise. Every request must then carryAuthorization: Bearer <token>. - Transport encryption (TLS) and any richer authorization are intentionally out of scope; terminate TLS at a reverse proxy if you need it.
Daemon templates for the central host live under contrib/:
- Linux:
contrib/systemd/mini-app-mcp.service(systemd user unit; install instructions in the file header) - macOS:
contrib/launchd/io.github.ynishi.mini-app-mcp.plist(launchd user agent; install instructions in the file header)
To host the central daemon on Fly.io instead of your own machine (persistent volume, edge TLS, bearer auth, daily backup cron), see docs/runbooks/fly-io-deploy.md and contrib/fly/fly.toml.
Legacy single-table mode
Or configure via .mini-app-mcp.env:
Dump / file materialization
mini-app-mcp can write each created or updated row to disk as a Markdown file. This is useful for agents that read context from files, for version-controlling records with git, or for quick human inspection.
How it works
After every successful create or update call the server writes (or overwrites) a file:
The file format is:
delete does not remove the dump file by default (the record stays on disk as an archive).
Enabling dump in schema.yaml
Add a dump: section to your schema.yaml:
Ignoring dump files in git
Add .mini-app/ (or your custom dump.dir) to .gitignore if you do not want dump files tracked by version control:
Schema management
mini-app-mcp exposes four tools for managing table schemas at runtime without restarting the server.
Creating a table
The tool writes <scope_dir>/notes/schema.yaml and immediately registers the new table in the live registry. Calling it again for the same table name returns SCHEMA_EXISTS. The optional title and description arguments are written to the YAML file and are immediately visible via info or schema://json. Individual field entries may also include a description string.
Updating a schema
Before overwriting, the server backs up the existing schema.yaml and a point-in-time SQLite snapshot to <scope_dir>/_backup/notes.<timestamp>.yaml and <scope_dir>/_backup/notes.<timestamp>.db. The live registry is refreshed after the write. No DDL migration is applied — the underlying table structure is unchanged.
Deleting a schema
The schema.yaml is moved to _backup/ and the table is unregistered from the live registry. The SQLite database file is not modified. Dropping or altering the table remains the operator's responsibility.
Atomic batch operations
All ops execute under a single SQLite SAVEPOINT. If any op fails the entire batch rolls back — YAML files are not written and the registry is not changed. All ops in one batch must target the same table.
dry_run preview
All four schema tools accept dry_run: true. In dry-run mode the tool computes and returns affect counts (rows, fields_added, fields_removed) without writing to any YAML file, SQLite table, or backup directory.
Backup retention
Backup files accumulate in <scope_dir>/_backup/. The server automatically deletes the oldest copies beyond the retention limit (default 10 pairs per table). Override the limit with MINI_APP_BACKUP_RETENTION.
Data snapshots
data_snapshot creates a standalone SQLite snapshot of one or more mounted tables without touching any YAML file or altering the schema:
Snapshots are written to <scope_root>/_snapshots/<table>.<unix_secs>.db using the SQLite hot backup API (rusqlite::Connection::backup), so the source database remains open and writable during the operation. The retention limit (default 10) is controlled independently via MINI_APP_SNAPSHOT_RETENTION and never interacts with _backup/.
Snapshot upload (S3-compatible, opt-in)
With the s3-upload build feature, data_snapshot can push each written snapshot to any S3-protocol destination — AWS S3, Backblaze B2 (S3-Compatible API), Cloudflare R2, MinIO — selected purely by endpoint:
Configuration is environment-only (rides .mini-app-mcp.env); credentials never travel through tool-call arguments:
Semantics:
- Configuration is validated before any snapshot is written — a binary built without the feature, or incomplete env, returns
UPLOAD_NOT_CONFIGUREDimmediately. - Individual upload failures are non-fatal: local snapshot and purge results stand, and failures are reported per table in the
upload_errors[]response field. Successes appear inuploaded[]as{table, key, bytes}. - Remote retention is out of scope (KNOWN LIMITATION): the server never deletes remote objects. Configure a bucket lifecycle rule to expire old generations.
- Compatibility notes: uploads are single
PutObjectrequests (no multipart), and nox-amz-checksum-*headers are sent unless you opt in viaMINI_APP_S3_CHECKSUM=sha256— the two aws-sdk-side pitfalls that break some S3-compatible providers do not apply by default.
Alternative without the feature: keep the server as-is and ship snapshots externally, e.g. a cron entry mini-app snapshot → rclone copy ~/.mini-app/_snapshots b2:my-bucket/mini-app-snapshots or a restic backup ~/.mini-app job — equivalent result with the credentials held by the external tool.
Scheduled backups
contrib/backup/mini-app-backup.sh turns the upload into a cron job: it calls data_snapshot(upload=true) on a running --mcp-http daemon (initialize → tools/call over streamable HTTP; deps: curl, jq) and exits non-zero when the call fails or upload_errors[] is non-empty, so failures surface in cron mail / journal / supercronic logs. Against a local daemon:
In the container image the script is bundled as mini-app-backup together with supercronic; setting BACKUP_CRON (e.g. 0 3 * * *) makes the entrypoint run it on schedule alongside the server (see contrib/docker/entrypoint.sh).
Relation graph usage
mini-app-mcp is table-agnostic, but a common pattern is to use a single table as a relation graph layer for agents that need typed edges between nodes (e.g. persona-AI memory: sister_of, member_of_studio, mother_of).
The reference schema lives at examples/schemas/relations.schema.yaml:
Bulk insert (N edges atomically)
Use schema_batch with query ops to register N edges in one SAVEPOINT:
Any op failure rolls back the entire batch.
Bulk replace (edge set full replacement)
Use the dedicated replace op to swap an edge set in one atomic SAVEPOINT. The server handles UUID generation, timestamps, and JSON serialization; the caller supplies the match scope and items list only.
The replace op runs DELETE WHERE (match) + N INSERTs inside a single SAVEPOINT. Both phases roll back together on any failure. The response includes per-op affects:
Semantics:
- Each key in
matchbecomes a separatejson_extract(data, '$.key') = valuepredicate joined by AND. Match value must be a scalar (string/number/bool/null). - Empty
match({}) is rejected with VALIDATION_ERROR to prevent accidental full-table wipes. - Each item in
itemsis validated against the table's schema before any SQL runs. - The
queryop (raw SQL escape hatch shown in Bulk insert) remains available for cases thereplaceop does not cover.
Listing edges (sub-1000 scope)
The list tool returns rows in created_at DESC order with limit capped at 1000. An optional filter argument enables server-side row filtering over schema-validated fields.
Filter variants
or and and accept Vec<ListFilter> recursively, enabling nested compositions to arbitrary depth.
Constraints: field names must be registered in the table's schema.yaml (unknown fields return a VALIDATION_ERROR). Values are type-checked against the schema field's declared type — the same typed scalar validation applied to BatchOp::Replace match values. Omitting filter returns all rows within limit/offset (full backward compatibility).
Mailbox-style OR filter example
Fetch messages addressed to "alice" or "broadcast" in a single call:
For small graphs where client-side filtering is sufficient:
Update semantics: merge vs replace
The update tool supports two modes controlled by the optional "mode" field.
Merge mode (default)
Merge mode follows RFC 7396 (JSON Merge Patch) shallow semantics:
- Absent fields are preserved — keys not present in
datakeep their stored values. - Non-null values overwrite — a key present in
datawith a non-null value replaces the stored value for that key. Nested objects are replaced wholesale (no deep merge). nulldeletes an optional field — if a key's value isnulland the field isrequired: falsein the schema, the field is removed from the stored row.nullon a required field is a Validation error — if a key's value isnulland the field isrequired: true, the call fails withVALIDATION_ERRORbefore any write occurs.- Full schema validation runs on the merged result — after merging, the complete merged object is validated against the schema. Any constraint violation (missing required field, type mismatch) returns a Validation error and the row is not updated.
Replace mode
Replace mode performs a full replacement: data is validated against the schema and then written as-is, completely overwriting the stored row. This is identical to the behaviour of update before version 0.9. Callers that relied on the old default and send partial data objects should switch to mode="replace" to restore the original behaviour.
Choosing a mode
Field projection
list, get, and alias_run all accept an optional fields argument that limits which schema fields appear in the returned data object. id, created_at, and updated_at are always included in the response envelope regardless of the selector.
Selector shapes
Omitting fields is fully backward-compatible — existing callers receive complete rows without any change.
Usage examples
Validation
Unknown field names are rejected with VALIDATION_ERROR before any query executes. Field name validation consults schema.yaml's canonical field definitions — not the actual keys present in stored rows — so projection errors are caught reliably even when the field is simply absent from a particular row.
Query aliases
Query aliases let you save a ListFilter expression (or a MiniJinja filter template) under a short name and replay it — with optional per-call limit / offset overrides — without repeating the filter JSON every time.
Creating a static alias
The alias is stored in the table's own SQLite database under _aliases. Alias names are unique per table; calling alias_create again with the same name returns ALIAS_ALREADY_EXISTS.
Creating a parameterized alias (filter template)
Parameterized aliases use a MiniJinja template string instead of a fixed filter. At run time the caller supplies parameter values that are rendered into the template before execution.
filter_template and filter are mutually exclusive — exactly one must be supplied. params_schema is an optional array of parameter names; supply it to document which keys alias_run expects in its params object.
Running an alias
Static alias (no parameters):
Parameterized alias (with params):
alias_run resolves the stored filter or renders the template and passes the result to Store::list. If limit is supplied at call time it overrides default_limit; if omitted, default_limit from the alias is used. offset is always a runtime-only argument (not stored).
Error cases for parameterized aliases:
Listing and deleting aliases
Alias isolation
Each table's _aliases storage is physically separate: aliases for notes live in notes.db, aliases for issues live in issues.db. There is no global alias namespace and no way for an alias operation to read or write aliases belonging to a different table.
Aggregation
query_aggregate runs COUNT / SUM / AVG / MIN / MAX / GROUP BY over one or many tables in a single tool call. Multi-table sources are joined with literal UNION ALL via SQLite ATTACH DATABASE, eliminating the N+1 round trips that result when callers fetch per-table rows and reduce client-side. The tool is read-only and idempotent.
Shape
Result is externally-tagged so callers can dispatch on kind:
Single-source aggregation
Multi-table aggregation
Multi mounts every backing .db file via SQLite ATTACH DATABASE (limit 10) and composes a UNION ALL between per-table sub-queries before applying the outer aggregate.
Caller is responsible for ensuring all Multi sources share a compatible schema; per-table field validation is a Phase 2 carry. Aggregator-specific errors (empty sources, ATTACH-limit exceeded, nested GroupBy, non-UTF-8 db path) return AGGREGATOR_ERROR (data.code); unknown table names return TABLE_NOT_FOUND; field / identifier rejections return VALIDATION_ERROR.
Global Alias (Phase 2)
Phase 2 unifies aliases across tables in a single global storage
(<project_dir>/_global.db + <user_dir>/_global.db, with lookup
precedence Project → User). The alias_create MCP tool accepts new
optional sources and aggregator arguments so one alias can span
multiple tables and stored aggregate logic:
The legacy table argument is still accepted and is silently
normalised to sources = { "kind": "single", "value": "<table>" };
specifying both table and sources is an error.
Migration: existing per-table _aliases rows are copied into the
project-scope _global_aliases automatically on every
TableRegistry::mount_from_dirs call. The migration is lossless
(all five legacy fields preserved + sources = Single(<table>) filled
in) and idempotent (INSERT OR IGNORE skips collisions), so it is safe
to run on every server restart. Per-table _aliases tables are not
deleted, preserving a rollback path until a future minor release.
Phase 2 limitations
Multi/Patternsource aliases require anaggregator; running them without one returns a structured error (the per-tablelistpath cannot serve cross-table rows).- Pattern glob supports
*only (one or more);?/[]are reserved for a future revision. - Pattern matching that resolves to zero tables returns
AGGREGATOR_ERRORatalias_runtime (early surface — does not defer toATTACH DATABASE). - Filter validation uses the schema of the first source table only;
cross-table schema divergence is the caller's responsibility (same
constraint as
query_aggregate). - Legacy single-table mode (no
MINI_APP_USER_DIR/MINI_APP_PROJECT_DIR) falls back to the per-tableStore::alias_*path;Patternsources are rejected in this mode.
Row history auto log
Every create, update, and delete call automatically writes a full-JSON snapshot of the affected row into a _row_history table inside the same SQLite database. The snapshot is written atomically inside the same transaction as the data change — either both the data DML and the history record commit, or neither does.
What gets recorded
Every history record also carries a monotonically increasing version counter (scoped per table + row id) and a recorded_at Unix seconds timestamp.
The pre-operation state of any entry is simply the previous entry's data_json, so it is not stored again (the legacy prev_data_json column remains readable in databases written by older versions, but new entries leave it null — this halves history write volume).
Two-tier storage: raw + compressed archive
History is never discarded, but it must not eat the disk either (a single 178KB row updated 949 times used to leave 222MB of full-copy history). The raw _row_history table only keeps the newest entries per row; older entries are automatically compacted — inside the same write transaction — into zstd-compressed JSONL chunks in _row_history_archive. Near-duplicate JSON versions compress at roughly three orders of magnitude, so long histories stay cheap while remaining fully restorable: row_restore and version listings read through the archive transparently.
Opting out per table (history: off)
Tables written at high frequency by automated jobs (heartbeat stamps, log-cache style rows) can disable history entirely in schema.yaml:
With history: off no _row_history entry is written for any mutation of that table (and row_restore has nothing to restore from — use it only where per-write history has no recovery value).
Restoring a row with row_restore
row_restore fetches the latest snapshot at or before a given Unix timestamp and writes it back as the live row. If the row was deleted it is re-inserted with the same id; if the row still exists it is replaced with the snapshot data.
The response is the same shape as get — a full row object with id, data, created_at, and updated_at.
Purge SOP
History records are not purged on every update. Purge is a separate operation performed by calling purge_old_history in application code with the desired retention policy:
- Retention window: 30 days (records older than 30 days are deleted)
- Max versions per row: 100 (oldest versions beyond 100 are deleted per row)
Purge is intentionally not wired to any automatic hook so that history accumulation does not add latency to normal create / update / delete calls.
Partial edit tools
Three tools let agents view and surgically edit individual string fields without fetching or replacing the entire row. Non-string fields (arrays, objects, numbers, booleans) are rejected with TYPE_ERROR.
content_view
Return the contents of a string field with line numbers (cat -n style). Pass view_range to limit output to a contiguous slice (1-indexed, inclusive on both ends).
content_replace
Replace a unique occurrence of old_str with new_str inside a string field.
If old_str does not appear the tool returns STRING_NOT_FOUND. If it appears more than once and replace_all is not set, the tool returns AMBIGUOUS with a candidates list.
content_insert
Insert one or more lines into a string field at a specific position.
line values greater than total_lines + 1 return OUT_OF_RANGE. All three tools record changes through the normal row_history hook, so every edit is fully auditable and restorable via row_restore.
Storage notes
SQLite databases are opened in WAL journal mode for safe concurrent access during reload. Sidecar files <db>.db-wal and <db>.db-shm are created next to each .db file — these are managed by SQLite and should not be deleted manually.
MCP Registry
mini-app-mcp is listed on the MCP Registry. The OCI image is published to GitHub Container Registry on every tagged release.
Docker (no Rust toolchain required)
License
MIT OR Apache-2.0
来源:README.md,提交 bc3de65
工具
0版本历史
2- v0.20.0最新Oct 21, 2026
- v0.19.1Sep 16, 2026
评分
已满足适用检查项的 50%
该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。
- 近 30 天内可连通25 分
请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。
- 已声明认证方式10 分
请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。
- 已列出工具15 分
请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。
- 描述必需15 分
- 图标10 分
- 文档15 分
- 许可证10 分