DEV Community

KrisYing
KrisYing

Posted on

MCP Servers Explained: How to Connect AI Agents to Any Business Tool

MCP Servers Explained: How to Connect AI Agents to Any Business Tool

The Model Context Protocol (MCP) is the biggest shift in AI tooling since function calling. If you build AI applications, you need to understand MCP — it's how AI agents will interact with the real world.

I've built 2 MCP servers with 30 tools between them. Here's everything I learned.

What Problem Does MCP Solve?

Before MCP, connecting an AI agent to a business tool meant:

  1. Write custom API integration code
  2. Define tool schemas for the specific AI model
  3. Handle authentication, rate limiting, error handling
  4. Repeat for every new tool and every new AI model

MCP standardizes this. Build one MCP server, and any AI client (Claude, Cursor, Windsurf, custom agents) can use your tools.

Think of it like USB for AI — one connector, universal compatibility.

Architecture in 60 Seconds

AI Client (Claude/Cursor) ←→ MCP Protocol ←→ Your MCP Server ←→ Business API
Enter fullscreen mode Exit fullscreen mode

Your MCP server exposes tools (functions the AI can call), resources (data the AI can read), and prompts (pre-built conversation templates).

Building a Real MCP Server

Here's the structure of my Shopify MCP Server (16 tools):

import { Server } from '@modelcontextprotocol/sdk/server/index.js';
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';

const server = new Server({
  name: 'shopify-store-mcp',
  version: '1.0.0'
}, {
  capabilities: {
    tools: {}
  }
});

// Define tools
server.setRequestHandler('tools/list', async () => ({
  tools: [
    {
      name: 'get_products',
      description: 'List products from the Shopify store with optional filters',
      inputSchema: {
        type: 'object',
        properties: {
          limit: { type: 'number', description: 'Max products to return (default 10)' },
          status: { type: 'string', enum: ['active', 'draft', 'archived'] }
        }
      }
    },
    // ... 15 more tools
  ]
}));

// Handle tool calls
server.setRequestHandler('tools/call', async (request) => {
  const { name, arguments: args } = request.params;

  switch (name) {
    case 'get_products':
      const products = await shopifyClient.get('products', args);
      return { content: [{ type: 'text', text: JSON.stringify(products) }] };
    // ... handle other tools
  }
});

// Start server
const transport = new StdioServerTransport();
await server.connect(transport);
Enter fullscreen mode Exit fullscreen mode

My 2 MCP Servers

Shopify Store MCP (16 Tools)

  • Products: list, get, create, update, delete
  • Orders: list, get, create, fulfill, cancel
  • Inventory: get levels, adjust quantities
  • Customers: list, get, create, search
  • Analytics: get order stats, revenue summaries

Google Sheets MCP (14 Tools)

  • Spreadsheets: create, list, get
  • Data: read range, write range, append rows, clear range
  • Sheets: add sheet, delete sheet, rename
  • Formatting: set column widths, merge cells
  • Search: find values across sheets

What Makes a Good MCP Server

1. Clear Tool Descriptions

AI agents read your tool descriptions to decide when to use them. Be specific:

// Bad
"description": "Gets data"

// Good
"description": "List products from the Shopify store. Returns product title, price, inventory quantity, and status. Supports filtering by status (active/draft/archived) and pagination with limit parameter."
Enter fullscreen mode Exit fullscreen mode

2. Defensive Error Handling

AI agents will pass unexpected inputs. Handle everything:

case 'update_product':
  if (!args.productId) {
    return { content: [{ type: 'text', text: 'Error: productId is required' }] };
  }
  try {
    const result = await shopifyClient.put(`products/${args.productId}`, args);
    return { content: [{ type: 'text', text: JSON.stringify(result) }] };
  } catch (err) {
    return { content: [{ type: 'text', text: `Error: ${err.message}` }] };
  }
Enter fullscreen mode Exit fullscreen mode

3. Reasonable Defaults

Don't require parameters that have obvious defaults:

properties: {
  limit: { type: 'number', description: 'Max results (default: 10)', default: 10 },
  sortBy: { type: 'string', description: 'Sort field (default: created_at)', default: 'created_at' }
}
Enter fullscreen mode Exit fullscreen mode

Monetization

MCP servers have multiple revenue paths:

Channel Model Potential
npm (free) Lead generation Credibility + GitHub stars
MCPize Per-call (85% share) $100-$10K/mo
Cursor Marketplace Free (visibility) User acquisition
Freelance Custom MCP dev $500-$5,000/project
Fiverr/Upwork MCP gigs $95-$500/gig

The market is early: MCP downloads are up 85% month-over-month, but less than 5% of servers are monetized. There's a window for early movers.

Getting Started

  1. Pick a business tool your clients use (CRM, accounting, project management)
  2. Use the @modelcontextprotocol/sdk npm package
  3. Start with 3-5 tools that cover the most common operations
  4. Test with Claude Desktop or Cursor
  5. Publish to npm and submit to MCP directories

The MCP ecosystem is growing fast. The developers who build useful servers now will own the distribution when the market matures.


I build MCP servers and AI automation systems. Check out my [Shopify MCP Server][GITHUB_LINK] and [Google Sheets MCP Server][GITHUB_LINK_2] on GitHub.

Top comments (0)