修正 sse neo4j 的实现细节
This commit is contained in:
parent
7167f5bbd8
commit
04f2b4e379
@ -1,5 +1,7 @@
|
||||
# go 实现 neo4j 的只读 mcp 服务器 (SSE)
|
||||
|
||||
[本期教程视频](https://www.bilibili.com/video/BV1g8TozyEE7/)
|
||||
|
||||
## 前言
|
||||
|
||||
本篇教程,演示一下如何使用 go 语言写一个可以访问 neo4j 数据库的 mcp 服务器。实现完成后,我们不需要写任何 查询代码 就能通过询问大模型了解服务器近况。
|
||||
@ -150,7 +152,6 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/neo4j/neo4j-go-driver/v5/neo4j"
|
||||
"neo4j-go-server/util"
|
||||
)
|
||||
|
||||
@ -222,7 +223,14 @@ func main() {
|
||||
|
||||
// 将真实函数和申明的 schema 绑定
|
||||
s.AddTool(executeReadOnlyCypherQuery, func(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
|
||||
cypher := request.Params.Arguments["cypher"].(string)
|
||||
args, ok := request.Params.Arguments.(map[string]interface{})
|
||||
if !ok {
|
||||
return mcp.NewToolResultText(""), fmt.Errorf("invalid arguments type")
|
||||
}
|
||||
cypher, ok := args["cypher"].(string)
|
||||
if !ok {
|
||||
return mcp.NewToolResultText(""), fmt.Errorf("cypher argument is not a string")
|
||||
}
|
||||
result, err := util.ExecuteReadOnlyCypherQuery(cypher)
|
||||
|
||||
fmt.Println(result)
|
||||
@ -438,7 +446,14 @@ func GetNodeFields(nodeType string) ([]string, error) {
|
||||
})
|
||||
|
||||
s.AddTool(getNodeField, func(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
|
||||
nodeLabel := request.Params.Arguments["nodeLabel"].(string)
|
||||
args, ok := request.Params.Arguments.(map[string]interface{})
|
||||
if !ok {
|
||||
return mcp.NewToolResultText(""), fmt.Errorf("invalid arguments type")
|
||||
}
|
||||
nodeLabel, ok := args["nodeLabel"].(string)
|
||||
if !ok {
|
||||
return mcp.NewToolResultText(""), fmt.Errorf("nodeLabel argument is not a string")
|
||||
}
|
||||
result, err := util.GetNodeFields(nodeLabel)
|
||||
|
||||
fmt.Println(result)
|
||||
|
@ -1,5 +1,7 @@
|
||||
# python 实现天气信息 mcp 服务器
|
||||
|
||||
[本期教程视频](https://www.bilibili.com/video/BV1zYGozgEHc)
|
||||
|
||||
## hook
|
||||
|
||||
等等,开始前,先让我们看一个小例子,假设我下周要去明日方舟锈影新生的漫展,所以我想要知道周六杭州的天气,于是我问大模型周六的天气,结果大模型给了我如下的回复:
|
||||
|
@ -43,6 +43,30 @@ const contributors = [
|
||||
{ icon: 'github', link: 'https://github.com/ArcStellar2025' },
|
||||
]
|
||||
},
|
||||
{
|
||||
avatar: 'https://avatars.githubusercontent.com/u/129645384?v=4',
|
||||
name: 'SFXJX (社奉行佳婿)',
|
||||
title: 'Developer',
|
||||
links: [
|
||||
{ icon: 'github', link: 'https://github.com/STUzhy' },
|
||||
]
|
||||
},
|
||||
{
|
||||
avatar: 'https://avatars.githubusercontent.com/u/37235140?v=4',
|
||||
name: 'hao (cybermanhao)',
|
||||
title: 'Developer',
|
||||
links: [
|
||||
{ icon: 'github', link: 'https://github.com/cybermanhao' },
|
||||
]
|
||||
},
|
||||
{
|
||||
avatar: 'https://avatars.githubusercontent.com/u/213030338?v=4',
|
||||
name: 'reliedejuedouzhe2',
|
||||
title: 'Developer',
|
||||
links: [
|
||||
{ icon: 'github', link: 'https://github.com/reliedejuedouzhe2' },
|
||||
]
|
||||
}
|
||||
]
|
||||
</script>
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user