华盛顿法律MCP服务器
一个MCP(模型上下文协议)服务器,为人工智能代理提供对华盛顿州修订后的华盛顿州法典(RCW)和华盛顿行政法典(WAC)的离线访问。
特性
- 完全离线:所有法律文本都存储在SQLite数据库中
- 快速访问:即时检索任何RCW或WAC部分
- 全文检索:使用SQLite FTS5搜索华盛顿所有法律
- 全面覆盖:访问所有RCW标题、章节和小节
- MCP兼容:适用于任何兼容MCP的AI客户端(Claude等)
建筑
该项目由两个主要部分组成:
- 数据收集阶段 (一次性设置):下载所有RCW/WAC文本的剪贴器
- MCP服务器 (运行时):从本地数据库提供法律文本,无需外部调用
安装
# Clone the repository
git clone
cd law_rule_mcp
# Install dependencies
npm install
# Initialize the database
npm run init:db
# Scrape RCW data (this will take several hours)
npm run scrape:rcw
# Build the TypeScript code
npm run build用法
运行MCP服务器
npm startMCP检验员测试
npm test使用Claude Desktop进行配置
添加到您的Claude Desktop配置(~/Library/Application Support/Claude/claude_desktop_config.json):
{
"mcpServers": {
"washington-law": {
"command": "node",
"args": ["/path/to/law_rule_mcp/dist/index.js"]
}
}
}可用的MCP工具
get_rcw
检索特定RCW部分的全文。
- 参数:
- citation (字符串):RCW引用(例如,“46.61.502”)
get_wac
检索特定WAC部分的全文。
- 参数:
- citation (string):WAC引用(例如,“296-24-2005”)
search_laws
通过关键字或短语搜索华盛顿法律。
- 参数:
- query (string):搜索词 - limit (数字,可选):最大结果(默认值:20)
list_rcw_titles
列出所有RCW标题和章节计数。
list_rcw_chapters
列出特定RCW标题中的所有章节。
- 参数:
- titleNum (string):标题编号(例如“46”)
list_rcw_sections
列出特定RCW章节中的所有部分。
- 参数:
- chapterNum (字符串):章节号(例如“46.61”)
get_statistics
获取数据库统计信息,包括节数和上次更新时间。
项目结构
law_rule_mcp/
├── src/
│ ├── index.ts # MCP server entry point
│ ├── database/
│ │ ├── init.ts # Database initialization
│ │ └── database.ts # Database access layer
│ ├── scraper/
│ │ └── rcw-scraper.ts # RCW web scraper
│ └── types.ts # TypeScript type definitions
├── data/
│ └── washington-laws.db # SQLite database (created after scraping)
├── package.json
├── tsconfig.json
└── README.md数据库模式
SQLite数据库包含:
- 运行时可调用包装 表:所有RCW部分的全文和元数据
- 广域控制 表:所有WAC部分的全文和元数据
- rcw_fts / wac_fts:全文搜索索引
- 元数据 表:数据库版本和更新时间戳
- scraper_progress 表:跟踪抓取进度
更新数据库
要使用最新更改更新法律数据库,请执行以下操作:
# Re-run the scraper to fetch updated laws
npm run scrape:rcw刮刀将更新现有部分并添加新部分。
发展
# Watch mode for development
npm run dev
# Build TypeScript
npm run build
# Test with MCP inspector
npm test备注
- 由于速率限制(尊重爬行),初始抓取需要几个小时
- 压缩后数据库大小约为200-500MB
- 一旦数据被抓取,服务器就会完全脱机运行
- 在MCP服务器操作期间,所有数据库查询都是只读的
许可证
麻省理工学院
