Skip to main content
Glama
hiing

CBETA MCP Server

by hiing
README.md
# CBETA MCP Server

[中文文档](./README.zh-CN.md)

MCP (Model Context Protocol) Server for [CBETA Online](https://cbetaonline.dila.edu.tw) - Chinese Buddhist Electronic Text Association.

> **CBETA** contains over 100 million characters of Buddhist scriptures, including the Taishō Tripiṭaka, Xuzangjing, and many other collections.

## Features

### 🔧 Tools

| Tool | Description |
|------|-------------|
| `search_sutra` | Search Buddhist scriptures by keyword |
| `get_sutra_content` | Get content of a specific scripture |
| `get_work_info` | Get detailed information about a work |
| `browse_catalog` | Browse the scripture catalog |

### 📚 Resources

- `cbeta://catalog` - Complete scripture catalog

### 💬 Prompts

- `explain_sutra` - Explain sutra passages
- `buddhist_term` - Look up Buddhist terminology

## Installation

### Option 1: Local (Node.js)

```bash
# Clone the repository
git clone https://github.com/your-username/cbeta-mcp.git
cd cbeta-mcp

# Install dependencies
npm install

# Build
npm run build

# Run
npm start
```

### Option 2: Cloudflare Workers (Recommended)

#### Prerequisites

1. [Cloudflare account](https://dash.cloudflare.com/sign-up)
2. [Node.js](https://nodejs.org/) (v18+)
3. [Wrangler CLI](https://developers.cloudflare.com/workers/wrangler/)

#### Deployment Steps

```bash
# 1. Clone the repository
git clone https://github.com/your-username/cbeta-mcp.git
cd cbeta-mcp

# 2. Install dependencies
npm install

# 3. Login to Cloudflare
npx wrangler login

# 4. Deploy to Cloudflare Workers
npm run deploy
```

After deployment, your MCP server will be available at:
```
https://cbeta-mcp.<your-subdomain>.workers.dev
```

#### Local Development

```bash
# Start local development server
npm run dev:worker

# Test with MCP Inspector
npx @modelcontextprotocol/inspector@latest
```

## Configuration

### Claude Desktop

Add to your Claude Desktop config file:

**Windows**: `%APPDATA%\Claude\claude_desktop_config.json`  
**macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`

#### For Local Server

```json
{
  "mcpServers": {
    "cbeta": {
      "command": "node",
      "args": ["C:\\path\\to\\cbeta-mcp\\dist\\index.js"]
    }
  }
}
```

#### For Cloudflare Workers

```json
{
  "mcpServers": {
    "cbeta": {
      "command": "npx",
      "args": [
        "mcp-remote",
        "https://cbeta-mcp.your-subdomain.workers.dev/sse"
      ]
    }
  }
}
```

## Common Work IDs

| ID | Title (Chinese) | Title (English) |
|----|-----------------|-----------------|
| T0001 | 長阿含經 | Dīrghāgama |
| T0099 | 雜阿含經 | Saṃyuktāgama |
| T0262 | 妙法蓮華經 | Lotus Sutra |
| T0374 | 大般涅槃經 | Mahāparinirvāṇa Sūtra |
| T0475 | 維摩詰所說經 | Vimalakīrti Nirdeśa Sūtra |
| T0665 | 金剛般若波羅蜜經 | Diamond Sutra |
| T0842 | 大毘盧遮那成佛神變加持經 | Mahāvairocana Sūtra |

## API Reference

### search_sutra

Search for Buddhist scriptures.

**Parameters:**
- `query` (required): Search keywords
- `scope` (optional): Search scope (T, X, N, etc.)
- `page` (optional): Page number (default: 1)
- `limit` (optional): Results per page (default: 10)

### get_sutra_content

Get the content of a specific volume.

**Parameters:**
- `work_id` (required): Work ID (e.g., T0001)
- `juan` (optional): Volume number (default: 1)
- `format` (optional): Output format ("text" or "html")

### browse_catalog

Browse the scripture catalog.

**Parameters:**
- `catalog_id` (optional): Catalog ID to browse

### get_work_info

Get detailed information about a work.

**Parameters:**
- `work_id` (required): Work ID

## Development

```bash
# Install dependencies
npm install

# Build local version
npm run build

# Build for Workers
npm run build:worker

# Run tests with MCP Inspector
npm run inspector
```

## License

MIT

## Credits

- [CBETA](https://www.cbeta.org) - Chinese Buddhist Electronic Text Association
- [DILA](https://www.dila.edu.tw) - Dharma Drum Institute of Liberal Arts