121 lines
3.4 KiB
Go
121 lines
3.4 KiB
Go
package services
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"runtime"
|
|
"strings"
|
|
)
|
|
|
|
// McpMarketItem MCP 市场条目
|
|
type McpMarketItem struct {
|
|
Key string `json:"key"`
|
|
Name string `json:"name"`
|
|
Description string `json:"description"`
|
|
Provider string `json:"provider"`
|
|
Transport string `json:"transport"` // stdio/http/sse
|
|
Command string `json:"command"`
|
|
Args []string `json:"args"`
|
|
Env []string `json:"env"`
|
|
URL string `json:"url"`
|
|
Tags []string `json:"tags"`
|
|
BuiltIn bool `json:"built_in"` // 是否为项目内置(演示)服务
|
|
}
|
|
|
|
// demoMcpPath 解析内置演示 MCP 服务可执行文件路径
|
|
// 优先级:1) 服务器工作目录下 bin/demo-mcp 2) go run ./cmd/demo-mcp 兜底
|
|
func demoMcpPath() (string, []string) {
|
|
ext := ""
|
|
if runtime.GOOS == "windows" {
|
|
ext = ".exe"
|
|
}
|
|
candidates := []string{
|
|
filepath.Join("bin", "demo-mcp"+ext),
|
|
filepath.Join("..", "bin", "demo-mcp"+ext),
|
|
}
|
|
if wd, err := os.Getwd(); err == nil {
|
|
for _, c := range candidates {
|
|
p := filepath.Join(wd, c)
|
|
if info, err := os.Stat(p); err == nil && !info.IsDir() {
|
|
return p, nil
|
|
}
|
|
}
|
|
}
|
|
// 兜底:go run ./cmd/demo-mcp(需要 Go 工具链)
|
|
return "go", []string{"run", "./cmd/demo-mcp"}
|
|
}
|
|
|
|
// GetMcpMarket 返回 MCP 市场服务列表
|
|
func GetMcpMarket() []McpMarketItem {
|
|
cmd, args := demoMcpPath()
|
|
list := []McpMarketItem{
|
|
{
|
|
Key: "demo",
|
|
Name: "内置演示 MCP",
|
|
Description: "项目自带演示服务:提供当前时间、计算器、模拟天气、回声等工具,用于验证 MCP 全链路。",
|
|
Provider: "本项目",
|
|
Transport: "stdio",
|
|
Command: cmd,
|
|
Args: args,
|
|
Tags: []string{"演示", "零配置"},
|
|
BuiltIn: true,
|
|
},
|
|
{
|
|
Key: "tianyancha",
|
|
Name: "天眼查 MCP",
|
|
Description: "企业工商信息查询、股权穿透、司法风险等数据服务。",
|
|
Provider: "天眼查",
|
|
Transport: "http",
|
|
URL: "https://mcp.tianyancha.com/mcp",
|
|
Tags: []string{"企业信息"},
|
|
},
|
|
{
|
|
Key: "qcc",
|
|
Name: "企查查 MCP",
|
|
Description: "企业信用信息、工商资料、经营风险等数据查询服务。",
|
|
Provider: "企查查",
|
|
Transport: "http",
|
|
URL: "https://mcp.qcc.com/mcp",
|
|
Tags: []string{"企业信息"},
|
|
},
|
|
{
|
|
Key: "qianzhan",
|
|
Name: "前瞻 MCP",
|
|
Description: "前瞻产业研究院行业数据、研究报告等。",
|
|
Provider: "前瞻",
|
|
Transport: "http",
|
|
URL: "https://mcp.qianzhan.com/mcp",
|
|
Tags: []string{"行业数据"},
|
|
},
|
|
{
|
|
Key: "itjuzi",
|
|
Name: "IT桔子 MCP",
|
|
Description: "创业公司数据、投融资事件、行业洞察等。",
|
|
Provider: "IT桔子",
|
|
Transport: "http",
|
|
URL: "https://mcp.itjuzi.com/mcp",
|
|
Tags: []string{"创投数据"},
|
|
},
|
|
{
|
|
Key: "boss",
|
|
Name: "BOSS直聘 MCP",
|
|
Description: "BOSS直聘企业招聘、职位等数据服务。",
|
|
Provider: "BOSS直聘",
|
|
Transport: "http",
|
|
URL: "https://mcp.zhipin.com/mcp",
|
|
Tags: []string{"招聘"},
|
|
},
|
|
}
|
|
return list
|
|
}
|
|
|
|
// FindMarketItem 按 key 查找市场条目
|
|
func FindMarketItem(key string) (McpMarketItem, bool) {
|
|
for _, item := range GetMcpMarket() {
|
|
if strings.EqualFold(item.Key, key) {
|
|
return item, true
|
|
}
|
|
}
|
|
return McpMarketItem{}, false
|
|
}
|