# Add MCP Tool

> Add new MCP tools to the server. Use when creating new GitHub PR review capabilities. Use when this capability is needed.

- Skill: `tomevault-io/add-mcp-tool-4` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx skillmds@latest add tomevault-io/add-mcp-tool-4`
- Raw SKILL.md: https://api.skillmd.com/api/skills/tomevault-io/add-mcp-tool-4/raw
- Safety review: pending
- 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-4

---


# Add MCP Tool

## When to Use

When adding a new GitHub PR review capability to the MCP server.

## Steps

### 1. Define Schema (`src/types.ts`)

```typescript
// Schema for runtime validation
export const NewToolSchema = z.object({
  owner: z.string().describe("Repository owner/organization"),
  repo: z.string().describe("Repository name"),
  prNumber: z.number().describe("Pull request number"),
});

// Explicit type definition (preferred)
export interface NewToolParams {
  owner: string;
  repo: string;
  prNumber: number;
}
```

### 2. Add Service Method (`src/github-service.ts`)

```typescript
async newMethod(params: NewToolParams): Promise<ResultType> {
  try {
    const result = await this.octokit.pulls.get({
      owner: params.owner,
      repo: params.repo,
      pull_number: params.prNumber,
    });
    return result.data;
  } catch (error) {
    const message = error instanceof Error ? error.message : String(error);
    console.error("Error in newMethod:", message);
    throw new Error(`Failed to execute newMethod: ${message}`);
  }
}
```

### 3. Register Tool (`src/index.ts`)

```typescript
server.addTool({
  name: "new_tool_name",
  description: "Clear description of what this tool does",
  parameters: NewToolSchema,
  execute: async (params: NewToolParams) => {
    const result = await githubService.newMethod(params);
    return {
      content: [{ type: "text", text: JSON.stringify(result, null, 2) }],
    };
  },
});
```

### 4. Update Documentation

Update `README.md` tool table with the new tool.

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

