See Ash Code logo See Ash Code

My first useful MCP tool wrapped a boring hosting task

Ashlynn Antrobus
• • 2 min read

My first cPanel MCP project wraps email account administration. The smallest operation in it is also a useful place to understand the idea: list the accounts for a domain.

An illustration of a server beside an envelope.

E-mail server illustration by ujmoser, CC0.

It takes one input, asks an existing API a question, and returns its answer. I can follow that request without creating or deleting a mailbox while I figure out the plumbing.

The July prototype puts the tools and the API connection in one Python file. The operation starts with this signature:

def list_email_accounts(domain: str) -> dict:

The parameter says what the tool needs. The implementation translates that domain into a cPanel UAPI call to the Email module’s list_pops function.

Following one request

Here is a teaching sketch of the call, with initialization left outside the function:

def list_email_accounts(domain: str) -> dict:
    return api.make_call("Email", "list_pops", {"domain": domain})

An MCP client supplies the domain as a named argument. Using a dummy domain, the relevant tool-call fields would be:

{
  "name": "list_email_accounts",
  "arguments": {"domain": "example.com"}
}

That is a sketch of the tool name and arguments, not a complete protocol message or a recorded request to my hosting account.

The connector builds a URL with the module and function in its path:

https://hosting.example.com:2083/execute/Email/list_pops

It sends the domain as a query parameter and adds cPanel authorization on the server side. The tool caller supplies a domain; the connector supplies the credentials it was configured with.

The first implementation returns the API’s parsed JSON. For explaining the result, I can use an abbreviated, fabricated response with a dummy account:

{
  "result": {
    "status": 1,
    "data": [{"email": "[email protected]"}]
  }
}

The full response can contain more fields. The point is to inspect the returned status and account data, rather than assume that receiving a dictionary means the hosting operation succeeded.

The tool is still a program

MCP doesn’t repair mistakes in the function it exposes. The first checked-in prototype has some ordinary Python problems: calls to check_API don’t match the helper named check_api, and the split_email signature contains a syntax error.

Those need fixing before treating that snapshot as a working server. A tool description can look convincing while the file containing it can’t run.

The connector also distinguishes only some errors. It catches request failures and invalid JSON, while an HTTP status error needs its own handling. An API-level failure inside otherwise valid JSON is another case for the caller to recognize.

Keeping the first operation small helps me separate those problems. I can check the function’s arguments, inspect the generated request, and supply a fake response without involving mailbox passwords or account deletion.

AA

Written by Ashlynn Antrobus

Software developer, author, and builder. Sharing technical lessons learned from building tools like Ebook2Text, IndexedDict, and rag-mcp, and navigating life as a programmer with dyslexia.