Grokipedia MCP服务器

一个为AI助手提供Grokipedia在线百科全书功能的模型上下文协议(MCP)服务器和Go库。

  • by benoute
  • Go
  • 本地部署
  • 更新于
在 GitHub 查看 benoute/grokipedia

使用说明

Grokipedia MCP服务器

用于访问xAI在线百科全书Grokipedia的模型上下文协议(MCP)服务器。

概述

该项目提供:

  • 一 MCP服务器 将Grokipedia功能作为人工智能助手的工具
  • A. Go 库 (pkg/grokipedia)用于在您自己的应用程序中直接访问API

安装

先决条件

  • 转到1.23或更高版本

从源头构建

git clone https://github.com/benoute/grokipedia-mcp.git
cd grokipedia-mcp
make build

二进制文件将在以下时间创建 ./bin/grokipedia-mcp.

使用Go安装

go install github.com/benoute/grokipedia-mcp/cmd/grokipedia-mcp@latest

用法

克劳德桌面(stdio模式)

  1. 将以下内容添加到您的 claude_desktop_config.json:
{
  "mcpServers": {
    "grokipedia": {
      "command": "/absolute/path/to/grokipedia-mcp",
      "args": [],
      "env": {}
    }
  }
}
  1. 重新启动克劳德桌面

HTTP模式

以HTTP模式运行服务器,以便与基于web的MCP客户端一起使用:

# Default port 8080
./grokipedia-mcp -http

# Custom port
./grokipedia-mcp -http -port 3000

命令行选项

选项 默认值 描述
-http false 以HTTP服务器而不是stdio运行
-port 8080 使用HTTP模式时要监听的端口

工具参考

搜索_韩国

在Grokipedia上搜索各种主题的文章和信息。

参数:

参数 类型 必填 默认 说明
query string 是 - 搜索查询
limit int 否 10 要返回的最大结果数
offset int 否 0 要跳过的结果数

退货: 包含以下内容的搜索结果数组:

  • title -文章标题
  • slug -物品标识符(与 get_grokipedia_page)
  • snippet -带有搜索匹配项的文本摘录
  • relevanceScore -相关性排名得分

get_grokipedia_page

检索Grokipedia页面的完整内容。

参数:

参数 类型 必填 说明
slug string 是 页面标识符(来自搜索结果或URL)

退货: 全文内容包括:

  • 标题和内容(标记)
  • 带有URL的引用
  • 带字幕的图像
  • 元数据(创建/更新日期、查看次数)

去图书馆

这 pkg/grokipedia 包可以直接在Go应用程序中使用:

package main

import (
    "context"
    "fmt"
    "log"

    "github.com/benoute/grokipedia-mcp/pkg/grokipedia"
)

func main() {
    ctx := context.Background()

    // Search for articles
    results, err := grokipedia.Search(ctx, "artificial intelligence",
        grokipedia.WithLimit(5),
        grokipedia.WithOffset(0),
    )
    if err != nil {
        log.Fatal(err)
    }

    for _, result := range results {
        fmt.Printf("%s (score: %.2f)\n", result.Title, result.RelevanceScore)
    }

    // Get a specific page
    page, err := grokipedia.GetPage(ctx, "Artificial_intelligence")
    if err != nil {
        log.Fatal(err)
    }

    fmt.Printf("Title: %s\n", page.Title)
    fmt.Printf("Content: %s\n", page.Content[:200])
}

搜索选项

  • grokipedia.WithLimit(n) -限制结果(默认值:10)
  • grokipedia.WithOffset(n) -跳过分页结果(默认值:0)

页面选项

  • grokipedia.WithoutContent() -检索没有完整内容的页面元数据

许可证

MIT许可证