AI Agent on 2026

How to Build an AI Agent in 2026: MCP + Python Tutorial

Developer guide · Updated 7 September 2026

How to Build an AI Customer Support Agent in 2026: MCP, Python, Node.js and Monetisation

The most commercially useful AI agent is rarely a general-purpose “do everything” bot. It is a narrowly scoped system that can read trusted business data, call a small set of tools, complete a measurable job and hand risky actions to a human. This guide builds exactly that: an AI customer support agent you can turn into a vertical SaaS product.

Why this topic now: Ahrefs reported that US monthly searches for agentic AI rose from 1,450 in May 2023 to 122,175 in May 2026, while what is agentic AI reached roughly 14,000 monthly searches. OpenAI, Anthropic and the Model Context Protocol ecosystem are simultaneously converging on the same core pattern: a model, tools, an execution loop, guardrails and observable state.

Why agentic AI is a 2026 developer trend

An agent is not simply a chatbot with a longer system prompt. OpenAI defines agents as systems that independently accomplish tasks on a user’s behalf: the model manages workflow execution, chooses tools, observes results and decides when the task is complete. Anthropic makes a useful distinction between workflows, where code determines a fixed path, and agents, where the model dynamically directs its own tool use. Both organisations recommend starting with the simplest architecture that can solve the job rather than jumping immediately to a multi-agent system.

That matters commercially. A developer can now sell an outcome instead of selling another text box. In customer support, the outcome can be defined clearly: answer from approved knowledge, look up an order, create a return or refund request, or escalate the ticket with context. Intercom’s current Fin pricing provides a real market benchmark for this model: it starts at US$0.99 per AI outcome. That does not mean a new product should copy the price; it shows that outcome-based billing is already understandable to buyers.

MCP is the second reason this category is worth learning. The Model Context Protocol’s current tools specification lets servers expose schema-described tools that language models can discover and invoke. This creates a standard boundary between the reasoning layer and systems such as CRMs, databases, order systems and ticketing software. The protocol also explicitly recommends human confirmation for sensitive operations and requires server-side input validation, access control, rate limiting and output sanitisation.

The 2026 AI agent stack User / API Agent loop decide → act → observe LLM Tools / MCP orders · CRM · tickets Guardrails permissions · approvals Traces + evals quality · cost · latency Design rule: keep the model flexible, but make permissions and irreversible actions deterministic.
Original illustration: a production agent is a controlled software system, not a free-running prompt.

What to build: a support agent with one measurable job

For a first paid agent, choose a task with three properties: the input is messy enough that rigid rules are painful; the agent has authoritative data it can consult; and success is measurable. Customer support fits those constraints unusually well. Anthropic specifically identifies customer support as a promising agent application because it combines conversation, tool access and actions while still allowing clear success metrics and human escalation.

Read

Search approved help content and retrieve customer/order context.

Act

Perform reversible or low-risk tool calls such as order lookup and creating a request.

Escalate

Send ambiguous, costly or policy-sensitive cases to a human with a structured summary.

Do not start by giving the agent the ability to issue money, delete customer data or send unrestricted external messages. Build a “request” tool first. For example, let the agent create a refund request; let deterministic business logic or a human approve the actual refund. This shrinks the blast radius while you gather real traces and eval data.

Production-minded architecture

The recommended first version is a single agent with a deliberately small tool set. OpenAI’s practical guide recommends maximising one agent before adding multi-agent orchestration because extra agents increase complexity and overhead. Use a stronger model to establish your quality baseline, then route simpler work to cheaper models after you have evals.

flowchart LR
    U[Customer] --> API[FastAPI / Express]
    API --> A[Support Agent Loop]

    A --> M[LLM]
    A --> K[Knowledge Retrieval]
    A --> T[Tools / MCP]

    T --> O[(Order System)]
    T --> CRM[(CRM)]
    T --> H[(Helpdesk)]

    A --> G{Sensitive action?}

    G -- yes --> P[Human approval]
    G -- no --> R[Return answer / action]

    P --> R

    A --> E[Tracing + evals + cost logs]

Mermaid source: paste this block into any Mermaid-enabled editor. A static illustration is included above so the article does not depend on JavaScript.

Agent execution flow Ticket Retrieve facts Choose tool High risk? Human approval Answer + log outcome yes no
Original flowchart: evidence first, tool selection second, risk gate before any sensitive action.

Recommended stack

