# Add MCP Tool

> How to expose a CSFD scraper function as a tool for AI agents via the Model Context Protocol server. Use when this capability is needed.

- Skill: `tomevault-io/add-mcp-tool-2` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx skillmds@latest add tomevault-io/add-mcp-tool-2`
- Raw SKILL.md: https://api.skillmd.com/api/skills/tomevault-io/add-mcp-tool-2/raw
- Safety review: pending (external: skill-scanner PASS, skillspector PASS)
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: AI & ML
- Author: tomevault-io (https://skillmd.com/u/tomevault-io)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/tomevault-io/add-mcp-tool-2

---


# Add MCP Tool

This skill explains how to Register a new tool in the MCP server so it can be used by LLMs.

## Prerequisites

The functionality must already exist in a Service (e.g., `csfd.movie(id)`). If not, use the `implement_scraper_feature` skill first.

## 1. LOCATE the Server Entry

- **File**: `mcp-server/index.ts`

## 2. DEFINE Input Schema

Use Zod to define the input arguments.
**Rule**: Every `.describe()` call is part of the prompt for the AI. Be descriptive!

```typescript
const toolArgs = {
  myParam: z.string().describe('Description of what this parameter does...')
};
```

## 3. REGISTER the Tool

Add the `server.tool()` call.

```typescript
server.tool(
  'tool_name_snake_case',
  'A clear, action-oriented description of what the tool does. Mention required inputs.',
  toolArgs,
  async ({ myParam }) => {
    try {
      // 1. Call the service
      const result = await csfd.someMethod(myParam);

      // 2. Return JSON content
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(result, null, 2)
          }
        ]
      };
    } catch (error) {
      // 3. Handle errors gracefully
      return {
        content: [{ type: 'text', text: `Error: ${error}` }],
        isError: true
      };
    }
  }
);
```

## 4. TEST the Tool

- **Command**: `yarn build:mcp` (to check types)
- **Manual Test**: You can temporarily add a call to `main()` or use the MCP Inspector if configured.

---
> Converted and distributed by [TomeVault](https://tomevault.io/claim/bartholomej) — claim your Tome and manage your conversions.
<!-- tomevault:4.0:skill_md:2026-04-11 -->

