Hoogle MCP Server
by hnbc6667777
README.md
# Hoogle MCP Server
一个用于在AI助手(Cursor、Claude Desktop、Codebuddy等)中搜索Haskell文档的MCP(模型上下文协议)服务器。
[](https://opensource.org/licenses/MIT)
[](https://nodejs.org/)
[](https://www.typescriptlang.org/)
## 📑 快速导航
| 文档 | 说明 |
|------|------|
| [🎉 WELCOME.md](WELCOME.md) | **新手从这里开始!** 快速上手指南 |
| [🚀 QUICKSTART.md](QUICKSTART.md) | 5分钟快速配置 |
| [💡 USAGE_EXAMPLES.md](USAGE_EXAMPLES.md) | 详细使用示例和技巧 |
| [📊 PROJECT_SUMMARY.md](PROJECT_SUMMARY.md) | 项目技术细节和架构 |
| [✅ DELIVERY_CHECKLIST.md](DELIVERY_CHECKLIST.md) | 项目完成度检查清单 |
## 功能特性
- 🔍 通过Hoogle API搜索Haskell函数、类型、模块和包
- 📚 支持函数名搜索、类型签名搜索和关键词搜索
- 🌐 可通过stdio或HTTP两种方式运行
- 🚀 完整的TypeScript类型支持
## 安装
```bash
npm install
npm run build
```
## 使用方法
### 方式1:Stdio模式(推荐用于Claude Desktop、Codebuddy)
启动stdio服务器:
```bash
npm start
```
### 方式2:HTTP模式(用于远程访问)
启动HTTP服务器:
```bash
npm run start:streamableHttp
```
默认监听端口:3088
## 配置AI工具
### Claude Desktop配置
编辑Claude Desktop配置文件:
- macOS: `~/Library/Application Support/Claude/claude_desktop_config.json`
- Windows: `%APPDATA%\Claude\claude_desktop_config.json`
添加以下配置:
```json
{
"mcpServers": {
"hoogle": {
"command": "node",
"args": ["/path/to/Hoogle_MCP_Server/dist/index.js"]
}
}
}
```
### Codebuddy配置
在Codebuddy设置中添加MCP服务器,配置类似:
```json
{
"mcpServers": {
"hoogle": {
"command": "node",
"args": ["/home/unixzhang/Hoogle_MCP_Server/dist/index.js"]
}
}
}
```
### Cursor配置
Cursor通常使用HTTP模式连接MCP服务器:
1. 启动HTTP服务器:`npm run start:streamableHttp`
2. 在Cursor设置中添加MCP端点:`http://localhost:3088/mcp`
## 可用工具
### search_hoogle
在Hoogle中搜索Haskell相关内容。
**参数:**
- `query` (string, 必需): 搜索查询,可以是:
- 函数名:`map`
- 类型签名:`(a -> b) -> [a] -> [b]`
- 关键词:`monad transformer`
- `count` (number, 可选): 返回结果数量(默认10,最大100)
**示例:**
在AI助手中,你可以这样使用:
```
请搜索Haskell中的map函数
```
```
帮我查找类型为 a -> [a] 的函数
```
```
在Hoogle中搜索 monad transformer,显示前5个结果
```
## 开发
### 监视模式
开发时可以使用watch模式自动重新编译:
```bash
npm run watch
```
### 项目结构
```
Hoogle_MCP_Server/
├── src/
│ ├── index.ts # Stdio入口
│ ├── server.ts # 核心MCP服务器逻辑(Hoogle搜索实现)
│ └── streamableHttp.ts # HTTP服务器入口
├── dist/ # 编译输出
├── package.json
├── tsconfig.json
└── README.md
```
## 技术栈
- **MCP SDK**: `@modelcontextprotocol/sdk` - 模型上下文协议实现
- **TypeScript**: 类型安全的开发体验
- **Zod**: 运行时类型验证
- **Express**: HTTP服务器(可选)
- **Hoogle API**: https://hoogle.haskell.org/
## API接口说明
Hoogle MCP Server使用Hoogle官方JSON API:
```
GET https://hoogle.haskell.org/?mode=json&hoogle={query}&count={count}
```
返回的结果包含:
- 函数/类型的完整签名
- 所属模块和包信息
- 文档链接
- 简短说明
## 许可证
MIT
TDQS
B3.4/5.0
Scored across 1 tool
Disambiguation5/5
With only a single tool, there is no possibility of misselection; search_hoogle has one clear, unambiguous purpose (querying Hoogle).
Naming Consistency4/5
The lone name follows a clean verb_noun snake_case pattern (search_hoogle) that fits MCP conventions, but a single name provides no pattern to verify against.
Tool Count3/5
One tool is thin for a server surface, though it maps directly onto Hoogle's single search endpoint; users needing docs, module browsing, or package detail have no alternative entry point.
Completeness3/5
Search by name, type signature, or keyword covers the core Hoogle use case, but there are no companion operations such as fetching full haddock documentation, listing package modules, or resolving suggestions, leaving some queries as dead ends.
Maintenance
ActivityInactive
ResponsivenessNo recent community issues