← Back to home MCP Security in Practice cover

MCP Security in Practice

What OWASP Won't Tell You About AI Tool Integrations

MCP Security Complete Guide | OWASP MCP Top 10 · token cost · file upload

Is your MCP actually production-ready? Token cost measurements, file upload edge cases, OWASP MCP Top 10 — verified by running freee tax automation in production.

Security Series [Implementation]. Specifically MCP protocol security.
Read on Kindle Read sample chapters See chapter list

30+ technical books across 4 languages · Sold on Kindle in 6 countries · From a year of real production use

Included with Kindle Unlimited Published: Updated:
ken imoto
ken imoto — Author of the Practical Claude Code & Harness Engineering series. 30+ technical books across JA/EN/PT/ES. · 7-day return window via Amazon

📖 Read for free

Read three full chapters right here before you buy. Liked it? Continue on Kindle.

01 Preface

“Automating 90% of tasks while being forced to do manual work on the most critical 10%. That’s the reality of MCP.”

Why I Wrote This Book

In March 2026, with tax filing deadline approaching, I was trying to automate expense processing using freee’s MCP server.

Creating transactions, setting account items, entering amounts. Everything worked perfectly. Just by instructing Claude Desktop with “Register December electricity bill for 8,500 yen under utilities,” the journal entry was completed in seconds. I remember being moved by “This is the power of MCP.”

However, the next step stopped me cold.

Receipt attachment was impossible.

Tool: mcp_server__api_post
Parameters: path: /api/v1/receipts
            body: {"company_id": "xxx", "description": "Electricity bill July"}
Response: API Error: 400
          Detail: Content-Type must be "multipart/form-data"

Receipt attachment is not optional for expense processing. It’s legally required. I ended up automating 90% of the task while being forced to do manual work on the most critical part.

CLI scripts could handle it from the outside. But then, what’s the point of publishing MCP integration?

This experience led me to thoroughly investigate what MCP can and cannot do. I verified file uploads across 7 services, studied OWASP MCP Top 10 security risks, and measured token costs across 4 MCP servers. The more I investigated, the more I realized the MCP world is full of pitfalls that “hurt if you don’t know them.”

  • 30 CVEs reported in 60 days
  • Scanning 500+ MCP servers revealed 38% without authentication
  • Zero out of 7 services fully support file uploads
  • Just loading tool definitions costs approximately ¥1,000 annually in tokens

There are plenty of articles saying “MCP is convenient!” However, there was almost no systematic information about practical problems (security, costs, file constraints) faced in production deployments.

So I decided to write it myself.

Book Structure

This book is organized into three major parts.

Part 1: Foundations and Practice (Chapters 1-4) From MCP’s big picture to communication specifications, token cost measurements, and real experience with freee tax automation. If you’re new to MCP, start here.

Part 2: Constraints and Security (Chapters 5-6) The core of this book. File upload problem verification across 7 services and complete coverage of OWASP MCP Top 10. Essential reading before deploying MCP in production.

Part 3: Practice and Outlook (Chapters 7-8) Production-ready workaround collections and MCP’s future with SEP-1306 and FileContent. Practical tips for those already using MCP.

Target Audience

  • Engineers considering AI automation using MCP
  • Those planning to deploy MCP servers in production environments
  • Those who want to understand MCP security risks
  • Those considering MCP integration with freee, Jira, Notion, GitHub, etc.

What This Book Doesn’t Cover

  • MCP server development tutorials (SDK usage, etc.)
  • Specific LLM usage instructions
  • How to participate in MCP specification development

About the Author

ken imoto. 8 years of engineering experience. Specializes in designing real-time systems combining AI/LLM with WebRTC. Actually conducted tax filing using freee’s MCP server and experienced both MCP’s possibilities and limitations.

This book contains all the insights gained from that experience. I’ve written honestly about not just successful methods, but also lessons learned from failures.

Welcome to the real world of MCP.

Continue this chapter on Kindle →
02 The Big Picture of MCP — A Protocol Connecting LLMs to External Tools

“MCP is a protocol to create AI’s ‘hands.’ However, those hands are still clumsy.”

The Protocol That Solves LLM’s “Cannot Do”

Before 2025, when you asked an LLM to “register expenses in freee,” it would respond:

“I apologize, but I cannot directly access external services. Please register manually on the freee website.”

LLMs are intelligent. They can write text, write code, and analyze. However, they couldn’t touch the external world.

MCP was born to break through this constraint.

MCP (Model Context Protocol) is an open protocol established by Anthropic that provides a standard for connecting LLMs with external tools and data sources. Simply put, it’s a protocol that gives LLMs “hands”.

Why Not Just Call APIs Directly?

You might wonder: “Why not just have LLMs call APIs directly?”

Indeed, having LLMs write Python scripts to call freee APIs has been possible for a long time. However, this approach had three problems.

Problem 1: Different Authentication Methods per Service freee uses OAuth 2.0, GitHub uses Personal Access Tokens, Slack uses Bot Tokens. Each service requires implementing different authentication flows.

Problem 2: No Dynamic Tool Discovery LLMs need to know “what can be done with this service” in advance. Making them read API documentation is inefficient and consumes massive tokens.

