Getting Started with MCP and Agent Development: From Function Calling to A2A in Practice

Starting from the five-step Function Calling mechanism, clarifying the technological evolution from Agent to MCP to A2A.
Based on an AI development tutorial from Bilibili, this article outlines the technological evolution from Function Calling to Agent, MCP, and A2A. It explains that MCP is essentially a protocol-based standardization of tool calling, with Function Calling as its underlying mechanism. The five-step Function Calling process is broken down—defining functions, model reasoning, generating calling instructions, executing functions, and returning results—with a weather query Python demo. The article distinguishes Function Calling from agents (which have planning and memory), noting that hand-writing Function Calling code is valuable for understanding the underlying chain, while MCP and A2A sit at the upper layers.
MCP, Agent, and A2A are concepts that get brought up repeatedly in AI development circles, but many beginners struggle to understand the underlying relationships between them. There's a tutorial series on Bilibili labeled as the "most complete and detailed," which walks through everything from Function Calling all the way to MCP and Agent to Agent, attempting to explain this chain of technological evolution thoroughly. This article is based on the core content of that tutorial, outlining the key threads from function calling to agent protocols.
Function Calling: The Foundation of Everything
To understand MCP, you must first go back to Function Calling. The tutorial clearly states that MCP is essentially an optimization of tool calling—or rather, a set of protocols built on top of tool calling that everyone agrees on. And the underlying mechanism of tool calling is precisely Function Calling.
Function Calling was pushed forward by companies like OpenAI, with OpenAI leading the charge from the start. It allows large models to connect with external tools, converting natural language into API calls, thereby solving the problem of knowledge stagnation after a model finishes training—once training is complete, the model can gain additional capabilities and data by calling external or internal functions.
According to the tutorial, virtually all general-purpose large models currently support Function Calling, including Gemini and Claude internationally. DeepSeekAd R1 does not support it, but DeepSeek V3 does. Qwen and Zip also have some cases of non-support, but mainstream models are largely covered.

The Five-Step Workflow
The tutorial breaks down the working principle of Function Calling into five steps:
- Define the function: Describe the function name, comments, parameters, and their types
- Model reasoning: Have the model determine whether the function needs to be called
- Generate Function Call: When the model decides to call, it generates the calling instruction and prepares the parameters
- Execute the function: The developer actually executes based on the model's output
- Return the result: Send the execution result back to the large model, which generates the final answer
This workflow is walked through completely in the tutorial's code demonstration, using weather queries as an example—the large model itself cannot obtain real-time weather and must rely on external functions to fill the gap.
JSON Schema is the standard format for describing function parameter structures. In Function Calling, developers need to use JSON Schema to define each parameter's name, type (string, number, boolean, object, array, etc.), whether it's required, and description information. The model uses this schema to determine whether a user request can be mapped to a function and to generate structurally valid parameters. The clearer the schema, the lower the probability of model misjudgment and parameter hallucination. In OpenAI's tools parameter, each function object contains three fields: name, description, and parameters, where parameters is a JSON Schema object. Understanding this is essential for understanding why MCP later standardizes tool descriptions—essentially unifying the schema conventions scattered across various APIs.
tool_choice is a key parameter that controls whether and how the model calls tools. Common values include auto, none, and required (some vendors also support specifying a particular function name). When set to auto, the model decides based on the conversation content whether tools need to be called; when set to none, it's forced not to call and only generates text; when set to required, it's forced to call at least one tool. The tutorial uses auto to demonstrate the typical scenario of autonomous model decision-making. Alongside this is the parallel tool calls capability: some models can return multiple tool_calls in a single response, allowing developers to execute multiple functions in parallel—this can significantly reduce latency in scenarios requiring simultaneous queries to multiple data sources.
Key Differences Between Function Calling and Agents
Many people conflate Function Calling with agents, and the tutorial specifically distinguishes them. When making decisions, an agent must not only judge whether to call a function but also generate a plan—determining whether to call function one or function two first, and then which other functions to call. The model reasoning in Function Calling only decides "whether to call this function"; it has no planning capability and doesn't consider whether other functions need to be called afterward.
Another difference is memory. The tutorial emphasizes that all Function Calling has no memory by default unless memory functionality is explicitly added. Agents, on the other hand, have a more complete decision-making and memory mechanism.

