M

MCP Svelte 文档

@spences10/mcp-svelte-docs
0 Stars 425 次浏览 spences10 更新于 2026-08-23

通过MCP协议启用矢量相似性搜索和Svelte文档的提供,并支持本地缓存和多种llms.txt文档格式。

MCP 服务配置

复制以下 JSON 到 OPClaw 或其他 MCP 客户端的配置文件中即可使用

{
  "mcpServers": {
    "svelte-docs": {
      "args": [
        "bash",
        "-c",
        "LIBSQL_URL=file:local.db LIBSQL_AUTH_TOKEN=your-token npx -y mcp-svelte-docs"
      ],
      "command": "wsl.exe"
    }
  }
}

该服务需要配置环境变量:LIBSQL_AUTH_TOKEN、LIBSQL_URL

服务介绍

mcp-svelte-docs

一个 Model Context Protocol (MCP) 服务器,提供对 Svelte 文档的高效访问,具有高级缓存、搜索功能和优化的内容交付。该服务器直接与 Svelte 官方文档集成,提供了适合不同 LLM 上下文窗口大小的完整版和压缩版。

功能

  • 📚 通过 MCP 资源访问完整的 Svelte 文档
  • 🔍 高级搜索功能:
    • 文档类型过滤(API、教程、示例、错误)
    • 章节层次结构感知
    • 基于以下内容的智能相关性评分:
      • 词频
      • 章节重要性
      • 文档类型相关性
      • 精确短语匹配
    • 上下文感知的结果摘录
    • 相关搜索建议
  • 💾 使用 LibSQL 进行高效缓存
  • 🔄 自动内容新鲜度检查
  • 📦 支持特定包的文档(Svelte、Kit、CLI)
  • 📏 大文档的智能内容分块
  • 🗜️ 为较小的上下文窗口提供的压缩版本
  • 🏗️ 构建在 Model Context Protocol 上

配置

此服务器需要通过您的 MCP 客户端进行配置。以下是不同环境的示例:

Cline 配置

将以下内容添加到您的 Cline MCP 设置中:

{
    "mcpServers": {
        "svelte-docs": {
            "command": "npx",
            "args": ["-y", "mcp-svelte-docs"],
            "env": {
                "LIBSQL_URL": "file:local.db",
                "LIBSQL_AUTH_TOKEN": "your-auth-token-if-using-remote-db"
            }
        }
    }
}

Claude Desktop with WSL 配置

对于 WSL 环境,请将以下内容添加到您的 Claude Desktop 配置中:

{
    "mcpServers": {
        "svelte-docs": {
            "command": "wsl.exe",
            "args": [
                "bash",
                "-c",
                "LIBSQL_URL=file:local.db LIBSQL_AUTH_TOKEN=your-token npx -y mcp-svelte-docs"
            ]
        }
    }
}

环境变量

服务器支持以下环境变量:

  • LIBSQL_URL(可选):LibSQL 数据库的 URL。默认值为 file:local.db
  • LIBSQL_AUTH_TOKEN(可选):远程 LibSQL 数据库的身份验证令牌

API

服务器实现了 MCP 资源和工具:

资源

通过以下 URI 访问文档:

  • svelte-docs://docs/llms.txt - 文档索引
  • svelte-docs://docs/llms-full.txt - 完整文档
  • svelte-docs://docs/llms-small.txt - 压缩文档
  • svelte-docs://docs/{package}/llms.txt - 特定包的文档
    • 支持的包:svelte, kit, cli

工具

search_docs

具有高级过滤和上下文感知功能的增强搜索功能。

参数:

  • query(字符串,必填):搜索关键字或自然语言查询
  • doc_type(字符串,可选):按文档类型过滤
    • 值:'api', 'tutorial', 'example', 'error', 'all'
    • 默认值:'all'
  • context(数字,可选):周围段落数(0-3)
    • 默认值:1
  • include_hierarchy(布尔值,可选):包含章节层次结构
    • 默认值:true

使用示例:

// API Reference Search
{
  "query": "bind:value directive",
  "doc_type": "api",
  "context": 1
}

// Tutorial Search
{
  "query": "routing sveltekit",
  "doc_type": "tutorial",
  "context": 2,
  "include_hierarchy": true
}

get_next_chunk

检索大型文档的后续部分。

参数:

  • uri(字符串,必填):文档 URI
  • chunk_number(数字,必填):要检索的部分编号(基于 1)

开发

设置

  1. 克隆仓库
  2. 安装依赖项:
pnpm install
  1. 构建项目:
pnpm build
  1. 以开发模式运行:
pnpm dev

发布

  1. 更新 package.json 中的版本号
  2. 构建项目:
pnpm build
  1. 发布到 npm:
pnpm publish

贡献

欢迎贡献!请随时提交 Pull Request。

许可证

MIT 许可证 - 详情请参阅 LICENSE 文件。

致谢

相关 MCP 服务