Procurement MCP Server
This server exposes an IT procurement backend's REST APIs as MCP tools, allowing AI clients to query and inspect purchase-order and e-signature data through natural language.
Check backend health: Verify whether the procurement backend is online via
GET /api/health.Search purchase orders: Search by keyword (PO number or name), optionally filter by status code and limit the number of results.
Get purchase order details: Retrieve line items, delivery/payment info, invoices, and attachments for a single purchase order (resolves PO number to the backend database ID first).
Check e-signature status: View e-sign workflows and each signer's status; note that matching is text-based (looks for PO/invoice numbers in the signing subject), not a true relational link.
The server handles login/JWT authentication with the backend automatically, so users only interact through MCP tools.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Procurement MCP Server search for all pending purchase orders"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Procurement MCP Server
一個以 IT 採購流程為題的 MCP (Model Context Protocol) server 學習專案。 它把既有的採購後端 (REST API) 包裝成 AI 可呼叫的工具,讓 Claude 等 AI 能透過自然語言查詢採購資料。
架構
AI client ──(MCP / stdio)──▶ 本 server ──(HTTP + JWT)──▶ 採購後端 REST API本 server 不做業務邏輯,只負責把後端能力轉成 MCP 工具,並處理登入與認證。
Related MCP server: sap-mcp-server
目前提供的工具
工具 | 說明 | 對應的後端端點 |
| 檢查後端是否正常運作 |
|
| 依關鍵字搜尋採購單,可選狀態碼篩選與筆數限制 |
|
| 查單一採購單明細:品項、送達與付款資訊、發票、附件 |
|
| 查電子簽核進度與每位簽署人的狀態 |
|
幾個實作上的注意事項:
get_purchase_order_details會串接兩個後端呼叫。 後端明細 API 的:id是資料庫的數字 id,不是採購單號,所以工具先用搜尋把單號換成 id 再取明細。 單號沒有完全命中時會列出相近選項請使用者指定,不會自己猜一筆。後端的
warning欄位會照實轉達。 後端向 FreshService 取資料失敗時, 回傳的品項會是空的並附上warning。工具會明確說明這是「取不到」而不是 「沒有」——否則 AI 會把失敗講成「這張單沒有品項」。check_esign_status依採購單查詢是「文字比對」,不是資料關聯。 後端的esign_requests表只存廠商、主旨與簽署人,沒有採購單欄位, 所以只能比對簽核主旨裡有沒有出現單號或發票號。工具的輸出會標明這一點: 比對不到不代表該採購單沒有送簽。若要真正的關聯,需要在後端的esign_requests加上po_number之類的欄位。
開發環境設定
需求:Node.js 20+。
npm install
cp .env.example .env # 然後填入 BACKEND_URL 與登入帳密
npm run dev # 用 tsx 直接執行 index.ts可用的 npm script:
指令 | 用途 |
| tsx watch,改檔就重啟 |
| tsx 直接跑一次 |
| 用 tsc 編譯到 |
| 跑編譯後的 |
| 跑回歸測試(見下) |
測試
npm test測試會真的把 index.ts 跑起來,用 MCP 協定呼叫每個工具,後端則換成
test/mock-backend.mjs——一個回傳格式照著真後端抄的假後端。所以測到的是
整條路:zod 參數驗證 → 登入帶 token → 呼叫後端 → 後處理 → 排版輸出。
不需要啟動真的採購後端,也不會碰到網路。
test/
├── mock-backend.mjs 假後端(回傳格式對齊真後端的 route)
├── mcp-client.mjs 用 stdio 講 MCP 的極簡測試 client
└── tools.test.mjs 各工具的回歸測試⚠️ 真後端改了回傳欄位時,
test/mock-backend.mjs也要跟著改, 否則測試會綠但實際是壞的。
環境變數 (.env)
變數 | 說明 |
| 採購後端位置,預設 |
| 後端登入帳號 |
| 後端登入密碼 |
⚠️
.env含密碼,已被.gitignore忽略,請勿 commit。
連接到 Claude Desktop
在 claude_desktop_config.json 的 mcpServers(小寫)加入:
{
"mcpServers": {
"procurement": {
"command": "npx",
"args": ["tsx", "/absolute/path/to/index.ts"]
}
}
}修改程式後需以 Cmd+Q 完整結束並重新開啟 Claude Desktop。
Available Tools
2 toolscheck_backend_health檢查採購後端健康狀態A
檢查採購流程後端服務是否正常運作。會呼叫後端的 /api/health 端點。當使用者想確認系統是否上線,或在做其他操作前想先確認連線時使用。
Inputs: no named parameters.
search_purchase_orders搜尋採購單A
依關鍵字搜尋採購單(會比對採購單號 po_number 或名稱 name),可選擇性地只篩選特定狀態、並限制回傳筆數。當使用者想查詢、尋找採購單時使用,例如「幫我找已核准的螢幕採購單,最多 5 筆」。
Inputs: q (required), limit, status.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 2 tools
The two tools are completely distinct: one checks backend health, the other searches purchase orders. There is no overlap or ambiguity in their purposes.
Both tools follow a consistent verb_noun pattern with snake_case: check_backend_health and search_purchase_orders. The naming convention is uniform and predictable.
With only 2 tools, the server feels thin for a procurement domain. The count is borderline—reasonable for a tiny read-only utility, but not enough for a full procurement MCP server.
The surface only provides search and health check. Missing are essential operations like create, update, delete, or get-by-id for purchase orders. This is a significant gap for a procurement-focused server.
Related MCP Connectors
Discover, plan and run tools across your connected business systems through one OAuth MCP endpoint
Pay-per-use tool marketplace for AI agents. Search, price-check, and call APIs via MCP.
MCP server unifying ERPs, CRMs, APIs and knowledge base for Claude, ChatGPT and Gemini.
Zero-setup MCP gateway securely connecting AI to your tools with authentication and workflows
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceEnables AI assistants to retrieve, search, and compare procurement documents using hybrid retrieval and MCP integration.-
- FlicenseNot gradedqualityDmaintenanceEnables natural language querying of SAP business partner data by exposing OData APIs as MCP tools for LLM agents.1-
- AlicenseNot gradedqualityDmaintenanceA metadata-driven MCP server that exposes selected SAP Ariba OpenAPI operations as configurable tools, enabling secure interaction with Ariba APIs through natural language.MIT
- FlicenseNot gradedqualityDmaintenanceEnables AI agents to query and manage ERP procurement data, including suppliers, parts, inventory, and purchase orders, with human approval for write operations.-