Skip to main content
Glama
README.md
# dharma-sources

A read-only [Model Context Protocol](https://modelcontextprotocol.io) server that lets AI assistants look up
authoritative Buddhist sources and cite them in a way a reader can check.

It does three things and nothing else: finds a text, returns the passage exactly as the archive publishes it,
and attaches the reference, translator, licence and canonical URL. It does not translate, summarise, or speak
for any teacher or tradition.

## Tools

| Tool           | What it does                                                                                  |
| -------------- | --------------------------------------------------------------------------------------------- |
| `search`       | Search the archives for works and passages                                                    |
| `fetch`        | Fetch a work, an edition or a passage by id                                                   |
| `resolve_work` | Turn a citation such as "MN 10" into the work, its editions and its parallels in other canons |
| `list_sources` | List the archives, what they cover and what may be reproduced                                 |

## Sources

| Source                                   | Served                                                          | Why                                                                                                                  |
| ---------------------------------------- | --------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------- |
| [SuttaCentral](https://suttacentral.net) | Passage text for segmented texts; links for legacy translations | Segmented translations are CC0 and root texts carry a Public Domain mark; other translations keep their own licences |

Each source has an adapter that reports what licence the archive states for an edition. One rule in
`src/core/rights.ts` then decides whether text leaves the server. Text with an unknown or unlisted licence is
withheld and the reader is sent to the archive.

## Use

```bash
pnpm install
pnpm build
node dist/cli.mjs fetch "sc:mn10/en/sujato:1.1-1.4"   # try it from the command line
node dist/cli.mjs stdio                                # run as a local MCP server
pnpm dev                                               # run the HTTP endpoint at http://localhost:8787/mcp
```

## Develop

```bash
pnpm check   # lint (Biome), types (TypeScript), tests (Vitest)
pnpm eval    # citation-integrity evals (Promptfoo) against the live archive
pnpm eval:model  # the same questions put to Claude, GPT and Gemini with and without this server
```

`src/core` and `src/adapters` are runtime-independent; `src/entry` holds the stdio, command-line and
Cloudflare Workers entry points, which all build the server from the same factory in `src/server.ts`.

## Licence

Code: Apache-2.0. Texts belong to their archives and translators under the licences shown with each record.