MCP-Server

MCP-Server

3.1

The Model Context Protocol (MCP) server is designed to facilitate communication between clients and servers using a structured protocol, often used in conjunction with LLM (Large Language Models) and other AI technologies.

MCP Project

環境建置

  1. 下載 Node.js
  2. 下載 docker 然後執行以下命令
docker run -d --name postgres -p 5432:5432 -e POSTGRES_PASSWORD=admin postgres
  1. 建立 Server
npm install
npm run build
  1. 建立 claude_desktop_config.json
cd ~/Library/Application\ Support/Claude
touch claude_desktop_config.json
  1. 將以下內容貼至剛建立的檔案內
{
  "mcpServers": {
    "mcp-server": {
      "command": "node",
      "args": ["/absolute/path/to/your/hello-mcp/build/index.js"]
    }
  }
}
  1. 執行 MCP 檢查器
npm run inspector
  1. 打開瀏覽器輸入以下網址 http://localhost:5173 ,點擊 Connect 按鈕
  2. 右側會出現以下畫面再點選 List Resources,會列出先前ListResourcesRequestSchema 所提供的 Resources
  3. 點擊 Hello World Message, 右側會出現 Server 的回應