Diwali Offer!Flat 20% OFF
Enroll Now
PrakalpanaLive online tech training
AI & ML⏱️ 10 min readπŸ“… Nov 24

MCP Explained: Model Context Protocol Guide for Developers (2026)

RM
Rahul Menonβ€’GenAI Engineer
πŸ“‘ Contents (15 sections)

πŸ“ŒWhat MCP Is

The Model Context Protocol (MCP) is an open standard for connecting AI applications to tools and data. Instead of writing a custom integration for every pair of AI app and service, you write an MCP server once for your service, and any MCP client, such as a chat assistant, an IDE, or your own agent, can discover and use it.

A common analogy is a USB port for AI: one shape of plug, many devices. For engineers building agents, MCP has become a core skill because it is how agents reach the systems where real work happens: databases, ticketing tools, code repositories, internal APIs.

πŸ“ŒThe Building Blocks

  • Host: the AI application the user interacts with.
  • Client: the component inside the host that holds a connection to one MCP server.
  • Server: a program that exposes capabilities from a system, for example your orders database or your Jira instance.
  • A server can expose three kinds of capability:

  • Tools: actions the model can call, with a name, a description and a JSON schema for the inputs. For example get_order(order_id) or create_ticket(title, priority).
  • Resources: read-only data the application can load into context, such as files, records or documentation pages.
  • Prompts: reusable prompt templates the server offers to users of the host.
  • πŸ“ŒTransports

    MCP messages are JSON-RPC. Two transports are common:

  • stdio: the host starts the server as a local process and talks over standard input and output. Simple and good for local tools.
  • HTTP (streamable HTTP): the server runs as a web service, which is what you use for shared, remote or multi-user deployments, usually with OAuth for authentication.
  • πŸ“ŒHow a Tool Call Flows

  • 1The client connects and asks the server which tools it offers.
  • 2The host passes those tool definitions to the model along with the user request.
  • 3The model decides to call a tool and produces the arguments.
  • 4The client sends the call to the server, which runs it and returns the result.
  • 5The result goes back to the model, which continues the task or answers.
  • The model never talks to your systems directly. Your server decides what is possible, which is exactly where you enforce safety.

    πŸ“ŒBuilding a Small MCP Server in Python

    The official Python SDK keeps a basic server short:

    from mcp.server.fastmcp import FastMCP
    mcp = FastMCP("orders")
    @mcp.tool()
    def get_order(order_id: str) -> dict:
    """Fetch an order's status, items and delivery date by its ID."""
    return orders_db.fetch(order_id)
    @mcp.tool()
    def request_refund(order_id: str, reason: str) -> str:
    """Create a refund request. A human must approve it before money moves."""
    return refunds.create_pending(order_id, reason)
    if __name__ == "__main__":
    mcp.run()

    The function names, type hints and docstrings become the tool schema the model sees, so write them as carefully as you would write an API for another team.

    πŸ“ŒDesigning Good MCP Tools

  • Few, clear tools beat many overlapping ones. The model chooses better from a short list.
  • Descriptions are prompts. Say what the tool does, when to use it and what it returns.
  • Validate every input on the server, even though the model produced it.
  • Return compact, structured results, not huge raw dumps that waste context.
  • Make write actions safe: create pending requests, require approval for risky steps, and make operations idempotent so retries do not double-charge anyone.
  • πŸ“ŒSecurity Rules You Cannot Skip

  • Least privilege: give each server only the permissions its tools need.
  • Authenticate remote servers and scope tokens per user.
  • Treat tool output as untrusted input. A web page or document returned by a tool can contain instructions meant to hijack the agent, which is called prompt injection. Never let tool output grant new permissions.
  • Human approval for anything that moves money, deletes data or contacts customers.
  • Log every call with inputs, outputs and the user it ran for.
  • Only install servers you trust, and review what third-party servers can access.
  • πŸ“ŒMCP vs Function Calling

    Function calling is the model API feature that lets a model request a call to a function you defined in your own code. MCP standardises how those tools are packaged, discovered and served, so they can be reused across many AI applications. Inside one application you can use plain function calling; once tools need to be shared across assistants, IDEs and agents, MCP saves you from rewriting integrations.

    πŸ“ŒWhere MCP Fits in Agentic AI

    In an agent, MCP servers are the hands. The agent framework, such as LangGraph or the OpenAI Agents SDK, handles planning, state and orchestration, and calls MCP tools to act. See how the frameworks compare in AI agent frameworks compared, and the full learning path in the Agentic AI roadmap.

    πŸ“ŒFrequently Asked Questions

    Is MCP only for Claude?

    No. MCP is an open protocol with SDKs in several languages, and it is supported by a wide range of AI applications, IDEs and agent frameworks across model providers.

    Do I need MCP to build an AI agent?

    No. A single agent can use direct function calling. MCP becomes valuable when the same tools should be reusable across several AI applications or teams, or when you want to plug into existing MCP servers instead of writing integrations.

    What is a good MCP project for a portfolio?

    An MCP server for a real API, for example a GitHub, database or ticketing integration, with two to four well-designed tools, input validation, an approval step for write actions, logging and a short demo of an agent using it.

    Which language should I use for an MCP server?

    Python and TypeScript have the most mature SDKs and examples. Java, C# and other languages also have SDKs, so backend teams can build servers in the language their services already use.

    πŸ“ŒLearn It Live

    You build and secure MCP servers, and connect agents to them, in Prakalpana's Agentic AI course, taught live online with an optional 1-on-1 track. WhatsApp or call +91 9180377502 for a free consultation.

    RM

    Written by

    Rahul Menon

    GenAI Engineer

    πŸš€ Master AI & ML

    Live online + 1-on-1 Agentic AI training Β· Join 5000+ developers

    Not sure what to do? Book career counselling (β‚Ή200 / 30 min)

    Not sure what to learn next?

    A 1-on-1 session with an industry mentor and a roadmap built for you. How it works

    1. 1Discuss your goals
    2. 2Get a personal plan
    3. 3Start learning
    Book for β‚Ή200/ 30 min