AI Agent Development in Practice: From Workflows to MCP Integration

    This article outlines an engineering approach to building AI agents, moving beyond single-turn model calls toward observable, replayable workflows. It covers the four core layers of agent architecture, environment setup and visual orchestration, model integration across five application types, prompt design, node extension with knowledge bases and external communication, and capability expansion through the Model Context Protocol (MCP). It also summarizes common success factors across four industry scenarios and explains how to move agents into production with versioning, canary releases, and observability.

    1. Why an Engineering Approach to Agent Development Matters

    Large language models have solved the problem of “understanding and generation,” but what enterprises actually need is deliverable business capability. Single-turn conversational calls often fail to meet requirements around process constraints, data freshness, and permission boundaries. As a result, the industry has largely shifted toward workflow-centric agent construction: breaking complex tasks into observable, replayable sequences of nodes, letting the model handle only the reasoning and expression it is good at, and leaving everything else to deterministic logic.

    A mature agent typically consists of four core layers:

    • Interaction layer: handles multi-channel access, session state, and context management;
    • Orchestration layer: organizes nodes as a directed graph, supporting conditional branching, loops, and parallelism;
    • Capability layer: wraps model calls, retrieval, tool invocation, and communication with external systems;
    • Governance layer: covers log tracing, evaluation, permissions, and cost control.

    Understanding this layering is the foundation for all the practices that follow. A common mistake among developers is stuffing all logic into prompts, which makes behavior uncontrollable and problems hard to locate. The value of an engineering approach lies in confining uncertainty to the smallest possible scope.

    2. Environment Setup and Getting Started with Visual Orchestration

    Deploying a visual agent platform locally or in a private environment is a low-cost starting point for learning and validation. Before deployment, plan three types of resources: application services, a relational database, and vector retrieval capability. If you are processing large volumes of documents, also prepare object storage for retaining the original files.

    The first exercise after deployment should not be a conversational application. Instead, build a minimal workflow first: a start node receives input → a model node performs structured extraction → an end node outputs the result. This smallest closed loop helps you understand how variables are passed between nodes, which is the basis for all subsequent complex orchestration.

    On platform selection, several categories of solutions exist. One category emphasizes integrated visual orchestration and knowledge bases, making it suitable for fast validation on the business side. Another is code-first and built for deep customization, making it suitable for complex integration by engineering teams. The two are not mutually exclusive; in practice, teams often use visual orchestration as the backbone and custom code nodes to fill the gaps.

    3. Model Integration and Five Application Types

    When integrating different models, focus on four general capabilities: context length, stability of structured output, degree of function-calling support, and whether multimodal input is available. It is advisable to build a model adaptation abstraction in the orchestration layer, confining vendor differences to configuration so that models can be swapped or gradually rolled out later.

    The five common application types each have their own boundaries:

    1. Chat assistant: multi-turn context plus a system prompt, suitable for consultation and companion scenarios;
    2. Text generator: one-shot input and output, suitable for marketing copy, summarization, and rewriting;
    3. Agent: capable of tool selection and autonomous planning, suitable for cross-system operations;
    4. Workflow application: deterministic and auditable processes, suitable for approvals, risk control, and data processing;
    5. Text embedding and retrieval: provides the vector foundation for knowledge bases and semantic search.

    The selection principle is simple: the higher the requirement for process determinism, the more you should lean toward workflows; only when a task is highly open-ended should you hand decision-making to an autonomous agent.

    4. Prompt Design and Style Optimization

    Prompt engineering is not about “writing more,” but about “constraining more precisely.” A reusable four-part structure looks like this:

    1. [Role] You are an e-commerce after-sales review assistant. Answer based on the clauses in the knowledge base.
    2. [Input] Order status: {{order_status}}; user request: {{query}}
    3. [Constraints] Use only the retrieved clauses; if there is no basis, reply "manual review required."
    4. [Output] JSON: {"decision":"","reason":"","clause_id":""}

    Optimization techniques include: using few-shot examples to anchor the output format; splitting long prompts into a system prompt and a task prompt; applying schema validation to key fields and retrying automatically on failure; and maintaining a fixed evaluation set to run regression comparisons after every change, avoiding “tuning by feel.”

    5. Node Extension, Knowledge Bases, and External Communication

    When built-in nodes are insufficient, custom code nodes can handle deterministic tasks such as format conversion, signature computation, and data cleaning, freeing the model from arithmetic and assembly. For the knowledge base stage, pay attention to chunking strategy and metadata design: split by semantic paragraphs, retain source and version fields, and at retrieval time first perform hybrid keyword and vector recall, then let the model rerank and summarize. This can significantly reduce hallucinations.

    Three patterns are recommended for communicating with external systems: request-response API calls, asynchronous decoupling via message queues, and event subscription callbacks. Engineering practice must enforce timeouts, retries, idempotency keys, and rate limiting to avoid amplifying downstream pressure under high concurrency.

    6. Capability Expansion with the MCP Protocol

    The value of the Model Context Protocol (MCP) is that it unifies the interaction paradigm among models, tools, and data sources: the server declares available tools and resources in a standard way, and the client discovers and invokes them on demand. This means the same agent no longer needs a separate adapter written for every system; capabilities expand horizontally as plugins. In practice, it is advisable to split services by domain, declare least-privilege permissions for tools, and log every invocation for auditing.

    7. Common Success Factors Across Four Industry Cases

    Looking at four scenarios—e-commerce intelligent customer service, an office collaboration assistant, enterprise internal knowledge Q&A, and production operations inspection—the success factors are highly consistent: make process determinism solid before introducing the model; build an evaluation set before pursuing quality improvements; run a small-scale canary before a full release. The release stage requires attention to version management, canary ratio, rollback plans, and invocation quotas. If running on a container platform, you can combine log services with monitoring and alerting to establish a closed observability loop.

    8. Conclusion

    The core competitiveness of agent development lies not in how many models you call, but in whether you can reliably orchestrate business rules, data, and tools into a maintainable system. Mastering these five capabilities—visual orchestration, prompt engineering, knowledge base retrieval, external communication, and protocol-based extension—covers the vast majority of enterprise requirements and enables a smooth path to production with the general capabilities offered by cloud platforms such as Baidu AI Cloud.