Back to Blog
Photo by Taylor Vick on Unsplash

Article content

Every AI assistant speaks a different language when connecting to external tools. Before open standards arrived, integrating an agent with your database meant writing a custom integration for Claude, a different one for GPT, and a third for any local model you ran. Much of the effort went into maintaining a translation layer instead of building the product.

The Model Context Protocol (MCP) is the clearest attempt yet at solving this. It does not replace every other approach. But understanding what it does, and where agent integration as a whole is heading, is becoming a core skill for Senior Frontend Engineers building AI-native applications.

The Problem MCP Solves

Before standardised protocols, every AI provider handled tool integration differently. OpenAI introduced function calling in 2023, which let you define tools as JSON schemas and have the model decide when to invoke them. Anthropic built their own tool use format. Open-source model runners had their own conventions. The result was a fragmented ecosystem where your integration code was tightly coupled to the specific model you were using.

This created a real architectural problem. If you built a coding assistant that could read your local files using OpenAI's function calling, switching to a different model meant rewriting every integration from scratch. The integration layer, not the model, became the bottleneck.

What MCP Does

The Model Context Protocol is an open-source specification introduced by Anthropic in late 2024. OpenAI and Google have since added MCP support to their APIs, agent SDKs, and developer tools, and Anthropic has donated the protocol to the Agentic AI Foundation under the Linux Foundation, so it is now governed as a vendor-neutral standard rather than a single company's project. It defines a standard way for AI applications to connect to external data sources and tools through a client-server architecture using JSON-RPC 2.0 as the transport layer.

The protocol has three core primitives:

  • Resources: data the model can read (files, database records, API responses)
  • Tools: actions the model can invoke (run a query, write a file, call an API)
  • Prompts: reusable templates the host application can surface to the model

What makes it significant is the separation of concerns. The AI application (the "host") connects to any MCP server through a standard interface. The MCP server handles the actual integration with your tools and data. Neither side needs to know the implementation details of the other.

// A minimal MCP server in TypeScript
// Real docs: https://modelcontextprotocol.io/quickstart/server
 
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
import { z } from 'zod';
 
const server = new McpServer({
  name: 'blog-search',
  version: '1.0.0',
});
 
// Define a Tool: an action the model can invoke
server.registerTool(
  'search_posts',
  {
    title: 'Search posts',
    description: 'Search blog posts by keyword',
    inputSchema: { query: z.string().describe('The search term') },
  },
  async ({ query }) => {
    // Your actual search logic here
    const results = await searchBlogPosts(query);
    return {
      content: [{ type: 'text', text: JSON.stringify(results) }],
    };
  }
);
 
// Start listening on stdin/stdout (for local use)
const transport = new StdioServerTransport();
await server.connect(transport);

This server can now be connected to any MCP-compatible client (Claude Desktop, Cursor, VS Code with GitHub Copilot, Zed) without modifying the server code.

Where Function Calling Fits

MCP did not replace function calling. The two sit at different layers and work together.

Function calling (tool use) is how a model, inside a single API request, signals that it wants to invoke a tool you described with a JSON schema. Every major provider supports it: OpenAI, Anthropic, and Google all expose a variant. If you are building one feature against one provider's API, defining tools inline is still the most direct path.

MCP is how those tools get packaged, discovered, and shared. An MCP server exposes tools once; any MCP-capable host (an IDE, a desktop app, or a provider's agent runtime) can connect to it and hand those tools to the model, which then calls them via its normal tool-use mechanism. Architecturally, function calling is request-scoped and MCP is connection-scoped.

In practice, providers now accept both side by side. With OpenAI's Responses API, for example, you can pass inline function tools and a remote MCP server in the same request:

// OpenAI Responses API: inline function tool plus a remote MCP server
import OpenAI from 'openai';
 
const openai = new OpenAI();
 
const response = await openai.responses.create({
  model: process.env.OPENAI_MODEL!, // any current tool-capable model
  input: 'Find posts about Next.js',
  tools: [
    {
      type: 'function',
      name: 'search_posts',
      description: 'Search blog posts by keyword',
      parameters: {
        type: 'object',
        properties: {
          query: { type: 'string', description: 'The search term' },
        },
        required: ['query'],
      },
    },
    {
      type: 'mcp',
      server_label: 'blog-search',
      server_url: process.env.MCP_SERVER_URL!,
      require_approval: 'never',
    },
  ],
});

Gemini follows the same pattern: function declarations per request, with MCP support available in Google's SDKs and in tools such as Gemini CLI.

The convergence is real. Thousands of community MCP servers exist, there is now an official MCP Registry for discovering them, and clients from Cursor and VS Code to ChatGPT and Claude speak the protocol. Function calling remains the low-level mechanism underneath; MCP is the portable packaging on top.

What This Means for Your Architecture

If you are building an AI-native feature in a Next.js application today, you are likely choosing where your tool definitions live:

Pattern 1: Provider-native tool use (simpler, less portable) Define tools in the format your chosen AI provider expects. Faster to ship, tightly coupled to one provider. Good for prototypes and single-provider products.

Pattern 2: MCP server (more work upfront, portable) Build a standalone MCP server that exposes your tools. Your AI application connects to it via the standard protocol. More initial setup, but the same server works with any MCP-compatible client.

// Connecting to an MCP server from a Next.js API route
// using the MCP TypeScript SDK
 
import { Client } from '@modelcontextprotocol/sdk/client/index.js';
import { StreamableHTTPClientTransport } from '@modelcontextprotocol/sdk/client/streamableHttp.js';
 
export async function POST(request: Request) {
  const { query } = await request.json();
 
  // Connect to your MCP server
  const client = new Client({ name: 'nextjs-app', version: '1.0.0' });
  const transport = new StreamableHTTPClientTransport(
    new URL(process.env.MCP_SERVER_URL!)
  );
  await client.connect(transport);
 
  // Call a tool on the server
  const result = await client.callTool({
    name: 'search_posts',
    arguments: { query },
  });
 
  await client.close();
  return Response.json(result.content);
}

The right choice depends on your context. For internal tools and developer tooling (where MCP clients are most adopted), the MCP server pattern pays off quickly. For end-user product features built on a single AI provider, inline tool definitions are often the pragmatic choice until reuse across clients becomes a real requirement. Because providers accept MCP servers directly, moving a tool from inline to MCP later is a contained change rather than a rewrite.

The Practical Takeaway

MCP is not a reason to rewrite your existing AI integrations. It is a reason to be intentional about where you build your next one. If you are adding a new tool integration to an AI feature this month, ask: is this integration something I might want to reuse across different AI clients? If yes, build it as an MCP server. If it is tightly scoped to one product and one provider, an inline function definition is fine.

The most useful thing you can do this week is browse the official MCP Registry. The community and vendors have already built servers for GitHub, Postgres, filesystem access, Slack, and dozens of other tools. Before building custom integrations, check if one already exists.


Sources & References

Newer Post

Mastering Skills: How Custom AI Instructions Improve Code Consistency

Older Post

The Adaptive Engineer: Strategies for Professional Growth in the AI Era

Suggested Reading

Architectural Note: Research, drafting, and code for this post were augmented by Claude (Anthropic), directed and verified by Maas Mirzaa. How this workflow works →