From Prompt to MCP: How LLM Application Architecture Evolves
This article explains five layers of large language model application architecture—Prompt, Function Call, Agent, Skill, and MCP—and how they work together. It walks through each concept with Java-style pseudocode showing where it fits in real engineering.
As AI technology moves quickly, developers building large language model applications often run into a confusing set of terms: Prompt, Function Call, Agent, Skill, and MCP. These ideas can look like they sit at the same level, but they actually describe different layers of capability and different stages of architectural evolution. This article breaks them down one by one, clarifies their boundaries and how they collaborate, and uses Java-style pseudocode to show where each one lands in real engineering.
1. Prompt: Translating Human Intent
A prompt is the text instruction a developer or user sends to a large language model. It is the most basic medium between human intent and model capability. If a large model is a library with a vast store of knowledge, a prompt is the map that tells the librarian which floor to visit and which book to find.
In practice, a prompt is rarely a single simple question. Modern LLM applications usually split prompts into a system prompt and a user prompt. The system prompt sets the model’s role, behavioral rules, and global context. The user prompt carries the specific task.
In Java, a structured prompt often looks like this:
public class PromptService {private final ModelClient modelClient;public PromptService(ModelClient modelClient) {this.modelClient = modelClient;}public String generateCode(String requirement) {// Define a system-level prompt that shapes the model's professional roleString systemPrompt = "You are a senior Java architect who explains technical concepts with rigorous engineering thinking and generates high-quality code.";// Define a user-level prompt that injects concrete context and requirementsString userPrompt = String.format("""Generate Java code for the following requirement. Include necessary comments and consider exception handling:Requirement: %sOutput a complete Java class.""", requirement);// Assemble the full prompt and call the modelPrompt prompt = new Prompt(systemPrompt, userPrompt);return modelClient.call(prompt).getContent();}}
The essence of a prompt is intent alignment. As prompt engineering has matured, developers have introduced techniques such as few-shot prompting and chain-of-thought prompting to further draw out the model’s reasoning ability.
2. Function Call: Giving the Model the Ability to Act
If a model only generates text from prompts, it stays trapped in language and cannot interact with the physical world or internal enterprise systems. Function Call breaks that limit by letting the model invoke external APIs or local functions.
When a user needs real-time data or a concrete action, the model uses predefined function descriptions to extract key parameters from the user’s intent and produce a function-call request that follows a JSON Schema. The developer receives that request, runs the real code locally, and returns the result to the model for the next summary.
public class FunctionCallExample {// 1. Define a function specification the model can callprivate FunctionDefinition weatherFunction = new FunctionDefinition("get_current_weather","Get real-time weather data for a specified city",Map.of("type", "object","properties", Map.of("location", Map.of("type", "string", "description", "City name")),"required", List.of("location")));public String handleUserQuery(String userInput) {// 2. Send the function specification together with the prompt to the modelModelResponse response = modelClient.callWithTools(userInput, List.of(weatherFunction));// 3. Check whether the model decided to call a functionif (response.hasToolCall()) {ToolCall call = response.getToolCall();String location = call.getArgument("location");// 4. Execute the real business logic locallyString weatherData = externalWeatherApi.query(location);// 5. Feed the result back to the model to produce a natural-language replyreturn modelClient.callWithToolResult(userInput, call.getId(), weatherData).getContent();}return response.getContent();}}
Function Call is the key step from “talk only” to “know and act.” It turns language ability into the ability to take action.
3. Agent: A System with a Think-and-Plan Loop
If Function Call gives the model limbs, an Agent gives it a brain. An Agent is not a single model call. It is a closed loop that can think, plan, act, and reflect toward a goal.
The core loop is usually perceive, think, and act. Given a complex task, the Agent breaks it into subtasks, reasons with prompts, executes those subtasks through Function Call, and reflects on the results to decide whether to continue or correct an error.
public class TaskAgent {private final ModelClient modelClient;private final ToolRegistry toolRegistry;private final MemoryStore memoryStore;public void executeTask(String goal) {int maxIterations = 10;int currentIteration = 0;String currentThought = goal;while (currentIteration < maxIterations && !isTaskComplete(currentThought)) {// 1. Think and plan: decide what to do nextAgentPlan plan = modelClient.planNextStep(goal, memoryStore.getContext(), toolRegistry.getAvailableTools());// 2. Act: execute a tool through Function Callif (plan.requiresToolExecution()) {String toolResult = toolRegistry.execute(plan.getToolName(), plan.getArguments());memoryStore.addObservation(toolResult);} else {memoryStore.addObservation(plan.getDirectResponse());}// 3. Update state and reflectcurrentThought = modelClient.evaluateProgress(goal, memoryStore.getContext());currentIteration++;}}}
An Agent architecture lets AI handle multi-step, changing business work. It is a core form of enterprise AI applications today.
4. Skill: A Professional Certificate for the Model
As an Agent needs more tools, handing it a large pile of loose functions can overflow the context window and reduce how accurately the model picks a tool. Skill addresses that problem.
A Skill is a higher-level wrapper around Function Call and prompt workflows. It is similar to a professional certificate: it means the model has a mature ability to solve a class of problems. For example, a “database SQL query skill” may internally wrap table-schema analysis, SQL generation, SQL execution, and result parsing as several lower-level function calls. From the Agent’s point of view, it only needs to know when to invoke that Skill.
In Java, Skills are often managed through a registry:
public class SkillRegistry {private final Map<String, Skill> skills = new ConcurrentHashMap<>();public void registerSkill(Skill skill) {skills.put(skill.getName(), skill);}public List<SkillDescription> getSkillDescriptionsForModel() {// Expose concise skill descriptions rather than a messy set of underlying functionsreturn skills.values().stream().map(Skill::getDescription).collect(Collectors.toList());}public String executeSkill(String skillName, Map<String, Object> params) {Skill skill = skills.get(skillName);if (skill != null) {return skill.execute(params); // The skill internally orchestrates multiple function calls}throw new SkillNotFoundException(skillName);}}
With Skills, developers can build modular, reusable AI capability libraries and sharply reduce both the Agent’s reasoning load and the cost of maintaining the system.
5. MCP: A USB Port for the AI World
As Agent and Skill ecosystems grow, a new pain point appears: every new data source or tool requires custom adapter code, and tool providers stay tightly coupled to AI applications. MCP (Model Context Protocol) exists to standardize that connection.
MCP can be understood as a USB port for the AI world. Before MCP, tools and data sources were like chargers of different shapes: each new device needed a matching connector. MCP defines a standard protocol so any context provider that follows it—object storage, an enterprise knowledge base, a logging system, and so on—can plug into any AI client that supports the protocol.
Technically, MCP usually uses a client-server architecture:
public class MCPClientManager {private final List<MCPConnection> connections = new ArrayList<>();// Dynamically connect to an external data source or tool service that follows MCPpublic void connectToDataSource(String mcpServerEndpoint) {MCPConnection connection = new MCPConnection(mcpServerEndpoint);connection.initialize(); // Handshake and capability negotiationconnections.add(connection);}// Provide the Agent with a unified context query interfacepublic List<ToolResource> getUnifiedResources() {return connections.stream().flatMap(conn -> conn.listResources().stream()).collect(Collectors.toList());}// Standardized resource or tool invocationpublic String invokeMCPResource(String resourceId, Map<String, Object> params) {MCPConnection targetConn = findConnectionByResource(resourceId);return targetConn.readResource(resourceId, params);}}
MCP decouples the model from external systems. It lets an organization turn internal systems into context the model can use at a much lower cost, and it is key infrastructure for large, cross-system networks of AI agents.
Conclusion
From Prompt to Function Call, then to Agent, Skill, and finally MCP, these five concepts are not isolated. Together they form a full ladder in the evolution of large language model applications. Prompt defines how people and models communicate. Function Call gives the model the ability to execute. Agent builds a closed loop for autonomous planning. Skill makes capabilities reusable and efficient. MCP standardizes how the AI ecosystem connects. Understanding this path helps developers make sounder architecture and technology choices when building complex AI applications.
