Skip to main content
Glama

Building a MCP Server for Agentic Commerce (PayPal Edition)

Written by on .

mcp
Paypal
Agentic Ai

  1. Problem
    1. The Approach
      1. Example Server Design (TypeScript)
        1. 1. Directory Structure
          1. 2. Main Server Setup (mcp-server.ts)
            1. 3. Example Checkout Tool (tools/checkout.ts)
            2. Key Takeaways
              1. Acknowledgements

                Imagine an AI agent that shops for you—browsing catalogs, comparing prices, completing checkout, and tracking delivery. In their MCP Summit session, Brenden Lane and Nitin Sharma from PayPal showed this is not just possible—it’s already happening. With MCP servers, agents can now handle entire shopping workflows end-to-end.

                Problem

                Online shopping today is still largely manual. Users search, compare, and buy. Merchants, in turn, run ads and promotions hoping to catch attention. This human-first loop feels outdated. What if agents could handle the shopping for us?

                The Approach

                PayPal’s MCP server for Agentic Commerce gives AI agents the tools to:

                • Browse and search product catalogs
                • Compare products and prices
                • Make secure purchases with authentication
                • Check shipping, inventory, and payment options

                All done through structured tool calls over MCP.

                Example Server Design (TypeScript)

                A simple way to build such a server in TypeScript:

                1. Directory Structure

                agentic-commerce-server/ ├── tools/ │ ├── catalog/ │ ├── productDetails/ │ ├── checkout/ │ └── emailReceipt/ ├── .env ├── mcp-server.ts └── package.json

                2. Main Server Setup (mcp-server.ts)

                import { createServer } from 'mcp-server'; import { catalogTool } from './tools/catalog'; import { productDetailsTool } from './tools/productDetails'; import { checkoutTool } from './tools/checkout'; import { emailReceiptTool } from './tools/emailReceipt'; createServer({ tools: [catalogTool, productDetailsTool, checkoutTool, emailReceiptTool], model: 'gpt-4', io: 'stdio', });

                3. Example Checkout Tool (tools/checkout.ts)

                import { defineTool } from 'mcp-server'; export const checkoutTool = defineTool({ name: 'checkout_order', description: 'Securely check out an order and complete payment', inputSchema: { productId: 'string', userId: 'string', paymentMethodId: 'string', }, execute: async ({ productId, userId, paymentMethodId }) => { return { status: 'success', orderId: `ORD-${Math.floor(Math.random() * 10000)}`, }; }, });

                Key Takeaways

                • Typed tools help agents perform complex tasks like shopping securely and reliably.
                • Clear tool boundaries make the system easier to maintain.
                • Control mechanisms like audit logs and access restrictions are essential.

                PayPal’s server also prioritizes trust, schema checks, sandbox testing, and discovery across agents.

                Acknowledgements

                This guide is based on Brenden Lane and Nitin Sharma's session at the MCP Summit – Building a MCP Server for Agentic Commerce, where they demonstrated how to build a full-stack server for agent-driven shopping.

                Thanks to the Anthropic team and the broader MCP developer community for their ongoing contributions to this space.

                Written by Om-Shree-0709 (@Om-Shree-0709)