A collection of FastMCP MCP servers, isolated in a virtual environment (Arch Linux ships an externally-managed Python).
python -m venv .venv
.venv/bin/pip install fastmcpAll servers live in servers/, one module per server, and default to stdio
transport:
.venv/bin/python -m servers.filesystemFile tools (read/write/list/move/delete/search) restricted to configured root
directories. Roots come from the colon-separated FILESYSTEM_ROOTS env var;
if unset, the current working directory is used.
FILESYSTEM_ROOTS=/home/sa/src:/home/sa/Documents .venv/bin/python -m servers.filesystemNote: an unrestricted root defeats the purpose — one served project can edit files in anything under the same root.
Searches the web (DuckDuckGo), Wikipedia, and the Arch Linux repository, and
fetches any page — all rendered to plain text through a local text browser
(w3m/lynx). Results keep a numbered reference list of URLs, so agents can
follow up with fetch_page. Fresh results are not cached; DuckDuckGo's
redirect links are unwrapped to real URLs.
Tools: search_web, search_wikipedia, search_arch_packages, fetch_page.
Browser selection tries WEBSEARCH_BROWSER → lynx → w3m → links;
browser="auto" per call unless overridden. Needs one of w3m, lynx,
links installed (e.g. pacman -S w3m).
WEBSEARCH_BROWSER=w3m .venv/bin/python -m servers.websearchNo new Python dependencies: pages are fetched with the standard library and only rendered by the external browser.
Persistent knowledge-graph memory, stored as JSON (entities with
observations, plus typed relations between them) at
$MEMORY_PATH or $XDG_DATA_HOME/mymcp-memory/graph.json
(~/.local/share/mymcp-memory/graph.json by default).
Every tool takes an optional scope. The default scope global uses the
path above; any other scope is a project-specific graph stored as a sibling
scopes/<scope>.json file. Use global for cross-project knowledge and a
project-named scope (e.g. the repo name) for project-specific memory.
Tools: create_entities (merges observations into known entities),
create_relations (deduplicated, both ends must exist),
add_observations / delete_observations, delete_entities (cascades its
relations), read_graph, search_nodes, open_nodes, plus
list_scopes and delete_scope for scope housekeeping. Writes are atomic.
.venv/bin/python -m servers.memoryConverts files to Markdown (via Microsoft's
markitdown) so agents can consume
them: PDF, Word (.docx), Excel (.xlsx), PowerPoint (.pptx), HTML, CSV, JSON,
XML, EPUB, ZIP listings, images (via OCR), and more. Input files must live
under the allowed roots — the same colon-separated FILESYSTEM_ROOTS env var
the filesystem server uses (cwd by default), so the two servers interoperate.
Tools: convert_file (path → Markdown, truncated to max_chars),
convert_string (in-memory content + file extension → Markdown),
list_allowed_roots.
FILESYSTEM_ROOTS=/home/sa/src:/home/sa/Documents .venv/bin/python -m servers.markitdownDependency: pip install "markitdown[all]" into .venv (plus python-docx,
needed only by smoke_test_markitdown.py to build the test .docx).
- Create
servers/<name>.pywith aFastMCPinstance calledmcpand aif __name__ == "__main__": mcp.run()block. - Install any extra dependencies into
.venv. - Register it in OpenCode (global config lives at
~/.config/opencode/opencode.json). V2 requires servers undermcp.servers. Use{env:NAME}for environment substitution — shell expansions like$HOMEare not expanded in JSON:
Alternatively, register from the shell (where $HOME does expand):
opencode mcp add filesystem --global \
--env "FILESYSTEM_ROOTS=$HOME/src" \
-- /home/sa/src/mymcp/.venv/bin/python -m servers.filesystemAlternatively, register from the shell (where $HOME does expand) — using
the absolute script path means the server also works from any workspace:
opencode mcp add websearch --global -- \
/home/sa/src/mymcp/.venv/bin/python /home/sa/src/mymcp/servers/websearch.pyThen check the connection:
opencode mcp listEach new server gets its own entry under mcp.servers with the same
interpreter and -m servers.<name>.
{ "$schema": "https://opencode.ai/config.json", "mcp": { "servers": { "filesystem": { "type": "local", "command": ["/home/sa/src/mymcp/.venv/bin/python", "-m", "servers.filesystem"], "cwd": "/home/sa/src/mymcp", "environment": { "FILESYSTEM_ROOTS": "{env:HOME}/src" } } } } }