Skip to content
PHP2Shell: The PHP Bug
Akshay Thakare

Model Context Protocol (MCP) Explained

A standard way to connect AI assistants to tools and data — servers, clients, tools, resources and prompts.

AI ToolsIntermediate3 min readUpdated 11 Oct 2026

The integration problem

Every assistant needs access to databases, file systems, ticketing tools and APIs. Without a standard, each pairing of assistant and tool needs custom glue code.

MCP defines one protocol: tools are exposed by MCP servers, and any MCP client (an AI app or agent) can discover and call them.

MCP request path
Userasks a question
MCP clientAI application
MCP serverexposes tools
Toolquery / API call
Resultback to the model

What a server can expose

PrimitiveWhat it isExample
ToolsFunctions the model may callrun_readonly_sql(query)
ResourcesData the client can read into contextA table schema, a file
PromptsReusable prompt templates"Explain this query plan"

How a tool call flows

  1. 1

    Discover

    On connect, the client asks the server which tools it offers, with names, descriptions and JSON schemas.
  2. 2

    Decide

    The model sees the tool list and chooses to call one with arguments.
  3. 3

    Execute

    The client sends the call to the server, which runs it with its own credentials and permissions.
  4. 4

    Return

    The result goes back to the model, which continues the task or answers.
Python.py
# a tiny MCP server exposing one read-only tool (Python SDK)
from mcp.server.fastmcp import FastMCP
 
mcp = FastMCP("warehouse")
 
@mcp.tool()
def row_count(table: str) -> int:
    """Return the number of rows in an allow-listed analytics table."""
    if table not in {"fact_sales", "dim_customer"}:
        raise ValueError("table not allowed")
    return query_scalar(f"SELECT COUNT(*) FROM {table}")
 
if __name__ == "__main__":
    mcp.run()

Finished this note?

Share