Genesis Arbitrage

Genesis Arbitrage · · 3 मिनट में पढ़ें

MCP (Model Context Protocol)

MCP (Model Context Protocol) एक खुला प्रोटोकॉल है जिसके ज़रिए AI एप्लिकेशन बाहरी डेटा और tools से जुड़ते हैं: फ़ाइलें, databases, APIs। Anthropic ने इसे नवंबर 2024 में open-source किया और दिसंबर 2025 में Linux Foundation के तहत एक directed fund, Agentic AI Foundation, को दान कर दिया।

MCP कैसे काम करता है

AI एप्लिकेशन, जिसे host कहते हैं, हर उस server के लिए एक MCP client बनाता है जिससे वह जुड़ता है। MCP server एक प्रोग्राम है जो tools (ऐसे functions जिन्हें model call कर सकता है), resources (संदर्भ के लिए डेटा) और prompts (prompt templates) उपलब्ध कराता है। संदेश JSON-RPC 2.0 का उपयोग करते हैं, और transport लोकल server के लिए stdio तथा रिमोट server के लिए Streamable HTTP है (MCP documentation)।

Client tools/list request से tools की सूची लेता है और tools/call से उनमें से किसी को call करता है, नाम और arguments देकर। हर tool में name, description और inputSchema होता है, जो उसके arguments का JSON Schema है।

REST API के ऊपर MCP

Market data के लिए MCP server आमतौर पर REST API पर एक पतला wrapper होता है: एक tool, एक HTTP request। API key server के environment में रहती है और केवल request header में जाती है (authentication); model को सिर्फ़ tool का विवरण और response दिखता है।

Genesis API का कोई आधिकारिक MCP server नहीं है। Wrapper आप खुद लिखते हैं; यह आधिकारिक Python SDK पर न्यूनतम उदाहरण है (mcp package, वर्शन 2.0 या नया, और requests):

import os

import requests
from mcp.server import MCPServer

API = "https://api.genesisarbitrage.com/v1"
mcp = MCPServer("genesis-funding")


@mcp.tool()
def funding_rates(coin: str) -> str:
    """A coin's funding rates across exchanges from Genesis API.

    Args:
        coin: coin ticker, for example BTC
    """
    r = requests.get(
        f"{API}/funding/rates",
        headers={"X-API-Key": os.environ["GENESIS_API_KEY"]},
        params={"coin": coin.upper()},
        timeout=10,
    )
    return r.text  # JSON: data और meta, या कोड के साथ error


if __name__ == "__main__":
    mcp.run(transport="stdio")

MCP सपोर्ट वाला असिस्टेंट इस फ़ाइल को लोकल server की तरह चलाता है (launch command उसकी settings में जाती है) और उसे funding_rates tool मिल जाता है: /funding/rates से किसी coin के exchanges पर funding rates।

यह भी देखें: function calling, OpenAPI, API key, AI agents के लिए crypto market data, AI agents के लिए Genesis API।

सवाल और जवाब

MCP और function calling में क्या अंतर है?

Function calling model के API की एक सुविधा है: एप्लिकेशन request के साथ tool विवरण भेजता है और calls खुद चलाता है। MCP एप्लिकेशन और tool server के बीच का प्रोटोकॉल है, इसलिए एक server किसी भी MCP-सक्षम client के साथ चलता है। एप्लिकेशन के भीतर MCP servers के tools फिर भी function calling के ज़रिए ही model तक पहुँचते हैं।