Frontmatter MCP
Enables querying Markdown frontmatter data using DuckDB SQL, including support for complex queries with type casting, JSON array operations, and semantic search with vector embeddings.
Provides tools for querying, updating, and managing frontmatter metadata in Markdown files, including batch operations for properties and array manipulation across multiple files.
Supports querying and updating frontmatter in Obsidian vaults with graceful handling of Templater expressions, enabling automated metadata management across Obsidian notes.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Frontmatter MCP find all markdown files with 'project' tag from this year"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
frontmatter-mcp
An MCP server for querying Markdown frontmatter with DuckDB SQL.
Configuration
Basic Usage
{
"mcpServers": {
"frontmatter": {
"command": "uvx",
"args": ["frontmatter-mcp"],
"env": {
"FRONTMATTER_BASE_DIR": "/path/to/markdown/directory"
}
}
}
}With Semantic Search
Semantic search requires large dependencies (~1GB). Set MCP_TIMEOUT to extend installation timeout:
{
"mcpServers": {
"frontmatter": {
"command": "uvx",
"args": ["--from", "frontmatter-mcp[semantic]", "frontmatter-mcp"],
"env": {
"FRONTMATTER_BASE_DIR": "/path/to/markdown/directory",
"FRONTMATTER_ENABLE_SEMANTIC": "true",
"MCP_TIMEOUT": "300000"
}
}
}
}Note: MCP_TIMEOUT is in milliseconds (300000 = 5 minutes).
Related MCP server: knowledgebased
Installation (Optional)
If you prefer to install globally:
pip install frontmatter-mcp
# or
uv tool install frontmatter-mcpTools
query_inspect
Get schema information from frontmatter across files.
Parameter | Type | Description |
| string | Glob pattern relative to base directory |
Example:
// Input
{ "glob": "**/*.md" }
// Output
{
"file_count": 186,
"schema": {
"path": { "type": "string", "nullable": false, "examples": ["notes/a.md"] },
"date": { "type": "string", "nullable": true, "examples": ["2025-11-28"] },
"tags": { "type": "array", "nullable": true, "examples": [["python", "mcp"]] }
}
}
// With semantic search ready, the schema also has
// "embedding": { "type": "FLOAT[256]", "nullable": true }
// (NULL for files without indexed text)query
Query frontmatter data with DuckDB SQL.
Parameter | Type | Description |
| string | Glob pattern relative to base directory |
| string | DuckDB SQL query referencing |
Example:
// Input
{
"glob": "**/*.md",
"sql": "SELECT path, date FROM files WHERE date >= '2025-11-01' ORDER BY date DESC"
}
// Output
{
"columns": ["path", "date"],
"row_count": 24,
"results": [
{"path": "daily/2025-11-28.md", "date": "2025-11-28"},
{"path": "daily/2025-11-27.md", "date": "2025-11-27"}
]
}update
Update frontmatter properties in a single file.
Parameter | Type | Description |
| string | File path relative to base directory |
| object | Properties to add or overwrite |
| string[] | Property names to remove |
Example:
// Input
{ "path": "notes/idea.md", "set": {"status": "published"} }
// Output
{
"path": "notes/idea.md",
"frontmatter": {"title": "Idea", "status": "published"},
"updated": true
}updated is false when the values were already as requested; the file is then not written.
batch_update
Update frontmatter properties in multiple files.
Parameter | Type | Description |
| string | Glob pattern relative to base directory |
| object | Properties to add or overwrite |
| string[] | Property names to remove |
Example:
// Input
{ "glob": "drafts/*.md", "set": {"status": "review"} }
// Output
{ "updated_count": 5, "updated_files": ["drafts/a.md", "drafts/b.md", ...] }Files whose values are already as requested are not written and not listed.
batch_array_add
Add a value to an array property in multiple files.
Parameter | Type | Description |
| string | Glob pattern relative to base directory |
| string | Name of the array property |
| any | Value to add |
| bool | Allow duplicate values (default: false) |
Example:
// Input
{ "glob": "**/*.md", "property": "tags", "value": "reviewed" }
// Output
{ "updated_count": 42, "updated_files": ["a.md", "b.md", ...] }batch_array_remove
Remove a value from an array property in multiple files.
Parameter | Type | Description |
| string | Glob pattern relative to base directory |
| string | Name of the array property |
| any | Value to remove |
Example:
// Input
{ "glob": "**/*.md", "property": "tags", "value": "draft" }
// Output
{ "updated_count": 15, "updated_files": ["a.md", "b.md", ...] }batch_array_replace
Replace a value in an array property in multiple files.
Parameter | Type | Description |
| string | Glob pattern relative to base directory |
| string | Name of the array property |
| any | Value to replace |
| any | New value |
Example:
// Input
{ "glob": "**/*.md", "property": "tags", "old_value": "draft", "new_value": "review" }
// Output
{ "updated_count": 10, "updated_files": ["a.md", "b.md", ...] }batch_array_sort
Sort an array property in multiple files.
Parameter | Type | Description |
| string | Glob pattern relative to base directory |
| string | Name of the array property |
| bool | Sort in descending order (default: false) |
Example:
// Input
{ "glob": "**/*.md", "property": "tags" }
// Output
{ "updated_count": 20, "updated_files": ["a.md", "b.md", ...] }batch_array_unique
Remove duplicate values from an array property in multiple files.
Parameter | Type | Description |
| string | Glob pattern relative to base directory |
| string | Name of the array property |
Example:
// Input
{ "glob": "**/*.md", "property": "tags" }
// Output
{ "updated_count": 5, "updated_files": ["a.md", "b.md", ...] }search
Search document text and return the best-matching passage of each document. Finds paraphrases as well as exact names.
This tool is only available when FRONTMATTER_ENABLE_SEMANTIC=true.
Parameter | Type | Description |
| string | What to look for, as a sentence or keywords |
| string | Glob pattern to search within (default |
| string | Optional SQL condition on frontmatter, same columns as |
| number | Maximum documents to return, 1-50 (default 10) |
| string[] | Headings whose passages are skipped, at any level (optional) |
Example:
// Input
{ "query": "felt lonely on my birthday", "where": "date < '2025-11-01'", "limit": 5 }
// Output
{
"results": [
{
"path": "daily/2025-10-15.md",
"line": 42,
"heading": "Timeline",
"section": ["Daily", "Timeline"],
"text": "Timeline\n- 20:48 Nobody around on my birthday ...",
"score": 0.9312
}
],
"index": { "state": "ready", "has_index": true, "last_run": { "indexed": 1903, "removed": 0, "failed": 0, "error": null } }
}line is where the passage starts in the file. section is the heading path from the top level down to heading, so a passage under a recurring section (for example comments added to each note by a tool) can be told apart; exclude_sections leaves such sections out of the search. Scores are only comparable within one search.
index_status
Get the status of the semantic search index.
This tool is only available when FRONTMATTER_ENABLE_SEMANTIC=true.
Example:
// Output (not started in this session; the first search starts it)
{ "state": "idle", "has_index": false, "last_run": null }
// Output (after a run)
{
"state": "ready",
"has_index": true,
"last_run": { "indexed": 12, "removed": 0, "failed": 0, "error": null }
}has_index stays true while a later refresh runs (the previous index is served). last_run.error says why a run stopped early (for example, the model could not be downloaded).
index_wait
Wait until a running indexing run finishes (or the timeout passes).
This tool is only available when FRONTMATTER_ENABLE_SEMANTIC=true.
Parameter | Type | Description |
| number | Maximum seconds to wait (default 60) |
Example:
// Output
{ "success": true, "state": "ready", "has_index": true, "last_run": { "indexed": 3, "removed": 0, "failed": 0, "error": null } }success is false when the timeout passed while indexing was still running.
index_refresh
Refresh the semantic search index (differential update).
This tool is only available when FRONTMATTER_ENABLE_SEMANTIC=true.
Example:
// Output
{ "state": "indexing", "message": "Indexing started", "target_count": 665 }
// Output (when already indexing)
{ "state": "indexing", "message": "Indexing already in progress" }Technical Notes
Warnings
Tools that read or write many files report per-file problems instead of failing: "warnings": [{ "path": "notes/a.md", "error": "..." }] (malformed frontmatter, a property that is not an array, a frontmatter key named path, which is reserved for the file path). SQL errors fail the call and list the columns of the files table.
Array Operations
batch_array_remove and batch_array_replace act on every occurrence of the value. batch_array_sort skips (with a warning) arrays whose values can't be compared.
All Values Are Strings
All frontmatter values are passed to DuckDB as strings. Use TRY_CAST in SQL for type conversion when needed.
SELECT * FROM files
WHERE TRY_CAST(date AS DATE) >= '2025-11-01'Arrays Are JSON Strings
Arrays like tags: [ai, python] are stored as JSON strings '["ai", "python"]'. Use from_json() and UNNEST to expand them.
SELECT path, tag
FROM files, UNNEST(from_json(tags, '[""]')) AS t(tag)
WHERE tag = 'ai'Writes Keep the File's Formatting
The update tools rewrite only the frontmatter keys whose values change. Other keys, comments, quotes, line wrapping, and the body stay byte for byte. A replaced list keeps its style (tags: [a, b] stays inline, block lists keep their indentation), and a new list follows the style already used in the file. Files are written atomically, so a failed write never leaves a partial file.
Excluding Files
FRONTMATTER_EXCLUDE takes comma-separated globs relative to FRONTMATTER_BASE_DIR, such as IDENTITY.md,_templates. Matching files are left out of query and the write tools, update refuses them, and the semantic index drops them on its next run. A pattern that matches a directory excludes everything under it; **/name.md matches at any depth. Dot directories (.obsidian, .git) are always skipped by the semantic index.
Templater Expression Support
Files containing Obsidian Templater expressions (e.g., <% tp.date.now("YYYY-MM-DD") %>) are handled gracefully. These expressions are treated as strings and naturally excluded by date filtering.
Semantic Search
Each file's body is split into chunks of about 400 characters at headings and line breaks, and each chunk is embedded. Chunks with under 20 characters of text once links, embeds, URLs and list markers are removed are not indexed. A chunk whose text, ignoring checkbox state, numbers and whitespace, appears in 10 or more documents is template text (a daily checklist, for example) and is never returned by search. Indexing starts on the first semantic call (search, a query using embed(), or index_refresh), not at server startup, and only re-reads files whose mtime changed. Dot directories such as .obsidian are skipped.
The search tool combines three signals:
Dense: cosine similarity of query and chunk embeddings. With ruri-v3 models the recommended prefixes (
検索クエリ:/検索文書:) are appliedLexical: BM25 over character bigrams, which needs no Japanese tokenizer and catches exact names and phrases
Rerank: a cross-encoder scores the best chunks of the top candidates from 1 and 2. With the reranker turned off, 1 and 2 are combined by weighted reciprocal rank fusion
On a 1,900-file Japanese vault with 16 queries that each have one known target document, the target ranked first for 2 queries with the previous whole-document embeddings and 13 with this pipeline (top 5: 6 and 15). Reranking adds about 0.3 seconds per query.
SQL access is still available: embedding is the normalized mean of a document's chunk vectors, and embed() encodes a query.
SELECT path, array_cosine_similarity(embedding, embed('feeling better')) AS score
FROM files
WHERE embedding IS NOT NULL AND date >= '2025-11-01'
ORDER BY score DESC
LIMIT 10Environment variables:
Variable | Default | Description |
FRONTMATTER_BASE_DIR | (required) | Base directory for files |
FRONTMATTER_EXCLUDE | (none) | Comma-separated globs no tool reads, writes or indexes |
FRONTMATTER_ENABLE_SEMANTIC | false | Enable semantic search |
FRONTMATTER_EMBEDDING_MODEL | cl-nagoya/ruri-v3-30m | Embedding model name |
FRONTMATTER_EMBEDDING_QUERY_PREFIX | model default ( | Prefix added to queries |
FRONTMATTER_EMBEDDING_DOCUMENT_PREFIX | model default ( | Prefix added to indexed chunks |
FRONTMATTER_RERANKER_MODEL | hotchpotch/japanese-reranker-xsmall-v2 | Cross-encoder for |
FRONTMATTER_CACHE_DIR | FRONTMATTER_BASE_DIR/.frontmatter-mcp | Cache directory for embeddings |
Changing the model or the document prefix rebuilds the cache on the next start. Each schema version has its own file (chunks-v4.duckdb), so sessions still running an older version keep their own store instead of deleting the new one; files of other versions are deleted once no process has them open.
Resource use, measured on a 1,900-file vault (27,700 chunks) on an M-series Mac:
Server memory before any semantic call | about 110 MB (torch and the models are loaded on first use) |
Memory after the first search | about 1.1 GB (torch, both models, vectors, BM25 index) |
First full index | about 90 s; later runs only re-index changed files (300 files: about 15 s) |
One search | about 0.4 s (retrieval about 10 ms, rerank about 0.3 s); the first search also loads the models (a few seconds) |
Cache file | about 35 MB; rewritten after indexing once it grows 25% (and 8 MB) past its compact size |
Model downloads (Hugging Face cache) | about 150 MB each for the embedding model and the reranker |
License
MIT
Available Tools
9 toolsbatch_array_addBatch Array AddB
Add a value to an array property in multiple files.
Inputs: glob (required), value (required), property (required), allow_duplicates. Returns: warnings, updated_count, updated_files
batch_array_removeBatch Array RemoveC
Remove a value from an array property in multiple files.
Inputs: glob (required), value (required), property (required). Returns: warnings, updated_count, updated_files
batch_array_replaceBatch Array ReplaceC
Replace a value in an array property in multiple files.
Inputs: glob (required), property (required), new_value (required), old_value (required). Returns: warnings, updated_count, updated_files
batch_array_sortBatch Array SortC
Sort an array property in multiple files.
Inputs: glob (required), property (required), reverse. Returns: warnings, updated_count, updated_files
batch_array_uniqueBatch Array UniqueC
Remove duplicate values from an array property in multiple files.
Inputs: glob (required), property (required). Returns: warnings, updated_count, updated_files
batch_updateBatch UpdateC
Update frontmatter properties in multiple files matching glob pattern.
Inputs: glob (required), set, unset. Returns: warnings, updated_count, updated_files
queryQueryCRead-only
Query frontmatter with DuckDB SQL.
Inputs: sql (required), glob (required). Returns: columns, results, warnings, row_count
query_inspectQuery InspectBRead-only
Get frontmatter schema from files matching glob pattern.
Inputs: glob (required). Returns: schema, warnings, file_count
updateUpdateA
Update frontmatter properties in a single file.
Only the changed keys are rewritten; other keys, comments, quoting, list style, and the body stay as they are.
Inputs: path (required), set, unset. Returns: path, updated, frontmatter
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 9 tools
Most tools are clearly distinct: update vs batch_update differs by scope, and the batch_array_* tools each perform a different array operation. The main ambiguity is between query and query_inspect, which both involve querying and could be confused at selection time, though their descriptions clarify the difference.
The batch_ and batch_array_ prefixes are used consistently, and operation names like add/remove/replace/unique are predictable. However, query_inspect is an outlier pattern, and the lone query and update names break the otherwise clear scope-prefix convention.
Nine tools is well-scoped for a frontmatter inspection, querying, and editing server. Each tool covers a distinct operation, and the set avoids both thinness and excessive surface area.
The surface covers schema inspection, SQL querying, single-file updates, batch updates, and common batch array operations. Minor gaps remain, such as explicit property deletion/renaming and single-file array helpers, but agents can likely work around these with update and query.
Maintenance
Related MCP Connectors
Search and reason over your Obsidian-style Markdown vault, right from ChatGPT.
Search, read, and safely update Markdown notes in your connected Phasoric knowledge vaults.
Personal context for every AI: search, read, and write back to your private Markdown library.
YouTube transcripts (chunks, phrase search, most replayed moments), PDFs and web pages as Markdown.
Related MCP Servers
- AlicenseAqualityBmaintenanceEnables semantic search over markdown files to find related notes by meaning rather than keywords, and automatically detect duplicate content before creating new notes.32BSD 2-Clause "Simplified"
- AlicenseAqualityCmaintenanceProvides semantic search and a tag-based knowledge graph for any project, auto-discovering local markdown knowledge bases with YAML frontmatter.1014 npmMIT
- AlicenseAqualityDmaintenanceEnables semantic search over local markdown note collections using vector embeddings, with real-time file watching and zero-config setup.4MIT
- AlicenseNot gradedqualityDmaintenanceEnables querying a local health knowledge base with hybrid RAG (vector + FTS5) and exploring backlinks between notes.MIT