Layer Pragmatic choice Why
Agent runtime OpenAI Agents SDK or a small custom loop Current Python and JavaScript SDKs support agents, function tools, handoffs and tracing.
Model Start with a high-quality baseline; optimise later As of 7 Sep 2026, OpenAI recommends GPT-6 Astra for the hardest work, GPT-5.6 Terra for intelligence/cost balance and GPT-5.6 Luna for cost-sensitive high-volume tasks.
Tool boundary MCP where integrations benefit from reuse MCP standardises tool discovery and schema-described invocation across model clients.
State PostgreSQL Store tenant, conversation, approval, billing and audit records outside the model context.
Knowledge Your approved docs + retrieval Answers should be grounded in sources your customer controls.
Observability Built-in traces, LangSmith or equivalent Inspect model calls, tool calls, latency, failure modes and cost before tuning prompts.
Deployment Container + managed DB Keeps the runtime portable; scale only after measuring actual load.

Step-by-step Python tutorial

This runnable example uses the current OpenAI Agents SDK. It intentionally uses in-memory data so you can understand the security boundary: the agent can look up an order and create a refund request, but it cannot directly move money.

Install and configure

python -m venv .venv
source .venv/bin/activate   # Windows: .venv\Scripts\activate

pip install openai-agents

export OPENAI_API_KEY="YOUR_KEY"

# Optional: choose another currently available model
export OPENAI_MODEL="gpt-5.6-terra"

Create support_agent.py

import asyncio
import json
import os

from typing import Any

from agents import Agent, Runner, function_tool


ORDERS: dict[str, dict[str, Any]] = {
    "ord_1001": {
        "customer": "Ava",
        "status": "shipped",
        "tracking": "TRACK-8842",
        "total_usd": 79.00,
    },
    "ord_1002": {
        "customer": "Noah",
        "status": "delivered",
        "tracking": "TRACK-9910",
        "total_usd": 42.50,
    },
}


REFUND_REQUESTS: list[dict[str, str]] = []


@function_tool
def lookup_order(order_id: str) -> str:
    """Return trusted order data for one order ID."""

    order = ORDERS.get(order_id)

    if not order:
        return json.dumps({
            "ok": False,
            "error": "order_not_found"
        })

    return json.dumps({
        "ok": True,
        "order_id": order_id,
        **order
    })


@function_tool
def create_refund_request(
    order_id: str,
    reason: str
) -> str:
    """
    Create a refund request for human review.

    This does NOT issue money.
    """

    if order_id not in ORDERS:
        return json.dumps({
            "ok": False,
            "error": "order_not_found"
        })

    request_id = (
        f"rr_{len(REFUND_REQUESTS) + 1:04d}"
    )

    REFUND_REQUESTS.append({
        "request_id": request_id,
        "order_id": order_id,
        "reason": reason
    })

    return json.dumps({
        "ok": True,
        "request_id": request_id,
        "status": "pending_human_review"
    })


support_agent = Agent(
    name="Store support agent",

    model=os.getenv(
        "OPENAI_MODEL",
        "gpt-5.6-terra"
    ),

    instructions=(
        "You are a customer support agent. "

        "Use tools instead of inventing order facts. "

        "Never claim that a refund was issued; "
        "the available tool only creates a request "
        "for human review. "

        "If required data is missing, "
        "ask one concise question. "

        "If the customer requests an irreversible, "
        "financial, legal, or privacy-sensitive action "
        "you cannot safely perform, escalate."
    ),

    tools=[
        lookup_order,
        create_refund_request
    ]
)


async def main() -> None:
    prompt = (
        "Customer says: My order ord_1002 "
        "arrived damaged. Can I get a refund?"
    )

    result = await Runner.run(
        support_agent,
        prompt
    )

    print(result.final_output)

    print(
        "Refund requests:",
        REFUND_REQUESTS
    )


if __name__ == "__main__":
    asyncio.run(main())

Run it

python support_agent.py

The important engineering pattern is not the exact prompt. It is the permissions design. The model can decide when to call create_refund_request, while the function itself decides what action is actually possible. That separation lets you add tenant checks, monetary limits, idempotency keys, rate limits and approval workflows in ordinary deterministic code.

The same agent in Node.js

OpenAI’s current JavaScript quickstart uses @openai/agents with Zod schemas for function tools. Save the following as support-agent.mjs.

npm init -y

npm install @openai/agents zod

export OPENAI_API_KEY="YOUR_KEY"

export OPENAI_MODEL="gpt-5.6-terra"
import {
  Agent,
  run,
  tool
} from "@openai/agents";

import { z } from "zod";


const orders = new Map([
  [
    "ord_1001",
    {
      customer: "Ava",
      status: "shipped",
      tracking: "TRACK-8842",
      total_usd: 79.00
    }
  ],

  [
    "ord_1002",
    {
      customer: "Noah",
      status: "delivered",
      tracking: "TRACK-9910",
      total_usd: 42.50
    }
  ]
]);


const refundRequests = [];


