Back to Skills

mcp-tools-as-code

verified

Convert MCP servers to typed TypeScript APIs for efficient code execution. Reduces token usage by 98%+ by transforming tool calls into programmatic access. Use when building agents that need to interact with multiple MCP servers efficiently, when context window is a concern, or when native control flow (loops, conditionals) would simplify multi-step workflows.

View on GitHub

Marketplace

cameronsjo

cameronsjo/claude-marketplace

Plugin

mcp

Repository

cameronsjo/claude-marketplace
3stars

plugins/mcp/skills/mcp-tools-as-code/SKILL.md

Last Verified

January 21, 2026

Install Skill

Select agents to install to:

Scope:
npx add-skill https://github.com/cameronsjo/claude-marketplace/blob/main/plugins/mcp/skills/mcp-tools-as-code/SKILL.md -a claude-code --skill mcp-tools-as-code

Installation paths:

Claude
.claude/skills/mcp-tools-as-code/
Powered by add-skill CLI

Instructions

# MCP Tools as Code

Transform MCP servers from discrete tool invocations into typed TypeScript APIs that agents interact with programmatically. This approach dramatically reduces token usage and enables native control flow.

## The Problem

Traditional MCP tool usage has two inefficiencies:

1. **Context Overload**: Tool definitions occupy significant context window space. Agents connected to many servers process thousands of tokens before reading requests.

2. **Intermediate Result Duplication**: Data retrieved through tool calls traverses the model multiple times. A meeting transcript fetched, summarized, and stored means processing the transcript tokens repeatedly.

## The Solution

Present MCP servers as filesystem-organized code APIs. Agents discover, load, and use tools via native TypeScript instead of discrete tool calls.

**Before** (150,000+ tokens for a simple workflow):
```
1. Tool call: gdrive.getDocument → Model processes result
2. Tool call: summarize → Model processes result
3. Tool call: salesforce.updateRecord → Model processes result
```

**After** (2,000 tokens):
```typescript
const transcript = (await gdrive.getDocument({ documentId: 'abc123' })).content;
const summary = extractKeyPoints(transcript);
await salesforce.updateRecord({
  objectType: 'SalesMeeting',
  recordId: '00Q5f000001abcXYZ',
  data: { Notes: summary }
});
```

## Architecture

### Directory Structure

```
servers/
├── {server-name}/
│   ├── index.ts          # Re-exports all tools
│   ├── types.ts          # Shared types and interfaces
│   ├── {tool-name}.ts    # Individual tool modules
│   └── README.md         # Server documentation
└── index.ts              # Server discovery/registry
```

### Tool Module Pattern

Each MCP tool becomes a typed TypeScript module:

```typescript
// servers/google-drive/getDocument.ts
import type { DocumentResult } from './types';

export interface GetDocumentInput {
  /** Google Drive document ID */
  documentId: string;
  /** Format to retri

Validation Details

Front Matter
Required Fields
Valid Name Format
Valid Description
Has Sections
Allowed Tools
Instruction Length:
9400 chars