calculate-price MCP Server
Click on "Install 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., "@calculate-price MCP Servercompute price for 5 units of $20 for silver tier"
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.
MCP vs 普通 Function Calling Demo
这个项目用同一个 calculatePrice 业务函数,对比两种调用方式:
MCP:把函数暴露成本地
stdioMCP tool,供 Codex 或其他 MCP client 调用。普通 API:把函数暴露成 HTTP API,应用再用 OpenAI Responses API 的 function calling 让模型选择调用参数,最后由应用请求这个 HTTP API。
安装和构建
npm install
npm run buildRelated MCP server: AWS Pricing Calculator MCP Server
共享函数
核心函数在 src/price.ts:
输入:
unitPrice、quantity、customerTier、可选couponCode、可选taxRate输出:小计、会员折扣、优惠码折扣、税费、最终价格
MCP server 和 HTTP API server 都只调用这一个函数。
方式一:通过 MCP 接入 Codex
构建后注册 MCP server:
codex mcp add price-demo -- node /Users/kierantou/Desktop/MCP/dist/mcp-server.js
codex mcp list
codex mcp get price-demo在 Codex 新会话或当前会话的 /mcp 里确认 price-demo 已启用,然后提问:
帮我计算单价 199、数量 3、gold 用户、优惠码 SAVE10 的最终价格期望 Codex 调用 calculate_price tool,而不是自己心算。
开发时也可以直接启动 MCP server:
npm run dev:mcp这个命令会等待 MCP client 通过 stdio 通信,手动运行时没有交互输出是正常的。
方式二:普通 HTTP API + OpenAI Function Calling
先启动价格 API:
npm run dev:api默认服务地址:
http://localhost:3000接口:
curl -X POST http://localhost:3000/calculate-price \
-H 'content-type: application/json' \
-d '{"unitPrice":199,"quantity":3,"customerTier":"gold","couponCode":"SAVE10"}'先设置 API key:
export OPENAI_API_KEY="your_api_key_here"运行默认示例:
npm run dev:function也可以传入自己的问题:
npm run dev:function -- "计算单价 88、数量 5、platinum 用户、优惠码 SAVE20 的价格"脚本会:
把
calculate_price的 JSON schema 发给 Responses API。接收模型返回的 function call。
请求 HTTP API:
POST /calculate-price。把函数结果发回模型。
输出最终自然语言回答。
注意:普通 function calling 里,模型不是自己直接访问任意 HTTP API。模型只会返回一次结构化 function call;真正请求 API 的动作由你的应用代码完成。
对比结论
普通 HTTP API + function calling 更接近传统应用集成方式。业务函数先暴露成 API,应用需要自己声明工具、接收工具调用、请求 API、回传结果。
MCP 更适合把工具做成独立能力。工具 server 可以被 Codex、其他 MCP client 或未来服务复用;client 负责发现工具和调用工具。
第一版只实现本地 stdio MCP。后续如果要给远程 Responses API MCP tool 使用,可以把同一套 calculatePrice 包装成 Streamable HTTP MCP server。
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/KieranTou-AI/mcp-test'
If you have feedback or need assistance with the MCP directory API, please join our Discord server