---
title: "Model Context Protocol (MCP): Connecting AI Agents to Your Own Tools"
description: "What the Model Context Protocol is and why it matters: writing a simple MCP server in TypeScript, tool design, security, authorisation and applying it to test automation platforms."
url: https://sanderyaz.com/en/blog/mcp-model-context-protocol/
author: Sander Yazıcıoğlu
date: 2026-12-02
updated: 2026-12-02
lang: en
tags: ["AI","LLM","TypeScript","Node.js"]
---

# Model Context Protocol (MCP): Connecting AI Agents to Your Own Tools

The real value of AI assistants isn't just generating text but doing work in your systems: starting a test run, reading error logs, taking a device screenshot. Instead of writing a separate integration for every assistant, there's now a common standard: the **Model Context Protocol (MCP)**.

## What is MCP?

MCP is an open protocol that lets an AI client (Claude, IDE assistants, agent frameworks) connect to external systems through a standard interface. An MCP server can offer three things:

- **Tools:** operations the model can call (`start_test_run`, `get_device_logs`).
- **Resources:** readable content (documents, report files).
- **Prompts:** ready-made, parameterised workflows.

A server you write once works with every client that supports MCP. MCP does for tools what USB did for devices.

## A small server in TypeScript

```ts
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: 'test-runs', version: '1.0.0' });

server.tool(
  'get_failed_runs',
  'Returns the latest failed test runs of a project, with their error messages.',
  { projectId: z.number(), days: z.number().max(30).default(7) },
  async ({ projectId, days }) => {
    const runs = await api.failedRuns(projectId, days);
    return { content: [{ type: 'text', text: JSON.stringify(runs) }] };
  }
);

await server.connect(new StdioServerTransport());
```

Locally you use the stdio transport; remote servers use Streamable HTTP.

## Good tool design

A model will use the tool, not a human. So:

- **The description is the documentation.** The model picks a tool from its name and description alone. Say what it returns and when to use it.
- **Few but powerful tools.** Turning every REST endpoint into a tool confuses the model. Design task-oriented tools: `summarize_run_failures` instead of `list_runs` + `get_run` + `get_steps`.
- **Short, structured output.** Returning a 5 MB log fills the context; summarise and paginate.
- **Meaningful errors.** Instead of "400": "projectId not found; call list_projects for valid IDs".

## Security

- **Least privilege:** separate read tools from write tools; put irreversible actions such as deletes behind user confirmation.
- **Prompt injection:** content returned by a tool (a test log, a web page) can look like instructions to the model. Mark tool output as data and require a second confirmation for critical actions.
- **Authentication:** use OAuth for remote MCP servers; act on behalf of the user, not with one super token.

## Applying it to test automation

For a platform such as Testinium, MCP makes this possible: a developer asks from their IDE "why did 12 tests fail in last night's run?", and the agent reads the failed steps, screenshots and logs and summarises the common root cause. To make your website readable by agents in the same spirit, see [making your website AI-agent ready](/en/blog/make-your-website-ai-agent-ready/).

## Conclusion

MCP turns AI integration from custom code rewritten for every client into a standard server written once. Start with a few well-described tools, tight permissions and short outputs. To measure your agent's quality, read [LLM evals as test automation](/en/blog/llm-evals-test-automation/).

---

About the author: [Sander Yazıcıoğlu](https://sanderyaz.com/en/about/). Sander Yazıcıoğlu is a Senior Full-Stack Developer in Istanbul. At LiveTesting he builds the backend, frontend, realtime systems and Appium automation of a real-device testing platform; before that he built enterprise Angular apps at Testinium and Loadium.
