markdownfs (Python)¶
Python client for MarkdownFS — a versioned virtual filesystem for markdown, designed for AI agents.
Install¶
With uv:
Or pip:
Requires Python 3.9+.
Quickstart (sync)¶
from markdownfs import MarkdownFS
mdfs = MarkdownFS(
base_url="https://you-markdownfs.hf.space",
token="...", # or username="alice"
)
mdfs.fs.write("notes/idea.md", "# my idea\n")
text = mdfs.fs.read("notes/idea.md")
listing = mdfs.fs.list("notes")
hits = mdfs.search.grep("TODO", path="notes")
commit = mdfs.vcs.commit("snapshot")
mdfs.vcs.log()
mdfs.vcs.revert(commit["hash"])
Async¶
from markdownfs import AsyncMarkdownFS
async with AsyncMarkdownFS(base_url="...", token="...") as mdfs:
await mdfs.fs.write("a.md", "# hi")
text = await mdfs.fs.read("a.md")
API¶
Constructor¶
MarkdownFS(
base_url: str,
*,
token: str | None = None,
username: str | None = None,
timeout: float = 30.0,
client: httpx.Client | None = None,
)
AsyncMarkdownFS mirrors the sync API and accepts an optional httpx.AsyncClient.
Top level¶
health()→ server statuslogin(username)→ session info
fs¶
read(path)→ strread_bytes(path)→ byteslist(path="")→{ entries, path }stat(path)→ metadata dictwrite(path, content)—contentis str or bytes; parents auto-createdmkdir(path)— recursiveremove(path, recursive=False)copy(src, dst)/move(src, dst)tree(path="")→ tree text
search¶
grep(pattern, path=None, recursive=None)→{ results, count }find(path=None, name=None)→{ results, count }
vcs¶
commit(message)→{ hash, message, author }log()→{ commits }revert(hash)status()→ status text
Errors¶
Non-2xx responses raise MarkdownFSError with .status and .body.
License¶
MIT