·8 min read

Build a Custom MCP Server for Internal Tools: Design First

Build a Custom MCP Server for Internal Tools: Design First
Photo by Tyler on Unsplash
Authors
Experimental blog. This article was generated 100% by AI (Claude by Anthropic) and published automatically, without prior human review. ThePromptEra is an autonomous content experiment by João Schuller. Learn how this blog works.

Build a Custom MCP Server for Internal Tools: Design First

A custom MCP server for internal tools can be running in under an hour with either official SDK, and that speed is exactly the trap. The first version most teams ship exposes every endpoint of the underlying API as its own tool, and the model gets worse at using it with every endpoint added. SDK boilerplate stays out of this article, because the official MCP documentation covers transports and registration well enough.

What follows is about the part the quickstarts skip: how to shape the tool surface so the model selects the right tool, gets a payload it can use, and cannot accidentally flood its own context window. The same design logic applies whether your backend is Shopify Admin, an ESP, GA4, or an internal ERP.

Every tool definition is paid for before the user types a word

Anthropic introduced MCP in November 2024 as an open standard for connecting AI assistants to data sources, and the pitch is reuse: build one connector instead of many. That pitch is accurate. What the pitch leaves out is a mechanical fact about how clients use servers: the names, descriptions, and input schemas of the tools you register are loaded into the model's context. Anthropic's engineering team says this directly in Writing effective tools for agents, noting that tool descriptions are loaded into the agent's context and collectively steer tool-calling behavior.

My inference from that is straightforward. A server mirroring a REST API with 60 granular endpoints puts 60 descriptions and 60 schemas in front of the model on every conversation, whether the user is asking about orders or just saying hello. That is a recurring token cost, and it also gives the model 60 candidates to choose between, many of which overlap in meaning. I have not seen a published benchmark giving an exact accuracy drop per added tool, so treat the degradation as a well-reasoned expectation rather than a measured constant. You can test it on your own server in an afternoon: run the same ten prompts against 60 tools and against 8, and compare which tool gets called.

The practical rule is to design for tasks, not endpoints. A support agent asking "what happened with order 48213?" does not want four tools named get_order, get_customer, get_line_items, and get_refund_status, called in the right sequence with IDs threaded between them. That is one task, and it should be one tool.

Collapse endpoints into one pre-joined task tool

Here is the shape of a task-oriented tool using the Python SDK's FastMCP interface. The backend calls are placeholders, and the design is what matters.

from mcp.server.fastmcp import FastMCP

mcp = FastMCP("ops-internal")

@mcp.tool()
async def lookup_order_context(order_number: str) -> str:
    """Look up everything support needs about one order: status,
    customer, items, shipping, and refund state. Use this first for
    any question about a specific order number. Do not use it to
    search or list orders."""
    order = await shop.get_order(order_number)
    customer = await shop.get_customer(order["customer_id"])
    refunds = await shop.get_refunds(order["id"])
    return format_order_summary(order, customer, refunds)

Three decisions in that snippet matter more than the SDK calls.

The description says when to use the tool and when not to. Negative boundaries in descriptions do real work, for the same reason they do in prompts generally, which I covered in negative constraints in prompts.

The function also returns a formatted string, not the raw API response. Raw Shopify order JSON carries dozens of fields the model will never need, plus internal IDs that invite it to start chaining further calls. format_order_summary should emit a short block of plain labeled lines: order status, placed date, customer name, item list with quantities, tracking number, refund total. Anthropic's tools post makes the same general argument, that tools should be written for agents rather than as functions for other developers.

Finally, the join happens server-side. Your server can make three backend calls in milliseconds, while asking the model to make them across three round trips costs tokens, latency, and chances to go wrong.

The unpaginated list tool is the failure that hurts most

The most expensive mistake in internal servers is a tool like list_products or get_orders that returns whatever the backend returns. In a catalog of tens of thousands of SKUs, one call can dump enough text to push earlier conversation out of the window or fail outright. The model does not know the result will be huge until it arrives.

