-
Notifications
You must be signed in to change notification settings - Fork 2k
feat: 新增MCP Server功能,支持文档全局检索工具 #1010
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds MCP (Model Context Protocol) Server functionality to MinDoc, enabling global document search capabilities. The implementation provides a streamable HTTP server that exposes document search tools for AI agents to query MinDoc's content repository.
Key changes:
- New MCP server package with authentication middleware and global search tools
- HTTP routing and filtering integration for MCP endpoints
- Go version upgrade from 1.18 to 1.23 to support mcp-go dependency
Reviewed Changes
Copilot reviewed 8 out of 9 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| routers/router.go | Adds MCP server routing with conditional enablement |
| routers/filter.go | Integrates MCP authentication middleware into request filtering |
| mcp/middleware.go | Implements API key authentication for MCP requests |
| mcp/mcp.go | Core MCP server setup and tool registration |
| mcp/handler.go | Global search tool implementation and request handling |
| go.mod | Updates Go version to 1.23 and adds mcp-go dependency |
| conf/app.conf.example | Adds MCP server configuration options |
| commands/daemon/daemon.go | Minor import formatting adjustment |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
mcp/handler.go
Outdated
| // GlobalSearchMcpHandler 全局搜索的mcp处理函数 | ||
| func GlobalSearchMcpHandler(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) { | ||
| paramMap := request.Params.Arguments.(map[string]any) | ||
| pageIndex, _ := paramMap["pageIndex"].(int) |
Copilot
AI
Sep 22, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Type assertion assumes pageIndex is an int, but the tool definition uses mcp.WithNumber which may provide a float64. This could cause the assertion to fail and default to 0. Use type assertion to float64 and convert to int, or handle the conversion properly.
| pageIndex, _ := paramMap["pageIndex"].(int) | |
| pageIndex := 1 | |
| if v, ok := paramMap["pageIndex"].(float64); ok { | |
| pageIndex = int(v) | |
| } |
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 8 out of 9 changed files in this pull request and generated 2 comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
This reverts commit 71ba7b6.
feat: 新增MCP Server功能,支持文档全局检索工具
由于依赖
mcp-go依赖对go版本最低要求为 go 1.23,因此go build的最低版本将被升级到 go 1.23已通过Dify v1.7.0版本进行自测试并验证通过:
其中,MCP配置为:
{ "mindoc": { "transport": "streamable_http", "url": "http://10.0.10.104:8181/mcp/?api_key=demo-mcp-api-key", "headers":{}, "timeout":600 } }对应的
app.conf配置为: