cd /news/ai-agents/turning-a-custom-gpt-action-into-an-… · home › topics › ai-agents › article
[ARTICLE · art-175359] src=dev.to ↗ pub= topic=ai-agents verified=true sentiment=↑ positive

Turning a Custom GPT Action into an MCP server: a minimal tested example

A developer published a minimal, tested example of migrating a Custom GPT Action to an MCP server using the official TypeScript SDK (@modelcontextprotocol/sdk 1.32.2, zod 4, Node 24). The demo wraps Open-Meteo's current-weather endpoint as a get_current_weather tool, with a stdio test client confirming tool listing, a successful call returning 2.6°C and 9 km/h wind, and a validation error for out-of-range latitude. The author notes the example is a happy-path demo, not production-hardened, and that HTTP error and network-failure branches remain untested.

recommendation

When porting an OpenAPI Action to an MCP tool, rewrite parameters as a zod inputSchema and explicitly return isError: true with an actionable message on failures, then test both success and validation paths via a stdio client.

more in playbook: Designing agent systems
by read2 min views1 publishedNov 24, 2026

If you have a Custom GPT that calls your own API through an Action, the same API can also be exposed to MCP clients such as Claude. This is a minimal, tested example of moving one Action operation into an MCP server. I ran the code below with the official TypeScript SDK (@modelcontextprotocol/sdk 1.32.2, zod 4, Node 24). It is a happy-path demo, not production-hardened.

Setup: npm i @modelcontextprotocol/sdk zod, save the server as server.mjs and the test client as test.mjs (both ES modules).

Custom GPT Action (OpenAPI) MCP server
operationId tool name
summary /description tool description (the model reads this to decide when to call it)
parameters + request schema inputSchema : a zod shape you write by hand (no OpenAPI import)
HTTP error response you map it to isError: true yourself, with a message the model can act on
API key / OAuth in the Action your server's own auth (not shown here)

Operation being moved: GET /v1/forecast?latitude=..&longitude=..¤t_weather=true (Open-Meteo, no key needed).

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: "weather-actions", version: "1.0.0" });

// OpenAPI operation: GET /v1/forecast?latitude=..&longitude=..&current_weather=true  (operationId: getCurrentWeather)
server.registerTool(
  "get_current_weather",
  {
    description: "Current temperature (°C) and wind speed (km/h) for a latitude/longitude.",
    inputSchema: { latitude: z.number().min(-90).max(90), longitude: z.number().min(-180).max(180) },
  },
  async ({ latitude, longitude }) => {
    const url = `https://api.open-meteo.com/v1/forecast?latitude=${latitude}&longitude=${longitude}&current_weather=true`;
    const res = await fetch(url);
    if (!res.ok) {
      return { isError: true, content: [{ type: "text", text: `Weather API returned ${res.status}. Check the coordinates and retry.` }] };
    }
    const { current_weather: w } = await res.json();
    return { content: [{ type: "text", text: JSON.stringify({ temperature_c: w.temperature, windspeed_kmh: w.windspeed }) }] };
  }
);

await server.connect(new StdioServerTransport());

A client that connects over stdio, lists tools, and calls the tool twice:

import { Client } from "@modelcontextprotocol/sdk/client/index.js";
import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
const c = new Client({ name: "t", version: "1" });
await c.connect(new StdioClientTransport({ command: "node", args: ["server.mjs"] }));
console.log(JSON.stringify((await c.listTools()).tools.map(t=>({name:t.name,required:t.inputSchema.required}))));
console.log(JSON.stringify(await c.callTool({ name: "get_current_weather", arguments: { latitude: 52.52, longitude: 13.41 } })));
console.log(JSON.stringify(await c.callTool({ name: "get_current_weather", arguments: { latitude: 999, longitude: 0 } })).slice(0,200));
await c.close();

Results:

listTools returned one tool, get_current_weather, with latitude and longitude required.{"temperature_c":2.6,"windspeed_kmh":9}. isError: true: Too big: expected number to be <=90 at latitude. The !res.ok branch in the handler is not covered by this test, and network failures (a thrown fetch) are not handled. If you would rather hand it off, I offer this migration as a fixed-price Upwork project (search for "Custom GPT Actions rebuilt as a tested MCP server").

── more in #ai-agents 4 stories · sorted by recency
── more on @model context protocol 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
→ Live at https://your-agent.zahid.host ✓
Get free account → Pricing
from €0/mo · no card required
LIVE [news/turning-a-custom-gpt…] indexed:0 read:2min 2026-11-24 · —