const lookupOrder = tool({
  name: "lookup_order",

  description:
    "Return trusted order data for one order ID.",

  parameters: z.object({
    order_id: z.string().min(1)
  }),

  async execute({ order_id }) {
    const order = orders.get(order_id);

    return JSON.stringify(
      order
        ? {
            ok: true,
            order_id,
            ...order
          }
        : {
            ok: false,
            error: "order_not_found"
          }
    );
  }
});


const createRefundRequest = tool({
  name: "create_refund_request",

  description:
    "Create a refund request for human review. " +
    "This does NOT issue money.",

  parameters: z.object({
    order_id: z.string().min(1),
    reason: z.string().min(3)
  }),

  async execute({
    order_id,
    reason
  }) {

    if (!orders.has(order_id)) {
      return JSON.stringify({
        ok: false,
        error: "order_not_found"
      });
    }

    const request_id =
      `rr_${String(
        refundRequests.length + 1
      ).padStart(4, "0")}`;

    refundRequests.push({
      request_id,
      order_id,
      reason
    });

    return JSON.stringify({
      ok: true,
      request_id,
      status: "pending_human_review"
    });
  }
});


const agent = new Agent({
  name: "Store support agent",

  model:
    process.env.OPENAI_MODEL ||
    "gpt-5.6-terra",

  instructions:
    "Use tools instead of inventing order facts. " +

    "Never say a refund was issued: " +
    "the tool creates only a request. " +

    "Escalate irreversible, financial, legal " +
    "or privacy-sensitive actions.",

  tools: [
    lookupOrder,
    createRefundRequest
  ]
});


const result = await run(
  agent,

  "Customer says: My order ord_1002 " +
  "arrived damaged. Can I get a refund?"
);


console.log(result.finalOutput);

console.log(refundRequests);
node support-agent.mjs
Production note: never put model API keys in browser JavaScript. Keep agent execution and privileged tools on your server. Replace the demo in-memory maps with authenticated, tenant-scoped services.

Where MCP fits

The demo uses local function tools because they are the shortest path to runnable code. When you have several agents or clients that need the same integrations, MCP becomes useful: move the order, CRM or helpdesk operation behind an MCP server and expose a small, typed tool contract.

A conceptual tool definition could look like this:

{
  "name": "lookup_order",

  "description":
    "Return the current order status for the authenticated tenant.",

  "inputSchema": {
    "type": "object",

    "properties": {
      "order_id": {
        "type": "string"
      }
    },

    "required": [
      "order_id"
    ],

    "additionalProperties": false
  }
}

Do not trust a tool merely because it is discoverable. The current MCP specification says servers must validate inputs, enforce access controls, rate-limit invocations and sanitise outputs. Clients should show sensitive tool inputs, ask for confirmation when appropriate, use timeouts and log tool use. In a multi-tenant SaaS product, the server—not the model—must enforce which customer data each tenant may access.

Reliability: the part that separates a demo from a product

Agent reliability remains an active research problem. A February 2026 paper, Towards a Science of AI Agent Reliability, argues that single benchmark accuracy is not enough: teams also need to measure consistency across repeated runs, robustness to perturbations, predictability of failures and severity of errors. LiveMCPBench similarly evaluates agents operating across large MCP toolsets and reports substantial performance differences between models. That is a reminder that tool discovery and composition should be tested rather than assumed.

Before taking money from customers, build an eval set from real or representative support cases. Run it on every prompt, model or tool change. At minimum, score factual grounding, correct tool selection, argument correctness, policy compliance, escalation behaviour, latency and estimated cost.

Risk Control Metric
Invented order facts Require order tool for order-specific claims Unsupported-fact rate
Wrong tool Distinct names, precise schemas and fewer overlapping tools Tool-selection accuracy
Duplicate action Idempotency key + database constraint Duplicate-action count
Unsafe financial action Create request, then human or deterministic approval Unauthorised-action rate
Silent degradation Tracing + nightly regression evals Pass rate by version
Runaway cost Turn limit, budgets, smaller-model routing Cost per successful outcome

How to monetise the agent

Sell the business result, not tokens. For support software, three models are practical: a base subscription plus usage, a pure outcome fee, or a managed-service retainer for a specific vertical. Outcome pricing is especially easy to explain when “success” is observable. Intercom’s US$0.99-per-outcome starting price is a useful reference point, but a new developer product should price around its own niche, integration depth, support burden and measurable customer value.

The monetisation flywheel Narrow workflow one painful job Measurable outcome resolution / handoff Usage data traces + failures Higher reliability eval-driven fixes Better pricing power charge for value
Original illustration: reliability data improves the product, which makes value-based pricing easier to defend.

A realistic unit-economics example

