Beckn Mobility MCP Server

Beckn Mobility MCP Server

Enables AI agents to search for cabs, view prices, and book rides through the open Beckn Protocol by connecting to Beckn-compliant mobility providers like Namma Yatri and ONDC.

Category
Visit Server

README

Beckn Mobility MCP Server

A generic Model Context Protocol (MCP) server for the Beckn Mobility domain. This server acts as a Buyer Application Platform (BAP), enabling AI agents (like Claude, Gemini, etc.) to search for cabs, view prices, and book rides using the open Beckn Protocol (e.g., Namma Yatri, ONDC).

Features

  • Generic BAP Implementation: Connects to any Beckn-compliant Mobility BPP.
  • MCP Tools: Exposes search_cabs, select_ride, init_booking, and confirm_booking as AI tools.
  • Async Webhook Handling: Robust WebhookManager handles Beckn's asynchronous callbacks with timeouts and request correlation.
  • Secure Signing: Implements Ed25519 request signing required by the Beckn Registry.
  • Hono Server: Built on Hono for high-performance HTTP handling and Server-Sent Events (SSE).
  • Verification Scripts: Includes a suite of scripts to verify crypto signing and end-to-end flows.

Prerequisites

  • Node.js v18+
  • A public URL (using ngrok or a cloud deployment) for receiving webhooks.
  • Registration with a Beckn Registry (e.g., Namma Yatri Sandbox).

Installation

  1. Clone the repository:

    git clone https://github.com/<YOUR_USERNAME>/mcp-beckn-mobility.git
    cd mcp-beckn-mobility
    
  2. Install dependencies:

    npm install
    

Configuration

  1. Generate Keys: Run the helper script to generate your Ed25519 signing keys.

    npx tsx src/generate_keys.ts
    

    Copy the output (BAP ID, Public Key, Private Key).

  2. Setup Environment: Copy .env.example to .env (or create it) and fill in your details:

    # Beckn Registry Details
    BAP_ID=mcp-mobility-bap-<TIMESTAMP>
    UNIQUE_KEY_ID=key1
    SIGNING_PRIVATE_KEY=<YOUR_PRIVATE_KEY>
    SIGNING_PUBLIC_KEY=<YOUR_PUBLIC_KEY>
    
    # URLs
    BAP_URI=https://<YOUR_NGROK_URL>  # Must be public!
    BPP_URI=https://gateway.nammayatri.in/search # Or local mock
    
    PORT=3000
    
  3. Register: Use your BAP ID and Public Key to register on the Namma Yatri / Beckn Registry.

Usage

  1. Start the Server:

    npm run dev
    
  2. Connect via Ngrok (if running locally):

    ngrok http 3000
    

    Update BAP_URI in .env with the ngrok URL.

  3. Connect your AI Client: Configure your MCP Client (e.g., Claude Desktop) to connect to the SSE endpoint:

    • URL: http://localhost:3000/sse

Verification

We have included scripts to verify the system before going live:

  • Verify Crypto: Checks if your keys and signing logic are mathematically correct.

    npx tsx src/verify_crypto.ts
    
  • Verify Full Flow (Local): Runs a local Mock BPP and tests the full HTTP request/response loop.

    npx tsx src/verify_full_flow.ts
    
  • Black Box Test: Simulates an MCP Client connecting via SSE and calling tools.

    npx tsx src/verify_mcp_client.ts
    

Project Structure

  • src/index.ts: Main server entry point (Hono app).
  • src/tools/mobilityTools.ts: MCP Tool definitions (search_cabs, etc.).
  • src/lib/becknClient.ts: Handles Beckn protocol communication and signing.
  • src/lib/webhookManager.ts: Manages async callbacks.
  • src/lib/honoTransport.ts: Custom MCP Transport for Hono.

License

MIT

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured