Skip to main content

okf-cli — Open Knowledge Format tooling

Convert plain markdown directories into OKF-conformant knowledge bundles. okf bundle generates YAML frontmatter, concept types, provenance, and per-directory index.md files; okf validate, okf list, and okf read consume the resulting bundle.

Install

uv tool install okf-cli

This installs the okf command. To include the optional MCP server support at the same time, install with the mcp extra instead:

uv tool install 'okf-cli[mcp]'

(If you already installed without it, reinstall with uv tool install --force 'okf-cli[mcp]'.)

Check the installation:

okf --help
okf --version

Quick example

Try it on a scratch directory:

mkdir okf-demo
printf '# Customers\n\n> Master table of customers.\n\nOne row per customer.\n' > okf-demo/customers.md

okf bundle okf-demo
okf validate okf-demo_knowledge_base
okf list okf-demo_knowledge_base
okf read okf-demo_knowledge_base customers

Your real usage will point at your own markdown directories instead:

okf bundle my-notes
okf validate my-notes_knowledge_base
okf list my-notes_knowledge_base
okf read my-notes_knowledge_base <concept-id>

Run okf <command> --help for options such as --default-type, --force, --strict, and --dry-run. (Without an explicit output directory, okf bundle <input-dir> writes to <input-dir>_knowledge_base in the current directory.)

Commands

Command Purpose
okf bundle <input-dir> [output-dir] Convert markdown into an OKF bundle
okf validate <directory> Check OKF v0.2 §11 conformance
okf list <directory> List concepts (ID, type, title, description)
okf read <directory> <concept-id> Print a concept by ID
okf reindex <directory> Rebuild every index.md from the concepts
okf serve-mcp <directory> Serve a conformant bundle over MCP HTTP

MCP server

Install the optional MCP dependency (if you installed with uv tool install okf-cli, reinstall with --force 'okf-cli[mcp]' as shown above), then serve a conformant bundle over Streamable HTTP:

okf serve-mcp my-bundle

The server binds to 127.0.0.1:8000 by default and listens at http://127.0.0.1:8000/mcp. Use --host and --port to change the bind address; --host 0.0.0.0 listens on all IPv4 interfaces. The server exposes read-only tools:

Tool Purpose
search(query, type, filters, limit) Find concepts by words in the ID, title, description, tags or any other frontmatter value
browse(path) List a directory's concepts and subdirectories with bundle-relative IDs and paths
read_concept(concept_id, section) Read a concept, or only one section; links resolves body links to concept IDs (exists)
list_concepts() List every concept (prefer search/browse for large bundles)

Every call re-reads files changed on disk since the previous call, so a bundle can be regenerated while it is served. The server instructions describe the tools and append the bundle's AGENTS.md when present. Add --token <secret> to require the matching Authorization: Bearer <secret> header on MCP requests; without it, requests are unauthenticated. For example:

okf serve-mcp my-bundle --token "$OKF_MCP_TOKEN"

Use HTTPS (typically through a TLS-terminating proxy) when serving beyond localhost. The token is a command-line argument and may be visible in shell history or process listings; use this option only on a trusted network, and do not treat it as a replacement for TLS.

HTTPS with Caddy

When Caddy runs on the same machine, leave the MCP server bound to its default 127.0.0.1 address and let Caddy handle public HTTPS:

mcp.example.com {
    reverse_proxy 127.0.0.1:8000
}

Start the MCP server with authentication enabled:

okf serve-mcp my-bundle --token "$OKF_MCP_TOKEN"

Clients connect to https://mcp.example.com/mcp and send Authorization: Bearer <token>. Keep port 8000 private; Caddy should be the public entry point. Caddy can provision HTTPS automatically when the domain points to the server and is reachable on the required ports.

Python library

src/okf/api.py is usable directly as a library:

from okf.api import Bundle, bundle, reindex, validate, write_concept

result = bundle("example", "out", default_type="reference", force=True)
assert validate("out").ok

# Programs that generate concepts themselves keep every frontmatter key as given.
write_concept(
    "out", "tables/invoices", {"type": "tables", "title": "Invoices"}, "Body."
)

# Rebuild index.md files after concepts were added or removed directly.
reindex("out")  # also: `okf reindex out`; stale indexes are emptied, never deleted

# Repeated reads: load once, then search and read from memory.
kb = Bundle.open("out")
kb.search("customer", type_="tables")
kb.read("tables/customers", section="Schema").body

Documentation

Metadata

Release files for okf-cli 0.9.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for okf-cli 0.9.0
File Size Uploaded Provenance Actions
okf_cli-0.9.0.tar.gz 161.3 kB Without provenance Details for okf_cli-0.9.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for okf-cli 0.9.0
File Interpreter ABI Platform Actions
okf_cli-0.9.0-py3-none-any.whl Python 3 none any Details for okf_cli-0.9.0-py3-none-any.whl

Total release size: 190.7 kB

Release files / okf_cli-0.9.0.tar.gz

Download URL okf_cli-0.9.0.tar.gz
Size 161.3 kB
Tags Source
SHA-256 checksum
How to use checksums
f722e9456b963a8149b57e59c8599579b3e63b2d51dd0d8613ef2c2071b7a3ab
BLAKE2b-256 checksum
How to use checksums
dbcfc919fc49342ae13b3be2583374ef4abe18cb02d1254af5a88af27939f4f7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / okf_cli-0.9.0-py3-none-any.whl

Download URL okf_cli-0.9.0-py3-none-any.whl
Size 29.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
42b515c5af835b2213daf90834a0179370898e292356471976104cb591b95bdc
BLAKE2b-256 checksum
How to use checksums
0390f9827cce21b24a14b95f15ca94fc443411281e8f52a9b9f80b1267750609
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for okf-cli 0.9.0

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A 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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page