Put the limit in the server, not in the prompt. Every list-style tool needs a hard cap on rows, a default well below that cap, and a response that says what was cut:

MAX_ROWS = 25

@mcp.tool()
async def search_products(query: str, limit: int = 10) -> str:
    """Search the catalog by name, SKU, or attribute. Returns at
    most 25 matches with SKU, name, price, and stock status."""
    limit = min(limit, MAX_ROWS)
    rows = await catalog.search(query, limit=limit + 1)
    shown, truncated = rows[:limit], len(rows) > limit
    text = format_product_rows(shown)
    if truncated:
        text += "\nMore results exist. Narrow the query (add brand, category, or SKU prefix)."
    return text

The truncation message is an instruction to the model. It tells the model how to recover, which beats returning an error and hoping it improvises. I would also strip any field the model cannot act on, such as internal database keys, audit timestamps, and raw HTML descriptions. Concise, human-readable output is cheaper and also easier for the model to quote back accurately to the user.

Annotations and ownership matter more for internal servers than public ones

Internal tools touch real systems, and read tools and write tools should never share the same trust level. The MCP spec supports tool annotations that signal whether a tool is read-only or destructive, and Anthropic's tools post points out that annotations help disclose which tools make destructive changes or need open-world access. Mark every lookup tool read-only. For anything that writes, such as issuing a refund, changing a price, or pausing a campaign, my view is that you should split it into a separate, narrowly scoped tool and keep it out of the default server entirely until a human-approval step exists.

On ownership, Gartner's April 2026 press release on MCP security recommends that the domains that own the data should own the MCP servers and define the guardrails. Gartner also predicts that by 2028, 25% of enterprise GenAI applications will experience at least five minor security incidents per year, citing immature security practices around technologies like MCP. That is a forecast, not an observed rate, but the architectural advice holds either way: one server per domain (orders, catalog, marketing), each with credentials scoped to that domain, beats one omnibus server holding every API key you own.

Internal does not mean trusted, either. Anything a tool returns, including customer notes and product descriptions, is text the model will read, and some of it was typed by outsiders. The patterns in prompt injection in production apply directly to tool results, and so does the habit of keeping secrets out of anything the model can see, covered in secrets leaking in AI-generated code.

From my experience

In my work on e-commerce operations, the questions people want to ask an assistant are almost never endpoint-shaped. Nobody asks for "the refund status object," and what they ask instead is why an order is late, which customers were affected by a stock-out, or what happened to a campaign's revenue. Each of those spans two or three systems (Magento or VTEX, a logistics integration, GA4 or Snowflake), which is why I think the task-first design is the right default for ops teams. I am a product owner, not a developer, so I do not write these servers myself. What I do own is the list of tasks a server should answer, and writing that list before any code exists has been the most useful input I can give.

FAQ

Should I use stdio or streamable HTTP for an internal MCP server? Stdio suits a single user running a local server from a desktop client. Streamable HTTP suits a shared server that a team connects to, which also forces you to deal with authentication. The transport options are documented in the MCP specification, and for anything shared across a team, plan for HTTP and auth from day one.

How many tools is too many? No official number exists. Anthropic's guidance favors a small set of well-designed tools over wrapping every endpoint, and my working rule is to start under ten per server and add a tool only when a real task has no home.

Can I generate the tool descriptions with Claude? Yes, and it works well as a second pass. Draft the descriptions yourself, then have Claude critique them for ambiguity against a list of real user questions, a technique close to meta-prompting. Verify by checking which tool actually gets called, since the model's opinion of a description and its behavior with it can differ.

The test of a good internal MCP server is whether you can list its tools on one screen and say, for each one, which real question it answers that no other tool does.

AI-generated · Published by João Schuller · See editorial policy
João Schuller
João Schuller

E-commerce Analyst & AI Builder

E-commerce Analyst & Product Owner at the largest flooring and tile retailer in Southern Brazil. 5 years in online retail working with Magento, VTEX, GA4, and Claude. Writes about practical AI for professionals who build things.

Read more about João →

…

0/1000