Skip to main content
Converting APIs to MCPs looks trivial. Many tools exist that auto-convert OpenAPI specs directly into MCPs. But direct conversion is problematic — what works for developers often fails miserably for AI agents.

The Problem with Direct Conversion

APIs are designed to return comprehensive data. MCPs need to return minimal, relevant data.

Example: Web Scraper API

Take an API like Apify’s web scraper. When you search, it returns:
  • All search result links
  • Full HTML of each page
  • Metadata, timestamps, pagination info
  • 10-20 results per request
Now imagine feeding this to an LLM. You’re dumping entire HTML pages into the context window. The LLM drowns in irrelevant content and either:
  • Forgets earlier context
  • Hits token limits
  • Produces poor results

Same Problem Everywhere

Direct API → MCP conversion ignores this fundamental difference.

Solution 1: Summarize Before Returning

Don’t return raw API responses. Process them first.

Option A: Pre-computed Summaries

Store summaries alongside your data:

Option B: On-the-fly Summarization

Use a small/nano LLM to summarize before returning:
Nano models to consider:
  • gpt-5.2 — Fast, cheap, good quality
  • claude-haiku-4-5-20251001 — Anthropic’s fastest model
  • gemini-1.5-flash — Google’s speed-optimized model
  • Local models via Ollama for zero-cost summarization

Solution 2: Build a Layer on Top

Don’t modify your existing API. Build an MCP-optimized layer on top: Your existing API continues serving developers. Your MCP layer:
  • Calls the same API
  • Processes/summarizes responses
  • Returns minimal, relevant data

Authentication: Use Your Existing Auth

Don’t create a separate auth system for MCPs. Use the same OAuth server that authenticates your existing users.

What You Need

Same Auth, Same Data

Implementation with @leanmcp/auth

Defining Scopes

Define scopes based on what the MCP actually needs:

Complete Example: HubSpot Integration


Summary

Reducing Tokens

More on optimizing MCP responses

Auth Examples

See authentication in action