Walking Through the Complete Call Chain with Code
The tutorial uses OpenAI's API to build a Python project for demonstration. The core steps include:
Step one, define the function. The tutorial defines a getWeather function that accepts a location parameter, with comments indicating it's a simulated weather query function that would be replaced with a real implementation in actual projects.
Step two, model reasoning. Initiate a chat completions request through the OpenAI client, passing in the model (the tutorial uses GPT-4-mini, considering it relatively cheap), the user message array, and the tools parameter. In tools, the function is described as a JSON-format object containing the function name, description, and parameter definitions—there's only one parameter, location, of type string, described as a city name like Beijing or Shanghai, with require indicating it's mandatory.
The tool_choice parameter is set to auto, letting the large model decide on its own whether to call.
Step three, parse the calling instruction. In the response returned by the model, tool_calls is the instruction to call the function. The tutorial demonstrates the process of extracting the function name and parameters from response.choices[0].message.tool_calls—the parameters are JSON strings that need to be converted with json.loads.

Step four, execute the function. Judge based on the extracted function name, and after matching, actually call getWeather, passing in location to get the result.
Step five, return the result. Pass the function execution result along with the tool call information back to the large model, which generates the final answer. The output from running the tutorial is complete information about today's sunny weather in Beijing, temperature, and wind speed.

Is It Still Necessary to Hand-Write Calling Code?
The tutorial is clear-eyed about the positioning of this code: it's only meant to simulate how real function calls actually happen. The tutorial openly admits that this approach won't appear in actual development anymore—maybe someone would have written it this way in 2013, but writing code like this in 2025 is unrealistic. At the very least, you should write an Agent.
This judgment is worth taking seriously. The value of hand-writing Function Calling code lies in understanding the underlying five-step chain, not in serving as engineering practice. Only by understanding the closed loop—where model reasoning produces calling instructions, parameters are generated by the model, developers handle execution, and results are sent back—can you understand what upper-layer frameworks actually encapsulate.
Where MCP and A2A Fit In
The tutorial makes it clear from the start: MCP builds protocol-level specifications on top of tool calling, giving all parties a commonly accepted standard for tool calling. A2A stands for Agent to Agent, pointing toward collaboration between agents. From Function Calling to Agent, then to MCP and A2A, the logic of this chain is consistent: the underlying capability is function calling, the middle layer is agents with planning and memory, and the upper layer is standardized protocols and multi-agent collaboration.
For developers who want to build their own agents, thoroughly understanding the five-step mechanism of Function Calling and then understanding the decision-making and memory differences of Agents is an unavoidable foundation. As for specific framework selection and hands-on building, the tutorial indicates it will be covered in subsequent content.
MCP (Model Context Protocol) was proposed and open-sourced by Anthropic at the end of 2024, using a client-server architecture: MCP Server exposes tools, resources, and prompt templates in a standardized way, while MCP Client (usually an AI application or Agent runtime) is responsible for discovering and calling these capabilities. It solves the fragmentation problem of tool integration—before MCP, every external service integration required writing a set of adapter code for a specific framework; with MCP, the same Server can be reused by different models and different clients. A2A (Agent to Agent) focuses on a higher level of interoperability: how agents built by different vendors and different frameworks can discover each other's capabilities, delegate tasks, and exchange results. The two have different positioning—MCP standardizes "how models/Agents use tools," while A2A standardizes "how Agents collaborate with each other"—and they are often used in combination.
One-line Summary
Starting from the five-step Function Calling mechanism, clarifying the technological evolution from Agent to MCP to A2A layer by layer.
Paragraph Summary
Based on an AI development tutorial from Bilibili, this article outlines the technological evolution chain from Function Calling to Agent, MCP, and A2A. It first points out that MCP is essentially a protocol-based standardization of tool calling, and that the underlying mechanism of tool calling is Function Calling. It then breaks down the five-step Function Calling process: defining functions, model reasoning, generating calling instructions, executing functions, and returning results, with a complete Python demonstration using weather queries. The article specifically distinguishes Function Calling from agents: agents have planning capabilities and memory mechanisms, while pure function calling only decides whether to call a particular function. Finally, it offers a judgment: the value of hand-writing Function Calling code lies in understanding the underlying chain, while engineering practice should be handled by Agent frameworks, with MCP and A2A sitting at the upper layers of this chain.
Related articles

Google Admits Custom Agents Consume 4x Quota, HuggingFace Malicious GGUF Exposed
Google admits Anti-Gravity CLI custom agent parameters cause 4x quota consumption, HuggingFace exposes 5 malicious GGUF models, Claude Code blind tests show 62% more steps, and three major service deadlines converge on November 30.

Khosla Ventures Plans to Raise Over $6 Billion Across Three New Funds
Khosla Ventures files with the SEC to launch three new funds targeting over $6 billion. We break down the fundraising context, investment strategy, and potential impact on the AI startup ecosystem.

Whoop Band Adds Automatic Strength Training Detection: First Feature Rollout After Motra Acquisition
Whoop fitness band adds automatic strength training exercise detection, driven by the Motra acquisition and rolling out in February. This article analyzes the feature's technical background, its significance for training data completeness, and industry impact.