Problem 3: No Safe Execution Environment Allowing unlimited execution of Python scripts written by LLMs is a security nightmare.

MCP attempts to solve all three problems with a standardized protocol.

MCP’s Three Components

MCP’s architecture is simple. It consists of just three elements.

MCP's Three Components

1. MCP Host/Client

Claude Desktop, IDEs (VS Code, etc.), AI tools. Receives user’s natural language requests and forwards them to MCP servers in standardized format.

The key point is that hosts don’t need to know service details. What endpoints freee’s API has, what parameters are needed - the MCP server knows all of this.

2. MCP Server

A lightweight program responsible for connecting to external services. One MCP server exists for each service.

An MCP server has three roles:

  • Tool Definition: Publishes “what can be done” in standard format
  • Authentication Management: Handles service-specific authentication like OAuth internally
  • API Calls: Executes actual external API calls

3. External Services (Resources)

freee, GitHub, Slack, Google Drive, etc. Services that provide actual data and functionality. MCP servers call these APIs.

Three Functions Provided by MCP

FunctionDescriptionExamples
ToolsFunctions LLMs can callTransaction creation, email sending, issue creation
ResourcesData LLMs can referenceFile contents, DB, configuration values
PromptsReusable prompt templatesCode review prompts, etc.

In practice, Tools are used most frequently. freee’s MCP server publishes 270 tools because it defines all operations for accounting, HR, invoicing, attendance, and sales management as Tools.

Differences Between MCP and Traditional Approaches

ItemTraditional (Direct API Calls)MCP
AuthenticationIndividual implementation per serviceUnified management by MCP server
Tool DiscoveryFeed API documentationDynamic retrieval via tools/list
Execution EnvironmentExecute LLM-generated codeMCP server mediates safely
StandardizationNone (custom implementation)Unified standard based on JSON-RPC 2.0

Current State of the Ecosystem

As of March 2026, the MCP ecosystem is expanding rapidly.

  • Official MCP Servers: GitHub, Slack, Notion, freee, Salesforce, etc.
  • Third Party: Hundreds of MCP servers published on platforms like LobeHub, Composio, CData
  • Supporting Clients: Claude Desktop, VS Code, Cursor, n8n, etc.

However, this rapid adoption has a dark side. A survey scanning 500+ MCP servers found 38% without authentication. This problem will be detailed in Chapter 6.

Chapter Summary

  • MCP is a protocol for standardized connection between LLMs and external services
  • Three-layer architecture: Host/Server/Resource
  • Main benefits are unified authentication management and dynamic tool discovery
  • The ecosystem is expanding rapidly, but security hasn’t caught up

The next chapter will delve into MCP’s communication specifications. We’ll see why JSON-RPC-based design causes file upload problems and understand the root cause.

Continue this chapter on Kindle →
Other editions: 日本語

Overview

Before you ship MCP (Model Context Protocol) to production, read this. Token cost measurements, file upload issues verified across 7 services, OWASP MCP Top 10, and lessons from running freee tax automation in production — the security guide for safely operating MCP.

What you will be able to do

Who is this book for

Problems this book solves

Where this book stands

Why this book

How this differs from other AI books

Compared to This book's difference
MCP official documentation Official docs cover features. This book covers production-discovered risks and mitigations.
Generic OWASP books Not generic OWASP. Specific to MCP's own Top 10.
AI agent design books Within agent design, this drills specifically into the MCP security layer.

Table of contents

  1. 01 Preface Free preview
    • 1-1 Why I Wrote This Book
    • 1-2 Book Structure
    • 1-3 Target Audience
    • 1-4 What This Book Doesn't Cover
    • 1-5 About the Author
  2. 02 MCP Mechanics and Threat Model Free preview
    • 2-1 The Protocol That Solves LLM's "Cannot Do"
    • 2-2 Why Not Just Call APIs Directly?
    • 2-3 MCP's Three Components
    • 2-4 Three Functions Provided by MCP
    • 2-5 Differences Between MCP and Traditional Approaches
    • 2-6 Current State of the Ecosystem
  3. 03 OWASP MCP Top 10 Free preview
  4. 04 Authentication and Authorization Design
  5. 05 Token Cost Measurements
  6. 06 File Upload Problems — 7 Services Tested
  7. 07 freee Tax Automation Implementation Patterns
  8. 08 Sensitive Data Handling Design
  9. 09 Server-Side Responsibility Boundaries
  10. 10 Audit Logs and Monitoring
  11. 11 Production Operations Checklist
  12. 12 MCP's Future
  13. 13 Afterword

MCP is convenient — until you put it in production. Then suddenly: “wait, is this actually safe?”

Unexpected token cost spikes, mysterious file upload failures, sensitive-data boundary design, the OWASP MCP Top 10 — this book is the practical security guide built from running freee tax automation in production, backed by 7-service verification data.

“Between ‘convenient’ and ‘safe’ lies a margin of design.”

Related books

Read on Kindle

Included in Kindle Unlimited

Read on Kindle
Topics: MCPModel Context ProtocolSecurityOWASPAI Tool Integration

* This page contains Amazon Associates links. Purchases may earn the author a referral fee.