myopenfund-mcp
Created and maintained by Marc Jeulin, part of MyOpenFund.
One MCP server over the MyOpenFund bricks: official documents and pipeline health, cited passage search over the embedded corpus, and company data.
Any MCP client (a desktop assistant, a coding agent, your own agent, a local model) gets outcome-oriented
tools over MyOpenFund's data: find official primary-source documents, read their facts with provenance
(doc_id, dates, source URLs), search the text of the documents by meaning and get passages to cite, count
the corpus, check the ingestion pipeline's health. Toolsets are
enabled per deployment: a toolset whose environment variables are not set is not configured, so it is not
mounted, and server_info says so. A toolset whose variables are set but whose extra is not installed
stops the server at start with a clear configuration error (it never runs silently without it).
MyOpenFund manages nobody's money and gives no investment advice. This server returns documents and facts from official sources, with their provenance. What you do with them is your decision.
- Two transports, same code: stdio for local use, Streamable HTTP (bearer tokens) in a Docker image.
- Host-agnostic: the same image runs on a laptop, on a host on a private network or on a cloud VM;
everything deployment-specific comes from
MOF_*environment variables. - Deterministic: no tool needs a hosted LLM (see Local models).
Contents
- Try it at home, without any infrastructure
- Quick start (stdio)
- HTTP deployment
- Deploying the rag toolset
- Tools
- Errors
- Tiers and tokens
- Configuration and limits
- Local models
- Roadmap
- Development
Try it at home, without any infrastructure
No database, no store, no server to run: the company tools read the SEC's public EDGAR data directly, keep what they fetch in a cache folder on your machine, and search the filings with a small embedding model that runs locally. You need Python 3.12+ (through uv), an MCP client, and about 2 GB of free disk space and memory for the model.
1. Install and run. Straight from PyPI, nothing to clone (the MCP client runs it for you, see step 2):
uvx --from "myopenfund-mcp[companies,filings]" myopenfund-mcp serve
or install it in a virtual environment:
python -m venv .venv
.venv/bin/pip install "myopenfund-mcp[companies,filings]"
2. Add it to your assistant and give your own SEC contact. In an MCP client that reads an mcpServers
block (Claude Desktop, Claude Code's .mcp.json, and most others):
{
"mcpServers": {
"myopenfund": {
"command": "uvx",
"args": ["--from", "myopenfund-mcp[companies,filings]", "myopenfund-mcp", "serve"],
"env": { "MOF_SEC_CONTACT": "Your Name your.email@example.com" }
}
}
}
Replace the placeholder with your own name and e-mail. The SEC's fair-access rules ask every automated
client to identify who is behind it, and it blocks the ones that do not. The value stays on your machine:
it is sent only to sec.gov, in the User-Agent of each request, and it is never logged, shown in a tool
result or put in an error. Without it the company tools are not mounted. Over stdio there is no token and
nothing listens on the network.
3. Ask a question. The scenario the MyOpenFund README suggests:
Since 2022, how have the big cloud providers financed their AI spending? Show me their capital expenditure and their debt quarter by quarter, how their shares performed after each annual report, and quote what each one says about it.
The assistant resolves the companies (companies_resolve), reads their capital expenditure and debt
(companies_fundamentals, companies_facts), gets the date each annual report became public
(companies_filings, the accepted_utc of each 10-K is the event date), and quotes the reports
(companies_fetch_filings, then companies_search_filings and companies_read_filing). Share prices are
not in this server: they come from the market-data toolset, which is not part of this server yet, so the
"how did the shares perform" part needs another source of prices; the event dates are what this server
gives it.
What is fetched, and where it is kept
- Facts and filing lists come from SEC's
companyfactsandsubmissionsendpoints, at mostMOF_SEC_MAX_RPSrequests per second (SEC's own limit is 10). Filings come from SEC's archive and are converted to text, then split into passages and embedded locally. - Everything is cached under
MOF_CACHE_DIR(default:~/.cache/myopenfund-mcpon Linux,~/Library/Caches/myopenfund-mcpon macOS,%LOCALAPPDATA%\myopenfund-mcpon Windows): HTTP answers, the local filings index and the model. Facts and filing lists are reused for 24 hours (MOF_CACHE_TTL_COMPANYFACTS_H,MOF_CACHE_TTL_SUBMISSIONS_H); the HTTP part is capped atMOF_CACHE_MAX_GB(20 GB), the model and the index are never evicted. Delete the folder to start over. - One server per cache folder. The filings index is locked by the process that opened it: a second
MCP server, or
warm, on the sameMOF_CACHE_DIRanswers[index_unavailable]for the filings tools (the other tools work). Give each its ownMOF_CACHE_DIR, or stop the first. - Upgrading from an earlier build. The index folder under
<MOF_CACHE_DIR>/index/is named after the model and the chunker version; folders written by an earlier chunker (a chunker version not endingttl2-fm1: before the chunk titles stated the period, or before 0.2.1) are no longer read: their documents are fetched and indexed again, and the old folders are orphaned, safe to delete. - The embedding model is downloaded once, at the first fetch of filings: about 1.1 GB, pinned to one revision. Later runs read it from the cache. No other model or data file is downloaded.
MOF_CACHE=offkeeps no HTTP entries and no index between runs: they live in a temporary folder removed at exit, sowarmrefuses to run. The model files (1.1 GB) still stay in the persistent cache folder, which is created even withoff, so the model is not downloaded again. Use it for a throwaway test only.
Where each company is read from (MOF_COMPANIES_SOURCE)
auto (the default) uses your own company store when you have one and SEC otherwise; with no store
configured, as here, everything comes from SEC. store reads only the store, sec only SEC (needs
MOF_SEC_CONTACT). Every row of a company tool says its source (store or sec_live) and, when the choice
needs explaining, a reason (for example freshness_unchecked: SEC could not be asked, so the store's
answer is not checked for freshness). A store is optional: if you run one, point MOF_COMPANIES_CATALOG and
MOF_COMPANIES_DATA_ROOT at it (see Companies and datasets).
How long it takes
The first question about a filing is slow because the filing is downloaded, converted and embedded on your machine; later questions about it are answered from the index. Measured on 4 CPU cores in a container (2026-11, Microsoft, Amazon, Alphabet, Meta and Oracle, their 22 10-Ks since 2022):
| Step | Time |
|---|---|
| Embedding model download (once, 1.1 GB) | 18 s on a fast connection; minutes on a home one |
Facts (companies_fundamentals), first call for a company |
17 to 26 s; later calls under 1 s |
| One 10-K downloaded, converted and indexed (390 to 720 passages) | 95 to 216 s, median 159 s |
First quotable passage (Item 7) after companies_fetch_filings of one company (its 4-5 10-Ks) |
24 to 45 s |
| First quotable passage of each company when the five are fetched in one call (22 10-Ks) | Microsoft 42 s, Amazon 55 s, Alphabet 67 s, Meta 80 s, Oracle 93 s (fetch call 3 s) |
| The five companies' 22 10-Ks, fetched in one call, all indexed | 56 min |
| A search once indexed | 0.25 s |
(First-passage times measured 2026-11-26 with the model already on disk; the model download is not
counted.) The indexer takes the companies in turn: first one batch (MOF_INDEX_BATCH_SIZE, 32 passages,
about 10 s) of the MD&A (Item 7) of each company's newest document, then the rest of the MD&As, newest
documents first, then everything else (MOF_INDEX_FIRST_BATCHES). So each of the five companies
fetched in one call got quotable passages within two minutes (42 s, then about 13 s per extra company
on 4 CPU cores), while the full documents take longer. The order covers the documents fetched and cut
ahead, at most MOF_INDEX_FETCH_AHEAD (default 40, the default MOF_FILINGS_MAX_DOCS, so a whole
fetch call): beyond the bound, documents cut later get their MD&A only after the remainders of the
documents already cut. For several companies
over several years, run warm beforehand. On Apple Silicon, set
MOF_RAG_ONNX_PROVIDER=coreml to run the embedding on the Mac's accelerator instead of the CPU (cpu
is the default). MOF_RAG_ONNX_THREADS limits the CPU threads. While a filing is still being prepared,
the tools say so and which documents are not ready; ask again a little later.
Prepare the filings overnight (warm)
Fetch and index the filings of the companies you will ask about before you ask, with the same code the
tools use. Use the same MOF_SEC_CONTACT and the same cache folder as your assistant's configuration:
export MOF_SEC_CONTACT="Your Name your.email@example.com"
uvx --from "myopenfund-mcp[companies,filings]" myopenfund-mcp warm \
--companies MSFT,AMZN,GOOGL,META --forms 10-K,10-Q --since 2022-01-01
Progress goes to stderr; run it again to resume, documents already ready are not fetched again. Stop
your assistant's MCP server first, as only one process can hold the index. More in
Warming the cache ahead of questions.
Small local models
A small local model (for example one served by Ollama, through an MCP-capable client) can call these
tools; see Local models. Ask one question at a time, name the companies and the period,
and check the quoted passages and figures against the url link of each result's source, as reading
long filings and combining numbers is where small models struggle most.
MyOpenFund manages nobody's money and gives no investment advice. What you do with these documents and facts is your decision.
Quick start (stdio)
Prerequisites:
- Python 3.12+;
- read access to the vault database as the read-only role
vault_readonly(never a writing role).
Run it straight from PyPI, nothing to clone:
uvx --from "myopenfund-mcp[vault]" myopenfund-mcp serve
or install it in a virtual environment:
python -m venv .venv
.venv/bin/pip install "myopenfund-mcp[vault]"
The extras pick the toolsets: [vault] (documents and pipeline health), [companies] (company data:
pip install "myopenfund-mcp[companies]"), [rag] (passage search: pip install "myopenfund-mcp[rag]")
and [filings] (the filing-text tools over a local index, with [companies]:
pip install "myopenfund-mcp[companies,filings]"), combinable ("myopenfund-mcp[vault,companies,rag,filings]"). The server is listed in the official MCP Registry as io.github.MyOpenFund/myopenfund-mcp. The PyPI distribution is myopenfund-mcp; the
command (myopenfund-mcp), the import name (myopenfund_mcp) and the repository name are unchanged. The
MyOpenFund packages it builds on (myopenfund-vault-query, myopenfund-open-data-store,
myopenfund-company-corpus, myopenfund-rag-engine) are installed from PyPI by the extras.
Migration. If this environment installed the packages under their former names (from a clone or a git
URL), run pip uninstall -y vault-query open-data-store company-corpus rag-engine before installing
myopenfund-mcp: the old and the new distributions own the same import packages.
Upgrading from 0.1.0. 0.2.0 adds the no-vault mode (see Try it at home):
- New extra
[filings](the filing-text tools,myopenfund-rag-engine[local,graph]);[companies]now installsmyopenfund-company-corpus[live](live SEC reads), and[rag]and[filings]both needmyopenfund-rag-engine0.2. Reinstall with the extras you use, e.g.pip install -U "myopenfund-mcp[vault,companies,rag,filings]". MOF_SEC_CONTACT(your name and e-mail) mounts the company tools without a store and is needed for the filing-text tools. A deployment with a store and noMOF_SEC_CONTACTkeeps reading the store only; one that sets it may also ask SEC, asMOF_COMPANIES_SOURCE(defaultauto) decides.- Reading SEC writes a cache folder,
MOF_CACHE_DIR(default under your user cache directory; in a container, point it at a writable volume), holding HTTP answers, the filings index and the 1.1 GB model. - Still installed under the pre-PyPI names (
vault-query,open-data-store,company-corpus,rag-engine)? Uninstall them first, as in the migration line above.
Upgrading from 0.2.0. 0.2.1 needs myopenfund-rag-engine 0.2.1, whose chunker keeps text 0.2.0
lost: a filing section starting on a --- page break lost its first page (about 2 % of the text of a
10-K, up to 5 % for some issuers). Upgrade with pip install -U "myopenfund-mcp[companies,filings]"
(with the extras you use). Re-indexing happens automatically: the chunker version is now
v2-t480-o32-ttl2-fm1, so the filings indexed by 0.2.0 are fetched and indexed again at the next
companies_fetch_filings (or warm), and the old folders under <MOF_CACHE_DIR>/index/ can be deleted.
To try the latest main before a release (the dependencies still come from PyPI):
pip install "myopenfund-mcp @ git+https://github.com/MyOpenFund/myopenfund-mcp"
Register it with your MCP client. With Claude Code:
claude mcp add myopenfund \
-e MOF_VAULT_DATABASE_URL='postgresql://vault_readonly:<password>@<host>:5432/documents?sslmode=verify-full' \
-- /path/to/.venv/bin/myopenfund-mcp serve
Any other client: run the command myopenfund-mcp serve (stdio is the default transport) with the same
environment. Over stdio there is no token: the local user owns the process and gets every tier
(MOF_MCP_TOKENS, if set, is ignored with a warning on stderr). Then ask the client to call server_info.
The snippet above stores the database URL, password included, in the MCP client's configuration file. Use the read-only role
vault_readonlyonly, and keep that file private.
HTTP deployment
MOF_MCP_TRANSPORT=http serves Streamable HTTP at MOF_MCP_PATH (default /mcp). It requires
MOF_MCP_TOKENS: the HTTP server never runs unauthenticated, and refuses to start without tokens.
The server speaks plain HTTP. Network exposure and TLS are the deployment's job, never the public
internet by default. The repository ships a generic Dockerfile,
compose.example.yaml and .env.example; nothing host-specific
lives in it.
cp compose.example.yaml compose.yaml
cp .env.example .env # never committed
.venv/bin/myopenfund-mcp hash-token alice # once per client, see Tiers and tokens
.venv/bin/myopenfund-mcp hash-token agent-1 --tier read
# edit .env: MOF_MCP_TOKENS, MOF_VAULT_DATABASE_URL, MOF_MCP_BIND_ADDR ...
docker compose up -d --build
No venv on the deployment host? Run hash-token in the container instead (after cp .env.example .env,
which compose needs, and with the image built):
docker compose build
docker compose run --rm mcp myopenfund-mcp hash-token alice
hash-token prints the token on stderr (copy it to the client) and only the MOF_MCP_TOKENS
entry on stdout, so redirecting stdout (>> entries.txt) never writes the clear token into a file.
The image runs as a non-root user (uid 10001), listens on 0.0.0.0:8000 inside the container, and
the compose file publishes it on 127.0.0.1 of the host unless MOF_MCP_BIND_ADDR says otherwise. In
.env, leave MOF_MCP_TRANSPORT and MOF_MCP_HOST unset: the image sets them. The compose file also runs it with a
read-only root filesystem (writable /tmp only), no Linux capabilities and no-new-privileges.
Pinned versions
Every rebuild of the image and every start of the install service installs the same Python packages,
the ones the CI tested:
- Base image:
PYTHON_IMAGEin theDockerfile, a tag and a digest (python:3.13.<patch>-slim-<debian>@sha256:...); the variant without a built image incompose.example.yamluses the same value. The image's Python and pip come with it. - PyPI runtime dependencies:
constraints.txt, the exact version of every dependency of[vault,companies,rag,filings]on that image (fastmcp and everything below it), passed with-c. - Build backend: this package is built from source at every install of the image, in an isolated
build environment that
-cdoes not reach;build-constraints.txtpins its backend (hatchling and its dependencies, pluseditables, which hatchling needs for the CI's editable install), passed with--build-constraint. Thelockedjob runsscripts/check_constraints.py --build, which fails when a build requirement is not pinned in the file at a version its specifier allows. - The MyOpenFund packages (
myopenfund-vault-query,myopenfund-open-data-store,myopenfund-company-corpus,myopenfund-rag-engine): ordinary PyPI dependencies, capped inpyproject.tomlbelow their next breaking release (>=0.m.n,<0.(m+1), e.g.myopenfund-rag-engine>=0.2.1,<0.3) and pinned to one exact version inconstraints.txt.
The install service passes both files of the release's tag as URLs and pins the package itself (the constraints files of the release's tag v<version>):
pip install -c https://raw.githubusercontent.com/MyOpenFund/myopenfund-mcp/v<version>/constraints.txt \
--build-constraint https://raw.githubusercontent.com/MyOpenFund/myopenfund-mcp/v<version>/build-constraints.txt \
'myopenfund-mcp[...]==<version>'
so the host also needs outbound HTTPS to raw.githubusercontent.com at each start, besides PyPI.
Not covered: file hashes (pins are == versions, not --require-hashes) and, outside Python, the DuckDB extensions the companies toolset downloads at start and the embedding model
(pinned by its own revision, see Deploying the rag toolset).
The CI runs the tests twice: floating within the ranges of pyproject.toml (Python 3.12 and 3.13, so a
coming break shows early) and locked (locked job: the image's Python, both constraint files, then
scripts/check_constraints.py, which fails when a runtime dependency of the server is missing from
constraints.txt or installed at another version, e.g. a new dependency brought by a release, and when an
extra it is asked to check does not exist, then scripts/check_constraints.py --build, which checks the build backend's pins). A test checks that the job's Python is
the patch of PYTHON_IMAGE.
Upgrading is a deliberate change in a pull request: for the base image, look up the digest of the new
tag (docker buildx imagetools inspect python:<tag>) and replace PYTHON_IMAGE in the Dockerfile and the
image lines of compose.example.yaml; for the packages, run python3.13 scripts/update_constraints.py (on
linux x86_64, the image's platform) and commit both regenerated files. The locked job then tests the new set.
A client connects with its token, e.g. with Claude Code:
claude mcp add --transport http myopenfund https://<your-host>/mcp \
--header "Authorization: Bearer <token>"
Connect from any MyOpenFund repo
Each MyOpenFund code repo ships a .mcp.json holding variables only, never an address or a token. Clone one
repo or all of them: each works on its own, including in new worktrees, and projects outside MyOpenFund do not
see the server. Set these two client-side variables once, in your shell profile or a private file it loads:
export MOF_MCP_URL=https://<your-host>/mcp
export MOF_MCP_TOKEN=<token> # your client token, the one from hash-token
MOF_MCP_TOKEN is the client's clear token; MOF_MCP_TOKENS is the server's list of digests. Claude Code asks
you to approve the server once per project. Start it from a shell that has the variables. Without them, it
warns about the missing variables and everything else keeps working.
Pattern 1: a host on a private network
A home server, a NAS or an office machine reachable only over a VPN or a private interface.
- Set
MOF_MCP_BIND_ADDRto the host's private address (the VPN or LAN interface), never0.0.0.0on a host that also has a public interface. - If the vault Postgres runs as a compose stack on the same Docker host, do not publish its port: join its
Docker network instead (uncomment the
networksblocks incompose.yaml, setMOF_VAULT_DOCKER_NETWORK) and use the database service name as<host>inMOF_VAULT_DATABASE_URL. On that private Docker network,sslmode=disableis acceptable. - TLS: the VPN already encrypts the traffic; for HTTPS on top, put a reverse proxy holding a certificate for the private name in front, or use your VPN's own HTTPS feature if it has one.
Pattern 2: a cloud VM (or container service)
- Keep the default
MOF_MCP_BIND_ADDR=127.0.0.1and terminate TLS at a reverse proxy on the same VM (Caddy, nginx, Traefik) proxying to127.0.0.1:8000, or run the container behind the provider's load balancer with a TLS listener and a security group that only admits the balancer. - Health check for the load balancer or orchestrator:
GET /healthanswers200with the bodyok, without a token (it reveals no version and no data);/mcpkeeps requiring one. The image's DockerHEALTHCHECKuses the same endpoint. - Reach the vault database over the provider's private network with
sslmode=verify-fulland the provider's CA certificate (sslrootcert=...).sslmode=requireis a fallback: it encrypts but does not authenticate the server. - Restrict who can reach the HTTPS endpoint (IP allow-list, private load balancer) wherever you can: the bearer token is the only authentication in v1.
Deploying the rag toolset
The rag_search tool needs a Qdrant collection already filled by the ingestion (rag-engine through the
data-orchestrator) and the embedding model intfloat/multilingual-e5-base as an ONNX file. The server only
reads: it never creates a collection, an index or a point. Angle brackets are placeholders: no real host
name, address or key belongs in this repository or in a compose file under version control.
The steps below work as they are for the two ways compose.example.yaml runs the server: the image built
from this repository, or its variant without a built image, where an install service puts the package
into a volume at each start of the stack.
-
A read-only API key on the Qdrant side. In the Qdrant stack, set a read-only key next to the main one (
QDRANT__SERVICE__READ_ONLY_API_KEY) and restart Qdrant. The MCP gets that key only. Check it from any host that reaches Qdrant. The key is typed at a prompt that shows nothing (read -s, in bash and in zsh) and kept in a variable of that shell: it is written neither in a command nor in the shell history.# Run this first line alone and type the key: pasted with the lines below, some shells # (bash before 5.1, the bash of macOS) take the next pasted line as the key. printf 'read-only key: '; read -rs MOF_KEY_CHECK; echo curl -s -o /dev/null -w '%{http_code}\n' -H "api-key: $MOF_KEY_CHECK" http://<qdrant-host>:<qdrant-port>/collections/<collection> curl -s -o /dev/null -w '%{http_code}\n' -H "api-key: $MOF_KEY_CHECK" -H 'Content-Type: application/json' -X PUT -d '{"vectors":{"size":4,"distance":"Cosine"}}' http://<qdrant-host>:<qdrant-port>/collections/mof-key-check
-
The first request is a read: it must print
200(401or403: Qdrant does not accept the key;404: no collection of that name). -
The second is a write: it must print
403. The key cannot write, and nothing was created. -
If the second prints
200, the key can write: it is not a read-only key, and the request has just created an empty collection namedmof-key-check. Delete that collection, then give the MCP a real read-only key and run the two checks again:curl -s -o /dev/null -w '%{http_code}\n' -H "api-key: $MOF_KEY_CHECK" -X DELETE http://<qdrant-host>:<qdrant-port>/collections/mof-key-check
-
At the end:
unset MOF_KEY_CHECK. -
Qdrant behind TLS: write
https://in these URLs, with the port TLS is served on; addQDRANT_HTTPS=trueto the command of step 2 and setMOF_RAG_QDRANT_HTTPS=truein step 6. The key then no longer travels in clear.
-
-
Payload indexes, once, from the data side. The filters and the list of valid filter values use Qdrant's payload indexes. Whoever owns the collection creates them, once per collection, with a key that can write, from an environment where
rag-engineis installed (the ingestion's own, or any venv withpip install "myopenfund-rag-engine>=0.2.1,<0.3", the range this server is built on). Give the host AND the port: the engine's default port is 6333. The key is typed at a prompt here too:# Alone first, as in step 1. printf 'key that can write: '; read -rs QDRANT_API_KEY; echo; export QDRANT_API_KEY QDRANT_HOST=<qdrant-host> QDRANT_PORT=<qdrant-port> python -c "from rag_engine.store import QdrantStore; print(QdrantStore().ensure_payload_indexes('<collection>'))" unset QDRANT_API_KEY
It prints the indexes it created (
[]when they were all there: running it again does nothing). The MCP never does this (its key cannot). Without the indexesrag_searchstill answers, more slowly: a filtered search reads every point (about 0.15 s on 34,000 points), and the valid filter values are read by one scroll of the collection, in the background (up to 100,000 points; beyond that, filter values are no longer checked).The engine (
myopenfund-rag-engine0.1) also creates the datetime indexes ondate_startanddate_end(payload schema version 2). Once they exist,automode applies date bounds to the intervals (withinMOF_RAG_DATE_FILTER_REFRESH_Sseconds, without a restart of the MCP). That is safe before the payloads carry their intervals (a point without one is still found by itsdate), but a month or a year document is found by its whole period only once the orchestrator'ssync-metadatahas written the intervals;sync-metadatacreates the two indexes itself (see Dates). -
The
[rag]extra in the install line. With the built image:MOF_EXTRAS=vault,ragas a build argument (compose.example.yaml). Without a built image:'myopenfund-mcp[vault,rag]==<version>'in theinstallservice. From PyPI:pip install "myopenfund-mcp[vault,rag]". No PyTorch is installed: queries are embedded on the ONNX runtime, on CPU. Without the extra the server refuses to start as soon asMOF_RAG_QDRANT_HOSTis set. -
Fill the model cache, once. The model is about 1.1 GB. It is pinned to one revision and every file is hash-checked at each start, so a changed or damaged file is refused. The fill is a one-shot container with the cache volume mounted read-write; it needs outbound HTTPS to
huggingface.coand to the hosts it redirects downloads to (underhf.co), and a writableHOME. The exact line it runs:python -c "from rag_engine.config import Settings; from rag_engine.embedding import make_embedder; make_embedder(Settings(backend='onnx', model_cache='/models')).release(); print('model cache ready')"
It succeeded when its last line is
model cache readyand its exit code is 0. Anything else (a traceback, another exit code) is a failed fill: the service would start without the model.- Built image:
docker run --rm -v myopenfund-mcp-rag-models:/models myopenfund-mcp python -c "..."with the line above (the image owns/modelsas its service user and setsHOME). - No built image: the
rag-model-fillservice ofcompose.example.yamlruns it for the first start of the stack (theinstallservice gives the volume to the service user). Check both signs withdocker compose logs rag-model-fill(last linemodel cache ready) anddocker compose ps -a rag-model-fill(Exited (0)), then delete that service. - Without Docker: the same line in the server's venv, with your own absolute directory in place of
/models.
Run again on a filled cache, the line downloads nothing, verifies the files and prints the same line. A filled directory can be copied from another host instead, keeping its symbolic links (
snapshots/links intoblobs/):cp -a,rsync -aortar, never a copy that follows or drops links. - Built image:
-
The service (
compose.yaml):- the cache volume mounted read-only at
/models; mem_limit: 3gor more: the process peaks at about 2 GB at every start, while the model loads, and stays around 1.5 GB afterwards; with a CPU limit, also setMOF_RAG_ONNX_THREADSto it;ORT_DISABLE_TELEMETRY=1andHF_HUB_OFFLINE=1in its environment (see Outbound connections);- a healthcheck start period of 60 s: the port opens once the model is loaded, 5 to 7 s from a warm
disk on 4 cores, more than 30 s when the 1.1 GB file is read from a cold disk (the image's
HEALTHCHECKhas it); - a route to Qdrant. On the same Docker host, join the Qdrant stack's network and use its service
name and its internal port (
MOF_RAG_QDRANT_HOST=<qdrant-service>,MOF_RAG_QDRANT_PORT=6333unless that stack changed it), without publishing anything. Otherwise use a host port Qdrant publishes on a private interface (MOF_RAG_QDRANT_HOST=<private-address>,MOF_RAG_QDRANT_PORT=<published-port>). Without TLS the key travels in clear: private network only.
- the cache volume mounted read-only at
-
The variables, in
.env:MOF_RAG_QDRANT_HOST(the host alone:qdrant:6333is refused),MOF_RAG_QDRANT_PORT,MOF_RAG_QDRANT_API_KEY(the read-only key of step 1),MOF_RAG_COLLECTION,MOF_RAG_MODEL_CACHE=/models;MOF_RAG_QDRANT_HTTPS=truewhen Qdrant is behind TLS; optionallyMOF_RAG_DESCRIPTION_NOTES(see Passage search). The others have defaults (Configuration and limits); the date settings (MOF_RAG_DATE_FILTER_MODE=auto,MOF_RAG_DATE_FILTER_REFRESH_S=300,MOF_RAG_DATE_FILTER_RETRY_S=30) need no value of their own. -
Restart and check.
GET /healthanswers200within the start period.- The log holds, in this order,
rag: embedding model intfloat/multilingual-e5-base ready in ... s,rag: collection <collection> checked, searches are servedandrag: filter values read from the collection (source_codes: ..., doc_types: ..., languages: ...), then (loggerrag_engine.store)Qdrant collection '<collection>' has no datetime index on both date_start and date_end: date filters in auto mode use the date field (legacy)(beforesync-metadata) or... has datetime indexes on date_start and date_end: date filters in auto mode use the intervals(after). It holds no line with the wordDownloading: the running service never downloads. An error line namingMOF_RAG_MODEL_CACHEmeans the cache is incomplete, unreadable or not the pinned model. server_info:toolsets.ragisenabled,rag.statusisready, andrag.source_codes/rag.doc_typeslist the collection's codes. Ifrag.statusisunavailable,rag.reasonand the log say why (see Passage search).rag_searchwith a short query and one valid code, e.g.{"query": "inflation outlook", "source_codes": ["<a code of rag.source_codes>"]}: passages come back.rag_searchwith the same code in the wrong case: the answer is[invalid_argument] source_codes: unknown value "..." (did you mean "..."? values are matched exactly); valid values: ....rag_searchwith a date bound, e.g.{"query": "inflation outlook", "date_from": "2016-07-14", "date_to": "2016-07-14", "include_undated": false}: passages come back (or none, for a day nothing is dated to),filters.include_undatedisfalse, and each hit hasdate_precisionanddate_kind(nulluntilsync-metadatahas run).
-
Never run this repository's integration tests against a production Qdrant.
tests/integration/test_real_qdrant.pycreates and deletes collections: it is for a throwaway Qdrant only (see Development).
Redeploying a new version (such as the one that moved to myopenfund-rag-engine 0.1 and added the date
settings): the same steps, from step 3. Rebuild the image, or point the install service at the new
<version> (and the constraints URLs of its tag v<version>); restart; check as in step 7. No new volume, no new variable to set (the date settings have
defaults), and the model cache is kept: the pinned model revision did not change. Step 2 is not needed
again for the server: the indexes the new version uses are created by the orchestrator's sync-metadata,
and until they exist date bounds behave as before.
Outbound connections of the rag toolset
Once the model cache is filled, the server makes no outbound connection besides its requests to Qdrant (checked behind a recording proxy that refuses everything: no request in the first minute):
ORT_DISABLE_TELEMETRY: the ONNX runtime installed by the[rag]extra sends usage events to its publisher (mobile.events.data.microsoft.com) and keeps a device id under$HOME/.cache/Microsoft/DeveloperToolsunless this variable is1. The server sets it to1in its own process before the runtime can be imported, and so do the image andcompose.example.yaml. A value you set yourself is kept (0allows the telemetry).HF_HUB_OFFLINE=1is recommended for the running service. With a complete cache the server askshuggingface.conothing; with an incomplete one it would try a download at every start, fail on a read-only volume, and leaverag_searchanswering[rag_unavailable] model_unavailable. The variable turns that attempt into an immediate, local error. Leave it unset for the fill of step 4.
Tools
Tool names carry their toolset prefix. Every tool is read-only (readOnlyHint) except
companies_fetch_filings, which downloads and indexes filings (act tier). Only
vault_search_documents is paged: it returns next_cursor to pass back unchanged with the same filters.
vault_corpus_stats, vault_runs_status and vault_vocabulary only bound their lists with limit (no cursor). Every
limit defaults to MOF_MCP_DEFAULT_ROWS; a value outside [1, MOF_MCP_MAX_ROWS] is refused, not
clamped. String arguments doc_id, text, cursor and the corpus of vault_get_document and
vault_vocabulary are at most 200 characters.
| Tool | Purpose | Key arguments |
|---|---|---|
server_info |
What this deployment offers: enabled toolsets, your tier, version, data freshness (last vault ingest). Call it first. Open to every authenticated caller. | none |
vault_search_documents |
Find official documents (metadata, not text). Start here: filter, then open one with vault_get_document. Rows are ordered by sort_by in sort_dir; equal sort values are ordered by doc_id, then corpus, ascending, whatever sort_dir (a total order: on an unchanged vault, pages never repeat or skip a row). total counts the whole filtered set. Cursors are offsets: if the vault is ingesting between two pages, a row can shift (seen twice or skipped). Rows carry, besides the identity, title, dates, type and URLs, the documents-contract columns date_precision (day, month, year, or null = not stated: a month or year date is the period's first day), date_kind (publication, meeting, period) and entity_scheme / entity_value (the issuing entity, e.g. cik / 0000320193). |
corpus (e.g. central-bank), source_code (publisher, e.g. us for the Fed), doc_type (a code within its corpus: needs corpus, see below), language, year, mime_type, date_from / date_to (YYYY-MM-DD, inclusive), text (case-insensitive substring of the title, matched literally: % and _ are ordinary characters), sort_by (date default, year, corpus, source_code, doc_type, title, created_at), sort_dir (desc default), limit, cursor, include_deleted (also return withdrawn documents, with deleted_at set) |
vault_get_document |
Every stored fact of a document: dates (with date_precision, date_kind), the document's URL (document_url, PDF preferred, HTML accepted) and the page it was found on (source_url), publisher, type, issuing entity, extra. A doc_id is unique within its corpus only, so it returns a list: with corpus, at most one document (the one of that corpus); without, one per corpus holding that doc_id, ordered by corpus, each with its corpus. None: [not_found] (with corpus, the message says to omit it to look in every corpus). The text block is the JSON list; structuredContent is {"result": [...]} (MCP structured output must be an object). |
doc_id, corpus (pass the corpus of the search row) |
vault_corpus_stats |
Live-document counts grouped by one field, largest first (NULL is a real group). Grouping by doc_type needs corpus. |
group_by (source_code default, corpus, doc_type, language, year, provenance, mime_type), corpus, limit |
vault_vocabulary |
What the codes mean: each corpus's declared codes with their labels, rows {corpus, kind, code, label, family} ordered by corpus, kind, code, with returned and truncated (true when limit cut the list: filter by corpus and kind). For turning the user's words ("10-K", "rate decision") into a corpus's doc_type. A corpus that has not declared its codes yet has no rows: vault_corpus_stats(group_by="doc_type", corpus=...) shows the codes its documents use. |
corpus, kind (doc_type, source_code, provenance, entity_scheme), limit |
vault_runs_status |
Is the pipeline healthy? Four lists, newest first unless stated: runs (one row per run, with outcome and totals; a run that crashed before reaching any source appears only here), source_runs (one row per run and source: counts, outcome, bounded error samples; bad_content is the part of docs_failed where the server sent the wrong bytes, e.g. an HTML page for a PDF, NULL = not reported, never 0), open_discovery_errors (unresolved discovery failures; while seen_at_is_ingestion_time is true, last_seen_at is approximate), source_health (expected-vs-observed publication cadence per series, the least healthy first: cadence_status overdue, then soon, then the rest, each by most days_late first, unknown last; each row also carries source_bad_content_7d, the 7-day sum, NULL when no run of the window reported it, and last_run_bad_content), and source_health_total (every series matching corpus / source_code, so a shorter list means limit left some out). A result over MOF_MCP_MAX_RESULT_CHARS is refused with [result_too_large]: lower limit or filter by source_code. |
corpus, source_code, since (ISO 8601, UTC if no offset, an explicit offset is kept: whole minutes, at most ±15:59; keeps runs finished at or after it, leaves out runs still in flight; applies to runs and source_runs only), until (same form; keeps runs finished at or before it, so old runs are reachable under limit), limit (applies to each of runs, source_runs, open_discovery_errors, source_health) |
doc_type needs corpus. A doc_type code means something only within its corpus (central-bank A1
and company A1 are different document types). vault_search_documents with doc_type and no corpus,
and vault_corpus_stats grouped by doc_type without corpus, answer [invalid_argument] doc_type needs corpus: ... with vault-query's message, which lists each corpus's codes and labels. The tool descriptions
tell the model to ask the user which corpus when the conversation does not make it clear, or infer it.
Resource: vault://documents/{doc_id}, the metadata of the documents with that doc_id as a JSON list, one
per corpus holding it (same content as vault_get_document without corpus).
Changes for clients (vault-query 0.5.0, vault 12ffd11). vault_get_document and the resource return
a list (was one object); vault_get_document takes corpus; doc_type without corpus is refused (see
above); search and document rows carry date_precision, date_kind, entity_scheme, entity_value; new
tool vault_vocabulary.
The vault_* tools and the resource exist only when MOF_VAULT_DATABASE_URL is set; the [vault] extra
must then be installed, or the server refuses to start (MOF_VAULT_DATABASE_URL is set but the [vault] extra is not installed). Timestamps in results are UTC: the server's database session runs with
timezone=UTC, whatever the database or role default.
Minimum vault schema. This server needs a vault at or after 12ffd11 (vault-query 0.5.0; this server needs myopenfund-vault-query >=0.1.0,<0.2, the former 0.6.0, which takes until on run reads and breaks search sort ties by doc_id, corpus: documents
keyed (corpus, doc_id), columns date_precision / date_kind / entity_scheme / entity_value, table
vocabulary; runs_sources.bad_content). Deploy the vault (and run its ingestion, which applies the
schema) before this server. Against an older schema, a tool that reads a missing column or table answers
[schema_outdated] the vault lacks a column or table this server reads (see README, Minimum vault schema),
not backend_unavailable; the server log names the missing column or table, and server_info reports
"freshness_error": "schema_outdated".
If the vault database is down, server_info still answers (version, tier, toolsets) with freshness
null and freshness_error set to the error's code (backend_unavailable, timeout, schema_outdated);
the server log names the exception class only.
Passage search (rag)
rag_search exists only when MOF_RAG_QDRANT_HOST, MOF_RAG_COLLECTION and MOF_RAG_MODEL_CACHE are set;
the [rag] extra must then be installed, or the server refuses to start (MOF_RAG_QDRANT_HOST is set but the [rag] extra is not installed). It searches the text of the embedded documents by meaning (one dense
search over the chunks, with rag-engine) and returns passages, best first. It does not write an answer:
the client's model reads the passages and cites them. Read tier.
| Argument | Meaning |
|---|---|
query (required) |
What to look for, in plain language, in any language; at most 2000 characters (the model reads the first 512 tokens). |
source_codes |
JSON array of source codes, exact (case matters). The valid ones: server_info, rag.source_codes. |
doc_types |
JSON array of document-type codes, exact. The valid ones: server_info, rag.doc_types. |
languages |
JSON array of language codes as stored, e.g. ["en"]. The valid ones: server_info, rag.languages. |
date_from, date_to |
Date bounds, YYYY-MM-DD, both inclusive. A document known only to the month or the year matches any range overlapping its period (see Dates for when). As soon as one bound is set, a document without a date is left out, unless include_undated is true. |
include_undated |
JSON boolean, default false. true: with a date bound, also keep the documents without a date (the dated ones outside the range stay out). Without a date bound it changes nothing and is accepted. A string ("true") or a number is refused. |
limit |
Number of passages; default MOF_RAG_DEFAULT_LIMIT (8), at most MOF_RAG_MAX_LIMIT (20). |
The values of one array are alternatives (OR), the arguments combine (AND). An omitted argument does not restrict; an empty array is refused.
What the client's model is told. The tool description states how to call the tool, the default and
the maximum limit of this deployment, what a date bound does (with a bound, a document known only to the
month or the year matches any range overlapping its period, and documents without a date are left out
unless include_undated is true; with MOF_RAG_DATE_FILTER_MODE=legacy it says instead that such a
document is found only at the first day of its period), and the hit fields, date_precision and
date_kind included. It stays under 1800 characters before the notes. It is corpus-neutral: it names no source
and gives no meaning to any code, because such facts go stale when the collection changes. The codes
themselves are read from the collection (server_info, and every refusal lists them). What they mean is
the deployment's to say, in MOF_RAG_DESCRIPTION_NOTES: one line of text (at most 1500 characters),
appended to the description after About this collection:. Suggested value for the central-bank
collection:
MOF_RAG_DESCRIPTION_NOTES=Central-bank monetary-policy documents. source_codes: "ecb" European Central Bank, "us" Federal Reserve, "gb" Bank of England, "au" Reserve Bank of Australia, "ca" Bank of Canada, "jp" Bank of Japan. doc_types: "A1" rate-decision press release; "A2" policy statement (for the ECB: the press-conference page, with its questions and answers); "A3" minutes or accounts of the meeting; "B1" press-conference material (Federal Reserve: transcript; ECB: the combined decision and statement, without the Q&A); "E1" monetary policy report or staff projections; "F1" economic projections.
Example call and result (text shortened):
{"query": "Why did the ECB raise interest rates in July 2022?", "source_codes": ["ecb"], "date_from": "2022-07-01", "limit": 1}
{
"query": "Why did the ECB raise interest rates in July 2022?",
"filters": {"source_codes": ["ecb"], "doc_types": null, "languages": null, "date_from": "2022-07-01", "date_to": null, "include_undated": false},
"count": 1,
"hits": [
{
"rank": 1,
"score": 0.8189,
"text": "The Governing Council decided to raise the three key ECB interest rates by 50 basis points. ...",
"doc_id": "ecb/A1/2022-07-21",
"title": "Monetary policy decisions",
"date": "2022-07-21",
"date_precision": "day",
"date_kind": "meeting",
"source_code": "ecb",
"doc_type": "A1",
"language": "en",
"page": 1,
"chunk_number": 0,
"citation": "Monetary policy decisions (ecb A1, 2022-07-21), p. 1"
}
]
}
- Hits.
scoreis the cosine between the query and the passage (4 decimals; higher is closer). Several hits may come from one document; nothing is grouped.filtersechoes the filters as applied,include_undatedincluded. The point id and the rest of the stored payload are not returned. - Date fields.
dateis the stored date,YYYY-MM-DD.date_precisionsays how much of it is known:day,monthoryear(a month or a year is stored as the first day of its period:2016-07-01withmonthis July 2016), ornullwhen unknown.date_kindsays what the date marks, as the producer labels it (meeting,publication,period), ornull. Both are read from the stored payload as they are:nullis normal for a collection whose payloads do not carry them yet (the production collection until the orchestrator'ssync-metadatahas run), and an unknown precision is read as a day. - Pages.
pageis the page the passage starts on as a reader counts it: the first page is 1 (the collection stores pages from 0; the server adds one). It isnullfor a document without pages, and thecitationthen has no page part.citationis<title> (<source_code> <doc_type>, <date>), p. <page>, each missing part left out (thedoc_idstands for a missing title). The date is written at its precision:July 2016formonth,2016foryear(English month names), the stored date forday, for an unknown precision and for a date not writtenYYYY-MM-DD. - Argument errors are written for the client's model, in terms of the JSON to send: a string where an
array is expected, the array itself written as a string included (
source_codes must be a JSON array of strings, e.g. ["ecb"]; omit it for no restriction, the example being the caller's own value), an empty array (... omit the argument for no restriction), a date in another form (date_from must be "YYYY-MM-DD", e.g. "2016-03-10"), a boolean written otherwise (include_undated must be a JSON boolean, true or false without quotes, not "true"; omit it for false). Nothing is corrected silently. - Unknown filter values are refused, never corrected. The server reads the distinct
source_code,doc_typeandlanguagevalues from the collection and keeps themMOF_RAG_CODES_TTL_Sseconds. A value that is not among them is[invalid_argument]listing the valid values (as JSON strings), with a hint for a near miss ("ECB": did you mean"ecb"?), instead of an empty result.- With the keyword indexes, the values come from Qdrant's facet API (a few milliseconds), at start and then when a filtered call finds them older than the TTL.
- Without them, one scroll of the collection reads the three fields. It always runs in the background (it starts when the server does): no search waits for it, the searches made meanwhile are checked against the values already known, and not checked while none is known yet.
- Before a value is refused, the values are read once more (not more often than every
MOF_RAG_CODES_RETRY_Sseconds): a code ingested since the last read is accepted at once, not after the TTL. - The values are dropped when the collection comes back after an outage (it may have been recreated).
A field that holds no value at all (an empty collection) refuses nothing. If the values cannot be
read, the last ones read stay in use, or nothing is checked when there is none (one warning in the
log), and the read is tried again
MOF_RAG_CODES_RETRY_Sseconds later.
- Limits and size. A
limitaboveMOF_RAG_MAX_LIMITis[limit_exceeded], never lowered. A result larger thanMOF_MCP_MAX_RESULT_CHARSis refused with[result_too_large], never cut; the message names the largestlimitthat fits. Passages are 200 to 400 words: the default 8 are a few thousand tokens. - Start-up. The embedding model is loaded and the collection is checked when the server starts, not at
the first call, and a model is never loaded or downloaded by a tool call. If Qdrant cannot be reached,
refuses the key, or does not hold the collection, the server still starts (as it does when the vault
database is down):
rag_searchanswers[rag_unavailable]with the reason, and works again by itself once a collection check passes (see the next point). If the model cannot be loaded (files missing with no way to download them, or a file that is not the pinned one), the server starts too, logs the cause as an error namingMOF_RAG_MODEL_CACHE, andrag_searchanswers[rag_unavailable]until the cache is fixed and the server restarted. - Time budget, and what happens when Qdrant hangs. One call never takes longer than
MOF_RAG_CALL_TIMEOUT_S(15 s), its wait included.MOF_RAG_QDRANT_TIMEOUT(10 s) is the limit of one request to Qdrant, and a call makes several: the search, before it the read of the filter values when it is due, the collection check after a failure, and, for a call with a date bound inautomode, the read of the collection's payload schema when it is due (see Dates).- A request that fails (no answer in time, connection refused, key refused, collection gone, server
error) ends its call with
[rag_unavailable]and the reason: a call pays for one request timeout at most, never for two in a row (a failed read of the filter values is not followed by a search). - A failed search refuses nobody else. It only makes the next call check the collection before its own search. With a healthy Qdrant (one slow request, one caller's timeout) that check takes a few milliseconds and the call is served; a search that succeeds meanwhile cancels the check. When the check passes and the search that follows fails again before any search is served (Qdrant answers the check and no search), that failure is remembered like a failed check: one call per retry period pays for a request timeout, the others are answered at once (the calls that arrive while that one search is still waiting pay for it too: under steady traffic, more than one). A search that is served clears that memory at once.
- A failed collection check (at start, or the one that follows a failed search) is remembered
MOF_RAG_CHECK_RETRY_Sseconds (5): the calls made meanwhile get its reason at once, without a request, and so do the calls that arrive while a check is running. Then one call checks again. So with Qdrant frozen, a burst of 50 calls is answered within one request timeout (only the call that runs the check after a failed search waits longer, for that check or the end of its own budget), later calls within milliseconds, and the tool works again at mostMOF_RAG_CHECK_RETRY_Sseconds after Qdrant does. - A search that Qdrant refuses as a request (HTTP 4xx, other than a refused key, a missing
collection, 408 and 429) is the error of that call alone:
[rag_unavailable] search_refused, nobody else is refused andserver_infostaysready. The next call checks the collection before its search (a few milliseconds): when it is the collection that changed (recreated with another vector size, every search is refused), that check says so withcollection_mismatch. The usual cause is a collection in strict mode asked to filter on a field that has no payload index (a date bound without the datetime index ondate): the filter cannot be served by the collection as it is indexed. Step 2 of Deploying the rag toolset creates the indexes. - At most
MOF_RAG_MAX_CONCURRENCYsearches (4) run at once, in threads of the toolset's own: the calls in excess wait without holding a thread, so the other toolsets andserver_infokeep answering whatever Qdrant does. A call whose budget ends answers[rag_unavailable]:busyif it never got a slot,timeoutif its search was still running. Such a search keeps its slot until its request to Qdrant ends: abandoned searches cannot pile up.
- A request that fails (no answer in time, connection refused, key refused, collection gone, server
error) ends its call with
server_infoadds aragobject:status(ready, orunavailablewith areason),collection,model,engine_version,default_limit,max_limit, andsource_codes,doc_types,languages: the valid values of each filter as last read from the collection (at most 60 each;nullwhile not known). It reports the outcome of the last collection check (at start, then by the calls that had to run one), without a request to Qdrant: a search that failed does not change it, the check that follows does.- Privacy. As for every tool, the audit line holds the tool name, the client, the outcome and the
duration, never the arguments, and the tool's own log lines never contain the query. At the levels the
CLI logs (INFO and above), no line written for a search holds the Qdrant host, the API key or a
response body, the framework's and rag-engine's included:
- every exception of a search is caught by the toolset and answered with a coded reason, so FastMCP
never prints one. An error the toolset maps (an outage, a refusal, an answer that is not JSON, such as
a proxy's HTML page sent with status 200:
qdrant_error) is logged by its class; any other is answeredinternal_errorand logged at ERROR by its class only, its text and traceback at DEBUG only, a level the CLI never turns on (a developer who sets it accepts them); - the server routes every record of the
rag_engineloggers (present and future modules) through a filter. A record that carries an error (an exception among its arguments or attached to it) or whose text holds the configured host (a whole word, as configured or lowercased, alone or with a port: hostqdrantis found inhttp://qdrant:6333, not in a collectionqdrant-docs; the configured collection's name, quoted as the engine writes it, is not taken for the host unless it is the host) or the key (anywhere, even inside a longer word) is written with its logger, its level and a fixed message naming the error's class only; the engine's warning on a failed schema read also keeps its collection, the filter used meanwhile and the delay before the next try. Other engine lines (the collection and the filter in use) are written as they are. The error's text is dropped because it can hold the host, a TLS host name, a proxy's error page naming an upstream host or an internal address, or the engine's hint about its own key variable. What this changes in the process's logging (for an operator who embeds the server or configures logging): therag_enginelogger stops propagating and gets one handler that filters each record, then hands it to the root logger's handlers, or tologging.lastResort(stderr, WARNING and above) when there is none, as the standard library does. The change is process-wide and lasts as long as the process. A laterlogging.config.dictConfigthat namesrag_enginereplaces that handler, and the engine's records are then written as the engine writes them: leaverag_engineout of such a configuration, or build the rag toolset after it. The CLI configures logging before it builds the toolsets. The HTTP libraries under the Qdrant client are apart:httpxlogs one INFO line per request with the server's address, which is why the CLI raises its logger to WARNING, andhttpcorelogs the host and port of each connection at DEBUG only.
- every exception of a search is caught by the toolset and answered with a coded reason, so FastMCP
never prints one. An error the toolset maps (an outage, a refusal, an answer that is not JSON, such as
a proxy's HTML page sent with status 200:
- Concurrency. One embedder and one Qdrant client are shared by the process; inference runs one query at a time (about 20 ms for a short query on 4 cores) off the event loop.
Dates in rag_search
What a bound means. A document is dated by date and date_precision; rag-engine stores the period
it covers as date_start and date_end (the same day for day, the whole month for month, the whole
year for year). With intervals in use, a bound keeps a document when its period has at least one day in
common with the range: the minutes of a July 2016 meeting known only to the month are found by
2016-07-14..2016-07-14 and by any range touching July 2016; a document of the year 2015 by any range
touching 2015. A document dated to the day is found on that day, as before. A document without a date is
left out of every bounded search unless include_undated is true. Without intervals (legacy) a month or
a year document is found only at the first day of its period.
When results change. Intervals are used only once the collection's payloads carry date_start and
date_end and both fields have a datetime index. The orchestrator's sync-metadata writes the
intervals (with the corrected dates, precisions and kinds) and creates the two indexes; until it has run,
auto mode finds no index and every bound is applied to date, exactly as before this version, and
date_precision / date_kind are null in the hits. Within MOF_RAG_DATE_FILTER_REFRESH_S seconds after the
indexes appear, the running server uses them, without a restart. A collection whose indexes exist before
all its payloads have intervals loses nothing: a point without its interval yet is still found by its
date.
How a date bound is applied is rag-engine's date_filter_mode, set here by MOF_RAG_DATE_FILTER_MODE
and passed to the engine with every search, with MOF_RAG_DATE_FILTER_REFRESH_S and
MOF_RAG_DATE_FILTER_RETRY_S (the engine's own RAG_ENGINE_DATE_FILTER_* variables are never read).
- Mode
auto(the default) follows the collection. A call with a date bound asks the collection whetherdate_startanddate_endboth have a datetime index (one read request, which the read-only key may send), and the answer is keptMOF_RAG_DATE_FILTER_REFRESH_Sseconds (300). Indexed: the bound is applied to the intervals; not indexed: to thedatefield, as before. A call without a date bound never asks. The read is also made once at start, after the collection check and the read of the filter values (not when either failed: then the first date-bounded call makes it), so the log says which filter is in use (a line of therag_engine.storelogger:... date filters in auto mode use the intervals, or... use the date field (legacy)), and it is made again by the first date-bounded call after the refresh delay: a collection upgraded while the server runs is followed without a restart. - The read is part of the call. It runs in the call's own slot (one of
MOF_RAG_MAX_CONCURRENCY) and within its budget (MOF_RAG_CALL_TIMEOUT_S); when it ends after the budget, the search is not sent and the call has already answered[rag_unavailable] timeout. - A failed read refuses no call and is not an outage. When the read fails or times out, the engine
answers with the last answer it read, or with the
datefield when it never read one, logs one warning (loggerrag_engine.store, naming the error's class only: see Privacy above), and reads againMOF_RAG_DATE_FILTER_RETRY_Sseconds later (30) at the earliest; the calls made meanwhile ask nothing. The toolset does not remember that failure: no[rag_unavailable]follows from it,server_infostaysready, and only the search itself says whether Qdrant answers. So with Qdrant frozen, a date-bounded call may spend one request timeout on that read before its search, once per retry delay: its budget still bounds it. While no answer has ever been read (a cold start, or a start that skipped the read), the date-bounded calls that arrive during that first read wait for it, each in its slot: a burst of them can hold every one of theMOF_RAG_MAX_CONCURRENCYslots for one request timeout, once, and the calls behind them, with or without a date bound, wait as long (measured with a 3 s request timeout and 4 slots: 8 date-bounded calls answered in about 3 s, an undated call sent meanwhile in 2.8 s). Once an answer is known, or the read has failed, the other calls never wait for a read in progress. - Modes
intervalandlegacynever read the collection: always the intervals, or always thedatefield.intervalon a collection in strict mode without the two indexes is refused by Qdrant ([rag_unavailable] search_refused, the error of that call alone).
Companies and datasets
The companies_* tools exist when a company store is configured (MOF_COMPANIES_CATALOG and
MOF_COMPANIES_DATA_ROOT) or SEC can be read (MOF_SEC_CONTACT, with MOF_COMPANIES_SOURCE not store);
the datasets_* tools only with a store. The filing-text tools (companies_fetch_filings,
companies_search_filings, companies_read_filing) need SEC and the [filings] extra. The [companies]
extra must be installed (from PyPI, pip install "myopenfund-mcp[vault,companies]"; the extra installs
myopenfund-open-data-store and myopenfund-company-corpus[live]). The
store is read-only (as the lake_reader role): nothing is ever written to it. Reading SEC writes to the
local cache folder only (MOF_CACHE_DIR: HTTP answers, the filings index, the model). In a hardened container, DuckDB
downloads and loads its ducklake and postgres extensions under $HOME/.duckdb at each start: HOME must be
writable, a tmpfs holding it must allow exec (/tmp:exec), and the container needs outbound HTTPS to
extensions.duckdb.org. The process must also be able to read the store's lake/ files (open-data-store creates
them 0700 for its own uid). Configuration:
MOF_COMPANIES_CATALOG, MOF_COMPANIES_DATA_ROOT, MOF_COMPANIES_QUERY_TIMEOUT_S,
MOF_COMPANIES_MAX_COMPANIES, MOF_COMPANIES_MAX_CONCURRENCY, MOF_COMPANIES_Q4_RULE (see Configuration and limits).
| Tool | What it does |
|---|---|
companies_resolve |
Find companies by name (former names too), ticker, CIK or entity id; returns candidates. |
companies_facts |
Raw reported facts of up to MOF_COMPANIES_MAX_COMPANIES companies, as filed, with filing reference and provenance. |
companies_fundamentals |
Standardised concepts and ratios per company and period, with their provenance. |
companies_filings |
A company's filings (forms, report-period window) with accepted_utc, the time each became public on EDGAR: the event date for share-price studies. accepted_is_fallback marks an acceptance time EDGAR did not give (end of the filing day, New York). The store covers report forms (see covered_forms in the result); other forms, and omitted forms (= all), are read from SEC, or, when only the store can answer (MOF_COMPANIES_SOURCE=store, or no SEC contact), the covered forms are answered and covered_forms, all_forms_covered and forms_not_covered say what the store could not. |
companies_fetch_filings |
act tier. Download companies' filings (forms, report-period window; at most MOF_FILINGS_MAX_DOCS per call) and queue them for indexing on this machine; returns at once with each document's doc_id and state (queued, fetching, indexing, partial, ready, failed, with a fixed error text). Fetching again is harmless: a ready document stays ready, a partial or failed one resumes. |
companies_search_filings |
Hybrid search (dense + BM25) over the passages indexed so far of the fetched filings (companies, forms, period); hits carry company, cik, form, filed, section, url, doc_id, chunk_id, text, plus indexed and the documents not_ready. Passages explain; figures come from companies_facts / companies_fundamentals. |
companies_read_filing |
A fetched filing's stored text, bounded: from a hit's chunk_id (or around it), a section, or the start; continue with next_chunk_id / next_offset while more. |
datasets_list |
The datasets the store publishes: name, version, kind, licence, row estimate. |
datasets_describe |
Columns (type, allowed values, doc), natural key and licence of one dataset. |
datasets_read_asof |
Rows of a dataset as known at as_of, with structured filters (no free SQL), paged with next_cursor. |
datasets_export_csv |
The same rows as CSV text to save or paste; refused, never cut, above MOF_MCP_MAX_RESULT_CHARS. |
- Point in time. Company data is bitemporal:
as_of(a timestamp, default now; a value without an offset is read as UTC) returns what was publicly known at that moment, so a restatement filed later does not leak into an earlier view. Results echo theas_ofused. Datetimes are UTC. - Concepts and ratios are company-corpus's. The server computes none: it calls company-corpus for the
concept catalogue and the ratios. The one quarterly derivation, TTM, is company-corpus's too: by default
(
MOF_COMPANIES_Q4_RULE=ytd9) a fourth quarter the company did not report on its own is FY minus the 9-month year-to-date, the rule of company-corpus's published outputs, computed from the store's own values, not by this server. The store holds the 9-month values (fundamentals3.1.0, frequencyytd9); a TTM window needing a 9-month value the company did not file is absent (no row), never computed another way.sum_of_quartersinstead takes FY minus Q1, Q2 and Q3 whenever those three quarters are in the store. frequency. Incompanies_fundamentals,annual,quarterlyandsemiannualalso return the balance-sheet values (frequencyinstant) dated at the ends of the included periods, as the ratios use them;instantalone returns balance-sheet values only. Incompanies_facts,frequencyfilters the filed column as it is (raw), includingytd9(the 9-month year-to-date, used only to derive an unreported fourth quarter;companies_fundamentalshas no 9-month periods).- Sector unknown. There is no SIC classification yet:
sector_relevantis null on the sector-sensitive ratios and true on the others. - CSV.
datasets_export_csvtakes the same arguments asdatasets_read_asof; decimals are written exactly (a column's decimals share the widest scale, so1.5can appear as1.500000). With no rows, the header alone ifcolumnsis given, else an empty string. - Time budget, and a store read over SMB. One call, all its store reads together, gets
MOF_COMPANIES_QUERY_TIMEOUT_Sseconds (default 20) and then answers[timeout]. The default is sized for your store host, where the server runs next to the store and readslake/from local disk. Read over SMB instead (measured from a Mac, 2026-11),companies_fundamentalstook 42 to 51 s cold and about 17 s warm, so the default fails cold calls. A deployment that reads the store over SMB (or another network share) should raiseMOF_COMPANIES_QUERY_TIMEOUT_S, e.g. to 90; the client's own tool-call timeout must then be longer than that too.
Errors
Tool errors are MCP tool errors whose message starts with a stable code, [code] message, so agents can
branch on the code and show the message.
| Code | Meaning | What to do |
|---|---|---|
invalid_argument |
A bad argument: limit outside [1, MOF_MCP_MAX_ROWS], a cursor this server did not issue, date_from after date_to, a doc_type filter or grouping without corpus (the message lists each corpus's codes: ask the user which corpus, or infer it), a value the vault database refuses (a since offset beyond ±15:59, a NUL character in a text argument); for companies and datasets, period_from after period_to, a filter value of the wrong type for its column, 'all' combined with other metrics; for rag_search, a blank query, a string where a JSON array is expected, an empty array, a date not written YYYY-MM-DD, an include_undated that is not a JSON true or false, a filter value the collection does not hold (the message lists the valid ones). |
Fix the argument; pass next_cursor unchanged. |
not_found |
No document with that doc_id (in that corpus, when one is given: omit corpus to look in every corpus). For companies_read_filing: no stored chunk with that chunk_id, or no such section in the document (the message lists its sections). |
Find ids with vault_search_documents; for a filing, take doc_id and chunk_id from companies_search_filings. |
timeout |
The vault query, the company store read or the SEC requests exceeded the call's time budget (MOF_MCP_QUERY_TIMEOUT_S / MOF_COMPANIES_QUERY_TIMEOUT_S, plus MOF_SEC_CALL_BUDGET_S when SEC is read). A companies_fetch_filings timeout says whether the documents may already be queued. |
Narrow the filters; for SEC, call again (the cache keeps what was read). |
schema_outdated |
The vault database lacks a column or table the pinned vault-query reads: the vault is older than this server (see Minimum vault schema under Tools). | Deploy the vault (and run its ingestion) first; check the deployment. |
backend_unavailable |
The vault database or the company data store is unreachable (or refused the query); on a company read from SEC, an SEC answer that cannot be read (the message then names SEC, not the store); for the filings tools, an unexpected failure of the local index. | Retry later; check the deployment. |
rag_unavailable |
rag_search cannot answer. The message starts with a reason: qdrant_unreachable (connection refused, or no answer within MOF_RAG_QDRANT_TIMEOUT; also the answer given at once while a failed collection check is remembered), qdrant_auth (API key refused), qdrant_error (another error from Qdrant), collection_missing, collection_mismatch (vector size or distance), model_unavailable, model_integrity, search_refused (Qdrant refused this one search, most often a filter on a field without a payload index: the other searches are served), timeout (the call's own budget, MOF_RAG_CALL_TIMEOUT_S, ended while its search was running), busy (it ended before one of the MOF_RAG_MAX_CONCURRENCY slots was free), internal_error (the search failed with an error the server does not expect; the log names its class). It never holds the host, the key, Qdrant's response or the engine's own error text. |
Retry later for qdrant_unreachable, qdrant_error, timeout and busy; for internal_error, retry and report it if it lasts; for search_refused, retry with fewer filters (without the date bounds first); the others need the deployment fixed. |
limit_exceeded |
rag_search was asked for more passages than MOF_RAG_MAX_LIMIT; companies_search_filings for more than MOF_FILINGS_SEARCH_MAX_LIMIT; companies_fetch_filings matched more filings than MOF_FILINGS_MAX_DOCS. |
Ask for at most the maximum the message names; narrow forms or the period, or fetch fewer companies at once. |
result_too_large |
The result exceeds MOF_MCP_MAX_RESULT_CHARS. Results are refused, never silently cut. |
Ask for a smaller limit (rag_search names the largest that fits). |
ambiguous_company |
A company reference matches several companies. | Pick a candidate from the message and pass its CIK. |
unknown_company |
No company matches the reference. | Use companies_resolve. |
unknown_concept |
A concept key is not in the catalogue. | The message lists valid keys. |
unknown_metric |
A ratio key is not in the catalogue. | The message lists valid keys. |
unknown_dataset |
No dataset with that name. | Names come from datasets_list. |
unknown_column |
A filter or column is not in the dataset. | Columns come from datasets_describe. |
too_many_companies |
More companies than MOF_COMPANIES_MAX_COMPANIES. |
Split the request. |
sec_contact_missing |
A company must be read from SEC and no MOF_SEC_CONTACT is set. |
Set MOF_SEC_CONTACT (your name and e-mail) and restart. |
sec_refused |
SEC refused the requests as an undeclared automated tool. | Check MOF_SEC_CONTACT (a real name and e-mail). |
sec_unavailable |
SEC is unreachable or throttling after the retries (remembered for MOF_SEC_FAILURE_TTL_S). |
Retry later. |
warming |
A company's facts are still being fetched from SEC; the message says how far. | Call again in a few seconds. |
no_facts |
SEC holds no XBRL financial facts for that company (a fund, or a foreign private issuer before XBRL). | Nothing to read from facts; its filings' text may still be fetched. |
not_fetched |
companies_search_filings or companies_read_filing on filings never fetched (for these companies, forms or period). |
Call companies_fetch_filings first. |
index_not_ready |
Nothing is searchable yet among the fetched filings in scope; the message gives the progress and says whether indexing is in progress. | Call again in a minute; if nothing is in progress (partial or failed documents), call companies_fetch_filings again. |
index_unavailable |
The local filings index cannot be used: another process holds its folder (two MCP servers, or a server and warm, on one MOF_CACHE_DIR), or the server is shutting down. |
Stop the other process, or give each its own MOF_CACHE_DIR. |
Arguments that do not match a tool's input schema (wrong type, string too long, e.g. an over-long company
id) are rejected by the MCP framework before a tool runs, without a [code]. An unexpected internal failure reaches the client as a generic error
without details (they may hold connection strings); the server log has the rest. rag_search is the
exception: every error of its search is answered with a coded [rag_unavailable] reason, so nothing of
an exception reaches the framework (see Privacy in Passage search). Over HTTP, a missing or
unknown token is rejected with HTTP 401 before any tool runs.
Tiers and tokens
- Two tiers:
read(read-only tools) andact(every tool; impliesread). An entry without a tier isact.companies_fetch_filingsis the act-only tool (it downloads and indexes filings on the server's machine); areadclient searches and reads what anactclient fetched. A tool above the caller's tier is not listed to that caller and cannot be called. - One token per client, each with its tier, in
MOF_MCP_TOKENSasclient:sha256hex[:tier], comma-separated. Client ids are 1-32 characters ofA-Z a-z 0-9 _ . -. The client id appears in the audit log line of every tool call (tool=... client=... outcome=... ms=..., on stderr; arguments are never logged). - Make a token with
myopenfund-mcp hash-token <client> [--tier read|act](in a container:docker compose run --rm mcp myopenfund-mcp hash-token <client>). It generates a random 256-bit token, prints it on stderr, and prints theMOF_MCP_TOKENSentry alone on stdout. Give the token to that client only; the server stores only its SHA-256 digest. It never accepts a token you supply. - Entropy: digests are unsalted SHA-256, which is safe only for high-entropy random tokens such as the generated ones. Never use a passphrase or a hand-picked token.
- Revoke a client: remove its entry and restart. Configuration errors name the faulty entry by position, never by content, so a misplaced token is not echoed into logs.
Warming the cache ahead of questions (warm)
.venv/bin/myopenfund-mcp warm --companies MSFT,AMZN --forms 10-K,10-Q --since 2022-01-01 [--until 2025-12-31]
Fetches the facts of each company (issuer tables and statement positions) and its filings in the window,
then downloads and indexes every document until it is ready, through the same code the tools use: later
questions are answered from the cache. Needs MOF_SEC_CONTACT and the [companies,filings] extras.
--forms defaults to MOF_FILINGS_DEFAULT_FORMS; --poll-interval SECONDS (default
MOF_WARM_POLL_INTERVAL_S) is the wait between two looks at the progress. Progress lines go to stderr
([warm] 12/20 documents ready (3 indexing)). Exit codes: 0 all ready, 1 a step or document failed
(listed), 2 bad arguments or no MOF_SEC_CONTACT, 130 interrupted (Ctrl-C: the indexer closes within
MOF_INDEX_CLOSE_TIMEOUT_S). Run it again to resume: documents already ready are not fetched again;
facts are requested again once the companyfacts/submissions cache entries pass their TTL
(MOF_CACHE_TTL_COMPANYFACTS_H, MOF_CACHE_TTL_SUBMISSIONS_H). It refuses MOF_CACHE=off and
MOF_COMPANIES_SOURCE=store (exit 2). It always reads SEC, never a company store: with
MOF_COMPANIES_SOURCE=auto the warmed facts serve as the fallback when the store is stale. With no progress
for MOF_WARM_STALL_S it lists the stuck documents and exits 1. If the filings index is open in another process
(a running MCP server), warm stops with a message: stop that server first.
Configuration and limits
Environment variables only (a .env file in a deployment); see .env.example. An unset
or empty variable takes its default; a bad value stops the server at start, naming the variable.
| Variable | Default | Meaning |
|---|---|---|
MOF_MCP_TRANSPORT |
stdio |
stdio or http. The Docker image sets http. |
MOF_MCP_HOST |
127.0.0.1 |
HTTP listen address. The Docker image sets 0.0.0.0 (inside the container). |
MOF_MCP_PORT |
8000 |
HTTP port (1-65535). |
MOF_MCP_PATH |
/mcp |
HTTP endpoint path; must start with /. |
MOF_MCP_TOKENS |
unset | client:sha256hex[:tier],...; required when the transport is http. |
MOF_VAULT_DATABASE_URL |
unset | Vault Postgres URL, read-only role; unset = no vault toolset. Set sslmode explicitly (also avoids a wasted SSL attempt per call): verify-full with the provider's CA preferred; require as a fallback (encrypts, does not authenticate the server); disable only on a trusted private network. |
MOF_MCP_QUERY_TIMEOUT_S |
20 |
Postgres statement_timeout per call, in seconds (1-2147483). |
MOF_MCP_CONNECT_TIMEOUT_S |
10 |
Postgres connection timeout, in seconds (2-300). |
MOF_MCP_DEFAULT_ROWS |
50 |
Rows per page when the caller gives no limit; at most MOF_MCP_MAX_ROWS. |
MOF_MCP_MAX_ROWS |
200 |
Largest limit a caller may ask for. |
MOF_MCP_MAX_RESULT_CHARS |
200000 |
Largest tool result in characters (at least 1000); larger results are refused. The cap measures the result's text block (compact JSON); the protocol also carries the same data as structured content, so a response on the wire is roughly twice that size. |
MOF_MCP_MAX_ERROR_SAMPLES |
5 |
Error samples kept per row of vault_runs_status. |
MOF_MCP_MAX_TEXT_CHARS |
2000 |
Each error text in vault_runs_status is cut to this length. |
MOF_COMPANIES_CATALOG |
unset | open-data-store catalogue connection string as the read-only lake_reader role (postgres:dbname=<db> host=<host> port=5432 user=lake_reader password=<password>); unset = no companies or datasets toolsets. Needs MOF_COMPANIES_DATA_ROOT too. |
MOF_COMPANIES_DATA_ROOT |
unset | Folder holding lake/ as this host sees it; read-only is enough. Needs MOF_COMPANIES_CATALOG too. |
MOF_COMPANIES_QUERY_TIMEOUT_S |
20 |
Seconds one companies tool call may spend on all its store reads before it answers [timeout] (1-3600). |
MOF_COMPANIES_MAX_COMPANIES |
10 |
Most companies a single call may name (1-100). |
MOF_COMPANIES_MAX_CONCURRENCY |
2 |
Store reads running at once (1-16); a read abandoned at its time budget keeps its slot until it ends, so the next callers may also get [timeout] for a while. |
MOF_COMPANIES_Q4_RULE |
ytd9 |
How TTM derives a fourth quarter the company did not report on its own: ytd9 = FY minus the 9-month year-to-date (the rule of company-corpus's published outputs; a TTM needing a 9-month value the store lacks is absent), sum_of_quarters = FY minus Q1, Q2 and Q3 (present whenever those three quarters are, some differ from company-corpus's). |
MOF_RAG_QDRANT_HOST |
unset | Qdrant host name or address, alone: a scheme, a path or a port (qdrant:6333) is refused at start, the port being MOF_RAG_QDRANT_PORT. An IPv6 address is given bare or in brackets. Unset = no rag toolset. Needs MOF_RAG_COLLECTION and MOF_RAG_MODEL_CACHE too. |
MOF_RAG_QDRANT_PORT |
6333 |
Qdrant HTTP port (1-65535). |
MOF_RAG_QDRANT_API_KEY |
unset | Qdrant API key; a read-only key is enough and recommended. Never logged, shown or put in an error. |
MOF_RAG_QDRANT_HTTPS |
false |
Connect to Qdrant over TLS (true / false). Without TLS the key travels in clear: private network only. |
MOF_RAG_QDRANT_TIMEOUT |
10 |
Seconds one request to Qdrant may take (1-300, at most MOF_RAG_CALL_TIMEOUT_S); a call makes several (collection check after a failure, read of the filter values when due, read of the payload schema for a date bound in auto mode when due, search). A request that takes longer fails, and the call that made it answers [rag_unavailable] qdrant_unreachable. |
MOF_RAG_CALL_TIMEOUT_S |
15 |
Time budget of one rag_search call in seconds, its wait for a free slot included (1-3600, at least MOF_RAG_QDRANT_TIMEOUT). At its end the call answers [rag_unavailable] with timeout or busy. |
MOF_RAG_MAX_CONCURRENCY |
4 |
Searches running at once (1-64), in threads of the toolset's own. The calls in excess wait without holding a thread. |
MOF_RAG_CHECK_RETRY_S |
5 |
Seconds a failed collection check is remembered (1-3600): calls made meanwhile answer [rag_unavailable] at once. Also the longest the toolset takes to notice that Qdrant is back. A failed search is not remembered: it makes the next call run the check. |
MOF_RAG_COLLECTION |
unset | Collection searched (768-dimension cosine vectors of intfloat/multilingual-e5-base). Needs MOF_RAG_QDRANT_HOST too. |
MOF_RAG_MODEL_CACHE |
unset | Directory holding the embedding model files (about 1.1 GB), as an absolute path. Required with the rag toolset, for every transport: the model is never kept in a temporary directory. Fill it once, then mount it read-only. The process needs about 2 GB of memory while the model loads: give a container at least 3 GB. |
MOF_RAG_ONNX_THREADS |
unset | Threads of the ONNX runtime (1-256). Unset = one per core of the host; in a container with a CPU limit, set it to the limit. |
MOF_RAG_DEFAULT_LIMIT |
8 |
Passages rag_search returns when the caller gives no limit; at most MOF_RAG_MAX_LIMIT. |
MOF_RAG_MAX_LIMIT |
20 |
Largest limit a caller may ask rag_search for (1-1000); a larger one is refused with [limit_exceeded]. |
MOF_RAG_CODES_TTL_S |
300 |
Seconds the collection's filter values (source codes, doc types, languages) are kept before being read again (1-86400). |
MOF_RAG_CODES_RETRY_S |
5 |
Least seconds between two reads of the filter values that the TTL did not ask for: the read made before a value is refused, and the retry after a failed read (1-3600). |
MOF_RAG_DESCRIPTION_NOTES |
unset | One line of text appended to the description of rag_search: what the collection holds, what its codes mean (at most 1500 characters). See Passage search for a suggested value. |
MOF_RAG_DATE_FILTER_MODE |
auto |
How a date bound of rag_search is applied (rag-engine's date_filter_mode): auto (the intervals on a collection where date_start and date_end both have a datetime index, the date field elsewhere), interval (always the intervals; a collection in strict mode without the two indexes refuses it: search_refused) or legacy (always the date field). Lower case, exactly. See Dates. |
MOF_RAG_DATE_FILTER_REFRESH_S |
300 |
auto mode: seconds the collection's answer (are the two indexes there?) is kept before a date-bounded call reads it again (0-86400; 0 reads it before every date-bounded search). The longest the server takes to use the intervals once the indexes exist, without a restart. |
MOF_RAG_DATE_FILTER_RETRY_S |
30 |
auto mode: seconds before a collection whose answer could not be read is read again (1-3600). Meanwhile date-bounded calls use the last answer read, or legacy when none was. Such a failure refuses no call and is not remembered as an outage. |
MOF_COMPANIES_SOURCE |
auto |
Where companies_* read each company: auto (per company, for the call's as_of: the store when it holds the company, SEC's latest report filing accepted by then and the statement positions of SEC's latest 10-K/10-Q/20-F/40-F accepted by then; else SEC; each row says source and, when relevant, reason; when SEC cannot be asked (no contact, or SEC down) store companies are served with reason: freshness_unchecked; without a store, SEC only and no datasets_* tools), store (needs MOF_COMPANIES_CATALOG) or sec (needs MOF_SEC_CONTACT). The companies toolset is mounted when a store or a contact is configured. Needs the [companies] extra, which now also installs markitdown and magika (document conversion for live filings). |
MOF_SEC_CONTACT |
unset | E-mail or name sent in the User-Agent of every request to SEC, as their fair-access rules ask. Printable ASCII, at most 200 characters. Never logged, shown or put in an error. |
MOF_SEC_MAX_RPS |
5.0 |
Requests per second to SEC (above 0, at most 10, SEC's own limit). |
MOF_SEC_TIMEOUT_S |
30 |
Seconds one request to SEC may take (1-600). |
MOF_SEC_RETRIES |
4 |
Retries of a failed request to SEC (0-20). |
MOF_SEC_CALL_BUDGET_S |
50 |
Time budget of one tool call that fetches from SEC, in seconds (1-3600). Past it the call answers that the company is still being fetched; the fetch goes on and a later call gets the result. |
MOF_SEC_POSITIONS_LOOKBACK_Y |
5 |
Years before now (before period_to when given) whose facts get their filings' statement positions fetched (three requests per filing) when a call names no period start (1-50); a call with period_from starts there instead. Either start is then moved back by MOF_SEC_TTM_LOOKBACK_M months. |
MOF_SEC_POSITIONS_DONOR_DEPTH |
4 |
Earlier report filings (10-K, 10-Q, 20-F, 40-F) looked through, newest first, for the statement positions a filing without its own borrows, as the store's concept selection does (0-40; three requests each). A filing whose donor lies deeper does not read the store's donor: its location reads unknown where the store reads inferred, or it borrows from an older filing the call reads anyway. |
MOF_SEC_TTM_LOOKBACK_M |
20 |
Months before the period's start (period_from, or the start MOF_SEC_POSITIONS_LOOKBACK_Y gives a call without one) whose facts' filings also get their statement positions, so the TTM, derived fourth quarters and prior-year averages of the period's ratios are the store's (0-120). A quarterly TTM spans four quarter ends up to 300 days back; its earliest quarter, when derived, reads a 9-month YTD up to 100 days earlier (ytd9: under 400 days, 14 months) or three quarters up to 300 days earlier (sum_of_quarters: under 600 days, 20 months); the prior-year averages read up to 385 days back. The default covers both Q4 rules; below 14 (or 20 with sum_of_quarters) a ratio may differ from the store's. |
MOF_SEC_MEMO_COMPANIES |
50 |
Companies whose live tables (computed from SEC) are kept in memory for MOF_CACHE_TTL_COMPANYFACTS_H; past it the oldest built is dropped (1-10000). |
MOF_SEC_FAILURE_TTL_S |
60 |
Seconds a failed fetch of a company from SEC (SEC unreachable, refused, unreadable answer) is remembered: calls meanwhile get its error at once, even when it came after their time budget, instead of fetching again (1-3600). |
MOF_SEC_FRESHNESS_BUDGET_S |
5 |
MOF_COMPANIES_SOURCE=auto with a store: seconds a call gives the check of the store against SEC's filing list (one cached request per company, at most MOF_COMPANIES_MAX_CONCURRENCY at once). A company not checked by then is answered by the store with reason: freshness_unchecked, as are all of them for MOF_SEC_FAILURE_TTL_S after SEC failed during a check (1-600). |
MOF_CACHE |
on |
Keep fetched data between calls: on or off (off: entries live for the process only). |
MOF_CACHE_DIR |
platform cache folder + /myopenfund-mcp |
Absolute path (~ is not expanded). Default: $XDG_CACHE_HOME or ~/.cache on Linux, ~/Library/Caches on macOS, %LOCALAPPDATA% on Windows. |
MOF_CACHE_MAX_GB |
20 |
Size of the cached HTTP bodies above which the oldest-written ones are removed (1-100000). The model files and the local index sit under the same folder, on top of this figure, and are never removed. |
MOF_CACHE_EVICT_TO |
0.9 |
Fraction of MOF_CACHE_MAX_GB the cache is shrunk to when it is over the limit (above 0, at most 1). |
MOF_CACHE_TMP_GRACE_S |
3600 |
Seconds a temporary file of an interrupted write is kept before eviction removes it (60-86400). |
MOF_CACHE_TTL_SUBMISSIONS_H |
24 |
Hours a cached filing list is reused (1-8760). |
MOF_CACHE_TTL_COMPANYFACTS_H |
24 |
Hours a cached company-facts file is reused (1-8760). |
MOF_FILINGS_MAX_DOCS |
40 |
Filings downloaded and indexed by one call (1-1000). |
MOF_FILINGS_SEARCH_DEFAULT_LIMIT |
8 |
Passages companies_search_filings returns when the caller gives no limit; at most MOF_FILINGS_SEARCH_MAX_LIMIT. |
MOF_FILINGS_SEARCH_MAX_LIMIT |
20 |
Largest limit a caller may ask companies_search_filings for (1-1000); a larger one is refused with [limit_exceeded]. |
MOF_FILINGS_SEARCH_MAX_DOCS |
40 |
Fetched filings a companies_search_filings call without companies may cover (1-10000); with more fetched, the call is refused with [invalid_argument] asking for companies. |
MOF_FILINGS_READ_MAX_CHARS |
40000 |
Characters in one companies_read_filing page (min 1000, also capped by MOF_MCP_MAX_RESULT_CHARS); more and next_chunk_id / next_offset give the next page. Kept well under MCP clients' result limits (Claude Code refuses about 25k tokens). |
MOF_FILINGS_NOT_READY_LISTED |
10 |
Not-yet-ready documents listed in a search result (not_ready, 0-1000); not_ready_total counts them all. |
MOF_INDEX_WORKERS |
1 |
Embedding workers of the filings indexer: batches embedded in parallel, one per document (1-32). One more thread fetches and cuts the documents ahead of them. |
MOF_INDEX_BATCH_SIZE |
32 |
Passages embedded and added to the index in one step (1-1024), the unit of the indexing order (rag-engine's ONNX batch size; about 8-12 s on 4 CPU cores). |
MOF_INDEX_FIRST_BATCHES |
1 |
Batches of the MD&A (Item 7) of each company's newest queued document indexed in the first round, one company after the other, before any other work (0-100; 0 = no first round: document by document). See How long it takes. |
MOF_INDEX_FETCH_AHEAD |
40 |
Documents fetched and cut ahead of the embedding, at most (1-1000; a few MB of memory each). A company's newest queued document is fetched ahead whatever the count. Keep it at least MOF_FILINGS_MAX_DOCS: beyond the bound, documents cut later get their MD&A after the remainders of the documents already cut. |
MOF_INDEX_CLOSE_TIMEOUT_S |
30 |
Seconds the server waits at shutdown for the indexing step in progress (a batch, a download, the model load), 0-3600; one batch takes about 8-12 s on 4 CPU cores. Past it the index is released; the document is resumed (partial) next time. |
MOF_WARM_POLL_INTERVAL_S |
5.0 |
Seconds myopenfund-mcp warm waits between two looks at the SEC fetch (still warming) and at the indexing progress (above 0, at most 3600); --poll-interval overrides it. |
MOF_WARM_STALL_S |
1800 |
Seconds without any progress after which myopenfund-mcp warm stops waiting for the documents still queued or indexing, lists them and exits 1 (1-604800). |
MOF_RAG_ONNX_PROVIDER |
cpu |
ONNX execution provider of the local embedding: cpu or coreml. |
MOF_SEARCH_RRF_K |
60 |
Constant k of the reciprocal-rank fusion of a filings search (1-1000). |
MOF_SEARCH_CANDIDATES |
50 |
Passages each retriever hands to the fusion (1-1000). |
MOF_SEARCH_EIGENMIND |
false |
Select a filings search's passages for diversity (rag-engine's eigenmind selection over the fused candidates). Off: in the filings evaluation (rag-engine, 2026-11) it was no better than plain hybrid ranking, and worse when it changed the selection. Needs the [filings] extra. |
MOF_FILINGS_DEFAULT_FORMS |
10-K |
Comma-separated form types fetched when the caller names none. |
MOF_CHUNK_MAX_TOKENS |
480 |
Largest passage of the local filings index, in tokens (16-8192). |
MOF_CHUNK_OVERLAP_TOKENS |
32 |
Tokens shared by neighbouring passages (0-2048, below MOF_CHUNK_MAX_TOKENS). |
Read by compose.example.yaml only, not by the server: MOF_MCP_BIND_ADDR (host address the port is
published on, default 127.0.0.1), MOF_MCP_BIND_PORT (default 8000), MOF_VAULT_DOCKER_NETWORK (the
vault stack's Docker network to join).
Local models
The server works with any MCP client, including clients driving local models. No tool needs a hosted LLM: every v1 tool is deterministic and the client's model does the reasoning. Tools that will use an LLM later (such as an answer tool over RAG) are optional, always support a local backend, and are not mounted when no LLM is configured. Tool descriptions are directive and arguments are validated against the input schema, to help small models call them correctly.
How small is small enough is measured, not assumed: tests/llm/test_scenario_small_model.py asks a local
model, over a fake SEC (no network, no download), to compare the capital expenditures of two companies in
two fiscal years and to quote and cite what each annual report says about financing them. A run passes
when the answer has both FY2024 values, equal to the rows the tools returned, and quotes a passage with
the url of a companies_search_filings result; the model must pass at least 4 runs of 6. The default
test model is qwen3:4b; if it fails, the documented default is the smallest model that passes.
Status (0.2.0): not yet validated with a small model. qwen3:4b scored 0 of 6 on a 4-CPU cloud run
(it answered from the passages without calling companies_facts, before the tool descriptions said
facts come first); the reference runs, qwen3:4b then qwen3:8b, are on Apple silicon. Claude
(Claude Code over stdio, real SEC) answers the same scenario correctly. Run it with a local Ollama
(ollama pull qwen3:4b):
MOF_MCP_IT_OLLAMA_URL=http://127.0.0.1:11434 MOF_MCP_IT_OLLAMA_MODEL=qwen3:4b \
.venv/bin/python -m pytest -m llm tests/llm/test_scenario_small_model.py -s
Roadmap
- v1 (this release):
server_infoand thevault_*toolset over the central-bank corpus, read-only; tiers, tokens, Docker image. - v1.1:
rag_search(cited passage search over the embedded corpus, delivered); embedding as anactjob andjobs_*to follow long actions are still to come. - v2:
companies_*(identity resolution, filings fetched on demand, reported fundamentals) anddatasets_*over the MyOpenFund data library. - Later:
graph_*and more sources.
Development
python -m venv .venv
.venv/bin/pip install -e ".[vault,companies,rag,filings,dev]"
.venv/bin/ruff check .
.venv/bin/python -m pytest -q
Working across repos
Clone the repos side by side and install a sibling editable over the PyPI version in this environment:
pip install -e ../vault/query (or ../open-data-store, ../company-corpus, ../rag-engine). A change here
that needs an unreleased sibling version waits for that sibling's release before its PR merges.
How to release
Bump __version__ in src/myopenfund_mcp/__init__.py in a PR (the version is read from there). Run pip install -e . again locally so the installed metadata follows. After the PR merges, go to Actions, then release, then Run workflow: pick the main branch and target pypi. Approve the pypi deployment. The workflow builds the package, checks it, publishes it, then creates the tag v<version> and the GitHub Release itself.
It fails before publishing if it is not run on the default branch or if that tag already exists. Target testpypi is a rehearsal: it publishes to TestPyPI and creates no tag and no release.
Pushing a tag v<version> by hand still works: the workflow checks that the tag equals the package version and is on the default branch, then publishes and attaches the files to the Release.
After the PyPI release the workflow also updates the MCP Registry listing (server.json, whose versions must equal __version__); to back-fill a version already on PyPI, go to Actions, then mcp-registry, then Run workflow on main.
Publishing the same version to the registry twice may be rejected; bump the version for a new listing.
If PyPI got the package but the tag or the Release is missing, re-run the failed github-release job from Actions; do not push the tag by hand (the re-run would fail at the PyPI upload).
A Dependabot PR that raises a sibling's cap needs the range in pyproject.toml edited and the constraints regenerated (python3.13 scripts/update_constraints.py); never merge it as a single pin.
The default test run needs no database, network or model. Opt-in suites (integration, models, llm)
are excluded by default and run with an explicit marker:
pytest -m integration: against a real vault database, withMOF_MCP_IT_DATABASE_URLset.pytest -m integration tests/integration/test_real_store.py: against a real company store, withMOF_MCP_IT_COMPANIES_CATALOGandMOF_MCP_IT_COMPANIES_DATA_ROOTset (optional:MOF_MCP_IT_COMPANIES_TIMEOUT_S, default 120;MOF_MCP_IT_ASSERT_LATENCY=1to enforce the 5 s criterion, on your store host only; add-sor-rPto see the printed fundamentals latency).pytest -m integration tests/integration/test_real_qdrant.py:rag_searchagainst a throwaway Qdrant (never a production one: the test creates and deletes collections), withMOF_MCP_IT_QDRANT_URLset (e.g.http://127.0.0.1:6333). The test creates, seeds (through rag-engine, with its model-freeFakeEmbedder) and deletes collections namedmof-mcp-it-*. Optional, for a Qdrant with keys:MOF_MCP_IT_QDRANT_API_KEY(can write) andMOF_MCP_IT_QDRANT_READ_ONLY_API_KEY(given to the server).pytest -m integration tests/integration/test_no_vault_real.py: the companies tools against the real SEC (no store), withMOF_SEC_CONTACTset: quarterly capex and total debt of the scenario's five companies since 2022, and values checked by hand against their 10-K text.pytest -m modelson the same file indexes real 10-Ks (downloads the embedding model once, before any timing, unlessMOF_MCP_IT_MODELS_DIRpoints at a folder holding it): the first quotable passage of each company withinMOF_MCP_IT_FIRST_PASSAGE_S(default 120 s) ofcompanies_fetch_filings, each company fetched alone and the five fetched in one call, and a French question over the Microsoft FY2024 10-K finding its Item 7 (optional:MOF_MCP_IT_CACHE_DIR,MOF_MCP_IT_INDEX_TIMEOUT_S, default 1800; setMOF_RAG_ONNX_PROVIDER=coremlto measure a Mac's accelerator).pytest -m integration tests/integration/test_store_vs_live.py: the same companies read from a real store and from SEC live, at the sameas_of, withMOF_MCP_IT_COMPANIES_CATALOG,MOF_MCP_IT_COMPANIES_DATA_ROOTandMOF_SEC_CONTACTset: at leastMOF_MCP_IT_PARITY_MIN_SHARE(default 0.99) of the rows equal, every difference printed (optional:MOF_MCP_IT_PARITY_COMPANIES,MOF_MCP_IT_PARITY_AS_OF, default 2025-06-30,MOF_MCP_IT_PARITY_FROM, default 2022-01-01,MOF_MCP_IT_COMPANIES_TIMEOUT_S,MOF_MCP_IT_CACHE_DIR).pytest -m llm: scripted sessions with a local model, withMOF_MCP_IT_OLLAMA_URLset (optional:MOF_MCP_IT_OLLAMA_MODEL, defaultqwen3:4bfor the scenario test;MOF_MCP_IT_OLLAMA_TIMEOUT_S, default 300 s per model answer, to raise on a slow CPU; see Local models).
Build the image with docker build -t myopenfund-mcp .; docker run --rm myopenfund-mcp myopenfund-mcp --help lists the commands.
License
MIT, see LICENSE. Copyright (c) 2026 Marc Jeulin.
Metadata
Release files for myopenfund-mcp 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| myopenfund_mcp-0.2.1.tar.gz | 385.9 kB | With provenance | Details for myopenfund_mcp-0.2.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| myopenfund_mcp-0.2.1-py3-none-any.whl | Python 3 | none | any | Details for myopenfund_mcp-0.2.1-py3-none-any.whl |
Total release size: 558.7 kB
Release files / myopenfund_mcp-0.2.1.tar.gz
| Download URL | myopenfund_mcp-0.2.1.tar.gz |
|---|---|
| Size | 385.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2d14b464bdcea94d48f623213f50deeedb9db46f7f9bada9cfbded7775644986
|
|
BLAKE2b-256 checksum How to use checksums |
c4bbd678ce99be31817a4152807d7ca6f6747333388dfd0bebd85ba131c1e836
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.
Transparency logRelease files / myopenfund_mcp-0.2.1-py3-none-any.whl
| Download URL | myopenfund_mcp-0.2.1-py3-none-any.whl |
|---|---|
| Size | 172.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d909d3519b2d12305019bafb2ced38f5c231569822f7393a55ed17c6f6a8a0d7
|
|
BLAKE2b-256 checksum How to use checksums |
9b18b04016a56b6bdef19516f577fd5fc057695a4908f3facda488d897715421
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.
Transparency logSecurity for myopenfund-mcp 0.2.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for myopenfund_mcp-0.2.1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.