As of 7 September 2026, OpenAI lists GPT-5.6 Terra at US$2 per million input tokens and US$12 per million output tokens. Suppose one successful support outcome consumes 20,000 input tokens and 3,000 output tokens across the entire run. The model cost is about US$0.076 per outcome before retrieval, third-party APIs, storage, monitoring, networking and support. With GPT-5.6 Luna at the current listed US$0.20/US$1.20 rates, the same token assumption is about US$0.0076. These are examples, not a guarantee of your real cost.

Example offer Price Best for What to watch
Starter SaaS US$149/month + US$0.55 per successful outcome SMBs with predictable support volume Define “successful outcome” precisely.
Outcome only US$0.60–US$0.90 per verified outcome Customers who dislike seat fees You absorb more utilisation risk.
Vertical managed agent Illustrative US$1,500–US$5,000 setup + US$500–US$2,500/month Businesses needing integration and ongoing tuning This is a proposed service range, not a market-average statistic.
Enterprise Custom platform + volume contract Complex permissions, SSO, SLAs and audits Sales and support costs can dominate inference cost.

For example, 25 customers on the starter plan, each generating 1,000 successful outcomes in a month, would produce US$17,475 in monthly revenue under the illustrative price above. Under the Terra token assumption, 25,000 outcomes would incur about US$1,900 in model token cost. That is not US$15,575 of profit: you still pay for databases, retrieval, monitoring, payment processing, support, sales, refunds, engineering and taxes. The point of the model is to track contribution margin per successful outcome from day one.

Where to find the first customers

Pick a vertical where support questions repeatedly touch a small number of systems. Examples include e-commerce order support, B2B SaaS account support, property-management enquiries or logistics status updates. Interview ten operators before adding another framework. Ask what a resolved ticket costs, which actions require approval, what data the agent may read and what failure would make them switch the product off. A narrow integration advantage is often a stronger moat than a generic “smarter agent” claim.

A developer launch checklist

  • One job: write a one-sentence definition of the outcome you sell.
  • Authoritative data: ground customer-specific claims in tools or approved knowledge.
  • Small tool set: remove overlapping and unnecessary actions.
  • Hard permission boundary: enforce tenant and action permissions outside the model.
  • Human gate: require approval for financial, destructive, legal or privacy-sensitive actions.
  • Evals: create a regression set before changing models or prompts.
  • Observability: log tool calls, errors, latency, token usage and final outcome.
  • Economics: meter cost and revenue per successful outcome.
  • Versioning: store prompt, model and tool versions with each trace.
  • Content moat: publish real diagrams, benchmark results and lessons from your implementation instead of generic AI summaries.
The opportunity: broad “what is agentic AI?” content is already crowded. A developer article that combines a narrow use case, runnable dual-language code, MCP architecture, safety controls and transparent unit economics answers a much more valuable search intent: “help me ship something I can sell.”

Verified references

  1. Ahrefs, “Agentic Marketing: What’s the Big Deal and How to Get Started”, 15 Jun 2026. https://ahrefs.com/blog/agentic-marketing/
  2. OpenAI, “A practical guide to building agents”. https://openai.com/business/guides-and-resources/a-practical-guide-to-building-ai-agents/
  3. OpenAI, Agents SDK Quickstart. https://developers.openai.com/api/docs/guides/agents/quickstart
  4. OpenAI, Models. Prices/model IDs checked 7 Sep 2026. https://developers.openai.com/api/docs/models
  5. Anthropic, “Building effective agents”, 19 Dec 2024. https://www.anthropic.com/engineering/building-effective-agents
  6. Model Context Protocol, Tools specification, revision 28 Jul 2026. https://modelcontextprotocol.io/specification/2026-07-28/server/tools
  7. Hugging Face, smolagents documentation. https://huggingface.co/docs/smolagents/index
  8. LangChain, LangSmith Deployment documentation. https://docs.langchain.com/langsmith/deployment
  9. Intercom, Fin pricing. https://www.intercom.com/pricing
  10. Kapoor et al., “Towards a Science of AI Agent Reliability”, arXiv, 2026. https://arxiv.org/html/2602.16666v2
  11. “LiveMCPBench: Can Agents Navigate an Ocean of MCP Tools?”, arXiv, 2025. https://arxiv.org/html/2508.01780
  12. Google Search Central, “Optimizing your website for generative AI features on Google Search”. https://developers.google.com/search/docs/fundamentals/ai-optimization-guide

Accuracy note: Model names, prices, SDK APIs and platform pricing can change after publication. The time-sensitive details above were checked against official pages on 7 September 2026. Re-check those sources when updating this post.

Leave a reply

Your email address will not be published. Required fields are marked *