Spark文档搜索服务

一个基于MCP协议的Apache Spark文档搜索与检索服务器,为AI助手提供直接访问Spark文档的能力。

  • by martoc
  • Python
  • 本地部署
  • 更新于
在 GitHub 查看 martoc/mcp-spark-documentation

使用说明

MCP Spark文档服务器

MCP(模型上下文协议)服务器,为以下对象提供搜索和检索工具 Apache Spark 文档。该服务器使Claude等AI助手能够直接搜索和阅读Spark文档。

特性

  • 全文搜索 使用SQLite FTS5进行BM25排名和波特词干分析
  • 分段过滤 按文档类别缩小搜索结果范围
  • 稀疏结账 用于从apache/spark中高效克隆仅doc目录
  • Docker支持 用于跨项目的可移植部署
  • STDIO传输 用于无缝MCP客户端集成

快速开始

使用Docker(推荐)

# Build the Docker image (includes pre-indexed documentation)
make docker-build

# Test the server
make docker-run

利用紫外线(地方发展)

# Initialise the environment
make init

# Build the documentation index
make index

# Run the server
make run

配置

克劳德代码/克劳德桌面

添加到您的 .mcp.json 或全局设置:

{
  "mcpServers": {
    "spark-documentation": {
      "command": "docker",
      "args": ["run", "-i", "--rm", "martoc/mcp-spark-documentation:latest"]
    }
  }
}

对于本地构建的Docker镜像:

{
  "mcpServers": {
    "spark-documentation": {
      "command": "docker",
      "args": ["run", "-i", "--rm", "mcp-spark-documentation"]
    }
  }
}

对于没有Docker的本地开发:

{
  "mcpServers": {
    "spark-documentation": {
      "command": "uv",
      "args": ["run", "mcp-spark-documentation"],
      "cwd": "/path/to/mcp-spark-documentation"
    }
  }
}

MCP工具

工具 说明
search_documentation 通过关键字查询搜索Spark文档,可选部分过滤
read_documentation 检索特定文档页面的完整内容

搜索文档

使用带有词干支持的全文搜索搜索Apache Spark文档。

参数 类型 必填 默认 说明
query string 是 - 搜索词(支持词干)
section string 否 无 按节筛选(例如,sql ref、流式传输、mllib)
limit integer 否 10 最大结果(1-50)

常见部分: sql-ref, api, streaming, mllib, graphx, structured-streaming, configuration, tuning

read_文档

检索文档页面的完整内容。

参数 类型 必填 说明
path string 是 文档的相对路径(来自搜索结果)

CLI命令

# Build/rebuild the documentation index
uv run spark-docs-index index
uv run spark-docs-index index --rebuild
uv run spark-docs-index index --branch master

# Show index statistics
uv run spark-docs-index stats

发展

make init       # Initialise development environment
make build      # Run full build (lint, typecheck, test)
make test       # Run tests with coverage
make format     # Format code
make lint       # Run linter
make typecheck  # Run type checker

文档

许可证

该项目根据麻省理工学院许可证获得许可-请参阅 许可证 文件以获取详细信息。