{
  "name": "buynearby",
  "version": "1.0.0",
  "description": "Search local Calgary stores for products, stock and deals; place orders for delivery or pickup, book a courier, or request a personal shopping run. Orders and bookings are real.",
  "tools": [
    {
      "name": "search_products",
      "description": "Searches products available at local Calgary stores. Returns product name, store, price, stock level and store categories.",
      "input_schema": {
        "type": "object",
        "properties": {
          "q": {
            "type": "string",
            "description": "Product search query — can be a product name, ingredient, or natural language description"
          },
          "limit": {
            "type": "integer",
            "description": "Number of results (max 50)",
            "default": 5
          }
        },
        "required": [
          "q"
        ]
      }
    },
    {
      "name": "check_stock",
      "description": "Returns the live stock level of one product, optionally for a single store.",
      "input_schema": {
        "type": "object",
        "properties": {
          "product_id": {
            "type": "string",
            "description": "Product ID from search results"
          },
          "store_id": {
            "type": "integer",
            "description": "Store ID (optional)"
          }
        },
        "required": [
          "product_id"
        ]
      }
    },
    {
      "name": "get_todays_deals",
      "description": "Returns today's discounted products and active flash deals at local stores, with sale and regular prices.",
      "input_schema": {
        "type": "object",
        "properties": {
          "store_id": {
            "type": "integer",
            "description": "Limit to one store (optional — omit for deals across all stores)"
          },
          "limit": {
            "type": "integer",
            "description": "Max results per section. Default 20, max 50"
          }
        },
        "required": []
      }
    },
    {
      "name": "get_stores",
      "description": "Returns local Calgary stores with their location information.",
      "input_schema": {
        "type": "object",
        "properties": {},
        "required": []
      }
    },
    {
      "name": "place_order",
      "description": "Places an order for one product from a BuyNearby store. Creates a real order; the customer receives a payment link by text or email, the card is held and is only charged after the store confirms the order. Guests provide name, phone and email; signed-in customers' saved details are used.",
      "input_schema": {
        "type": "object",
        "properties": {
          "product_id": {
            "type": "string"
          },
          "quantity": {
            "type": "integer",
            "default": 1
          },
          "customer_email": {
            "type": "string"
          },
          "delivery_address": {
            "type": "string"
          },
          "express": {
            "type": "boolean",
            "default": false,
            "description": "Adds an express fee (default $4.99 CAD)"
          },
          "requested_by_time": {
            "type": "string",
            "description": "Any parseable date/time, e.g. 'today 22:00' - recorded on the order, not an enforced SLA at this tier"
          }
        },
        "required": [
          "product_id",
          "customer_email",
          "delivery_address"
        ]
      }
    },
    {
      "name": "place_cart_order",
      "description": "Places one order for several products from one or more BuyNearby stores. Prices and stock come from the live catalog. Creates a real order; the customer receives a payment link by text or email, the card is held and is only charged after the store confirms the order. Delivery or pickup.",
      "input_schema": {
        "type": "object",
        "properties": {
          "customer_name": {
            "type": "string"
          },
          "customer_phone": {
            "type": "string"
          },
          "customer_email": {
            "type": "string"
          },
          "delivery_address": {
            "type": "string",
            "description": "Required unless fulfillment_type is 'pickup'"
          },
          "fulfillment_type": {
            "type": "string",
            "enum": [
              "delivery",
              "pickup"
            ],
            "default": "delivery"
          },
          "coupon_code": {
            "type": "string"
          },
          "express": {
            "type": "boolean",
            "default": false
          },
          "tip_percentage": {
            "type": "number",
            "default": 0,
            "description": "Only set this if the user explicitly chose a tip - don't default one in on their behalf"
          },
          "items": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "product_id": {
                  "type": "string",
                  "description": "From search_products results"
                },
                "quantity": {
                  "type": "integer",
                  "default": 1
                }
              },
              "required": [
                "product_id"
              ]
            }
          }
        },
        "required": [
          "customer_name",
          "customer_phone",
          "delivery_address",
          "items"
        ]
      }
    },
    {
      "name": "book_courier",
      "description": "Gets a quote for, books, checks the status of, or cancels a point-to-point courier delivery in Calgary. A booking is real and a driver is assigned when available; payment is a link sent to the customer by text and this call never charges a card. A booking can be cancelled while it is pending or assigned.",
      "input_schema": {
        "type": "object",
        "properties": {
          "action": {
            "type": "string",
            "enum": [
              "quote",
              "book",
              "status",
              "cancel"
            ]
          },
          "pickup_address": {
            "type": "string",
            "description": "Required for action 'quote'/'book'"
          },
          "delivery_address": {
            "type": "string",
            "description": "Required for action 'quote'/'book'"
          },
          "size_tier": {
            "type": "string",
            "enum": [
              "small",
              "standard",
              "heavy"
            ],
            "default": "standard"
          },
          "package_count": {
            "type": "integer",
            "default": 1
          },
          "customer_name": {
            "type": "string",
            "description": "Required for action 'book'"
          },
          "customer_phone": {
            "type": "string",
            "description": "Required for action 'book', 'status', and 'cancel' — for 'status'/'cancel' this must match the phone on the booking (it's the ownership check, since booking_ref alone is guessable)"
          },
          "customer_email": {
            "type": "string"
          },
          "delivery_notes": {
            "type": "string"
          },
          "preferred_pickup_time": {
            "type": "string",
            "description": "Any parseable date/time; omit for ASAP dispatch"
          },
          "preferred_dropoff_time": {
            "type": "string",
            "description": "Any parseable date/time the customer needs the delivery completed by, e.g. 'today 10pm'; must not be before preferred_pickup_time"
          },
          "idempotency_key": {
            "type": "string",
            "description": "Optional, action 'book' only — pass the same value on a retry (e.g. after a dropped connection) to avoid creating a duplicate booking"
          },
          "booking_ref": {
            "type": "string",
            "description": "Required for action 'status'/'cancel', e.g. 'CB-20260912-0007'"
          },
          "cancel_reason": {
            "type": "string",
            "description": "Optional, action 'cancel' only"
          }
        },
        "required": [
          "action"
        ]
      }
    },
    {
      "name": "shop_and_deliver",
      "description": "Books a personal shopping run: a BuyNearby driver shops the given item list at a named store and delivers it. Creates a real order; the customer is charged the driver's actual receipt total afterward. Item prices given are estimates.",
      "input_schema": {
        "type": "object",
        "properties": {
          "customer_name": {
            "type": "string"
          },
          "customer_phone": {
            "type": "string"
          },
          "customer_email": {
            "type": "string"
          },
          "delivery_address": {
            "type": "string"
          },
          "store_hint": {
            "type": "string",
            "description": "Physical store name, e.g. 'Purdys Chocolatier Chinook Centre'"
          },
          "notes": {
            "type": "string"
          },
          "items": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "item_name": {
                  "type": "string"
                },
                "quantity": {
                  "type": "number",
                  "default": 1
                },
                "unit": {
                  "type": "string",
                  "default": "each"
                },
                "estimated_price": {
                  "type": "number",
                  "description": "CAD, your best estimate for this line - becomes the driver's shopping budget"
                },
                "product_id": {
                  "type": "string"
                },
                "store_id": {
                  "type": "integer"
                },
                "notes": {
                  "type": "string"
                }
              },
              "required": [
                "item_name",
                "estimated_price"
              ]
            }
          }
        },
        "required": [
          "customer_name",
          "customer_phone",
          "delivery_address",
          "store_hint",
          "items"
        ]
      }
    }
  ],
  "mcp_endpoint": "https://buynearby.store/api/v1/mcp-server.php",
  "mcp_endpoint_note": "This file (mcp.json) is a discovery manifest, not a live protocol server — point an actual MCP client's custom connector at mcp_endpoint above (JSON-RPC 2.0 over HTTP POST: initialize, tools/list, tools/call). mcp_endpoint is an OAuth 2.1-protected resource (RFC 9728 metadata at /.well-known/oauth-protected-resource; authorization server metadata, RFC 8414, at /.well-known/oauth-authorization-server) supporting Dynamic Client Registration (RFC 7591) and Authorization Code + PKCE — an unauthenticated request gets a 401 with a WWW-Authenticate header that should drive a compliant client through connect/login/consent automatically, after which place_order/place_cart_order/book_courier/shop_and_deliver auto-fill the connected user's own name/phone/email. For clients that don't support OAuth discovery, an X-API-Key header (or ?key= query param on the mcp_endpoint URL) also works as a shared platform key, with identity supplied explicitly in each tool call's arguments instead.",
  "server": {
    "url": "https://buynearby.store/api/v1",
    "endpoints": {
      "search_products": "GET /search.php",
      "check_stock": "GET /stock.php",
      "get_todays_deals": "GET /deals.php",
      "get_stores": "GET /stores.php",
      "place_order": "POST /order.php",
      "place_cart_order": "POST /cart-order.php",
      "book_courier": "POST /courier.php",
      "shop_and_deliver": "POST /shop-and-deliver.php"
    }
  }
}