ericsiang/first_mcp_server
3.2
If you are the rightful owner of first_mcp_server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
The Model Context Protocol (MCP) server is a versatile server framework that supports communication between clients and servers using the MCP protocol, which is particularly useful for integrating with Large Language Models (LLMs).
Tools
2
Resources
0
Prompts
0
Go MCP Server 服務
參考:
MCP server 建立
- 目前MCP 支援 SSE 和Stdio兩種類型。
- stdio:standard input output,標準輸入輸出,適用於mcp client和mcp server部署在同一個機器上,不涉及跨機器。
- sse:Server-Sent Events,伺服器發送事件,是基於HTTP的協定。適用於mcp client與mcp server不在同一個機器的場景,涉及網路傳輸。
server 對外提供資源設定
- 資源是你向 LLMs 揭露資料的方式。它們可以是任何東西:檔案、API 回應、資料庫查詢、系統資訊等。資源可以是:
- 靜態資源(固定 URI)
- 動態資源(使用 URI 模板)
server 對外提供工具
- 工具讓 LLM 透過你的伺服器執行操作。與資源不同,工具預期會進行計算並產生副作用。它們類似於 REST API 中的 POST 端點。 下面是一個算術運算的工具範例:
- 工具可以用於任何種類的計算:
- Database queries 資料庫查詢
- File operations 檔案操作
- External API calls 外部 API 呼叫
- Calculations 計算
- System operations 系統操作
- 每個工具應該:
- 有清晰的描述
- 驗證輸入
- 優雅處理錯誤
- 返回結構化的響應
- 使用適當的結果類型
- 工具可以用於任何種類的計算:
建立自己的 Stdio MCP Server
main.go
- 查詢 IP 資訊的工具 => ip_query
- 查詢顯示狗狗圖片的工具 => dog_query
產生執行檔
go build -o mcpServer
使用 vscode cline extensions 內設定,測試自建的MCP Server
cline_mcp_settings.json
{
"mcpServers": {
"siang-mcp-server": {
"command": "產生的執行檔路徑",
"args": []
}
}
}
有成功執行