iTranslated by AI

The content below is an AI-generated translation. This is an experimental feature, and may contain errors. View original article
🔧

Building an MCP Server to Bring Certainty to AI Agents

に公開

Introduction

When using Claude or Cursor, have you ever encountered situations like these?

  • You asked, "Is May 22, 2026, a business day?" and it answered confidently but incorrectly.
  • You requested a time zone conversion, and it ignored daylight saving time.
  • You asked it to calculate "5 business days from now," and it forgot to skip public holidays.

While AI is clever, there are tasks it is not good at providing 100% accurate answers for. Because it relies on inference, it occasionally makes mistakes. However, when using these tools for business, "occasionally wrong" is a problem.

That is why I built a utility MCP (Model Context Protocol) server that guarantees accuracy, which AI agents can call as external tools.


What is Thousand API?

It is an MCP server that provides a collection of tools that can handle tasks more reliably than AI inference.

It complements three things that AI cannot provide on its own:

  1. Real-time data (exchange rates, IP geolocation, public holiday data, etc.)
  2. Reliable calculations (business days, time zone conversions, distance calculations, etc.)
  3. Side-effect processing (QR code generation, fetching URL meta info, etc.)

Available Tools

Tool Description
Calendar Holiday judgment, N-business day calculation, time zone conversion (with automatic DST support)
Scraper Fetch URL title, OGP, and favicon
ExchangeRate Real-time exchange rates and currency conversion
IPLookup Fetch geographical information for IP addresses
Distance Distance calculation between two locations
QRCode Generate QR codes from text or URLs

How to Connect to Claude or Cursor

You can use it just by adding the following to your configuration file.

For Claude Desktop (claude_desktop_config.json):

{
  "mcpServers": {
    "thousand-api": {
      "url": "https://mcp.thousand-api.com/mcp",
      "headers": {
        "x-api-key": "YOUR_API_KEY"
      }
    }
  }
}

The configuration is the same for Cursor.
You can generate your API key for free after registering at https://www.thousand-api.com/ja.

Example of Actual Usage

When you ask Cursor, "Tell me the date 3 business days from next Monday," the add_business_days tool is invoked, and it returns a date that accurately accounts for public holidays.

// Example of MCP tool invocation
{
  "name": "add_business_days",
  "arguments": {
    "country": "JP",
    "from": "2026-05-26",
    "days": 3
  }
}

// Response
{
  "from": "2026-05-26",
  "days": 3,
  "country": "JP",
  "result": "2026-05-29"
}

Screenshot of actual use in Cursor


Why I Built This

I originally started this as a utility API for developers, thinking, "I'll turn processing tasks that I can build myself but get tired of repeating into an API."

However, I ran into the fundamental question: "Wouldn't a library be better for that?" The necessity of it being an API was weak.

So, I pivoted. Everything changed when I focused on the context of "being used by AI agents."

  • Libraries are things humans install and use.
  • MCP servers are tools that AI agents can call directly.

By redefining it as "an API for AI to call, not for humans to call," the value proposition became clear.


Tech Stack

As this is a personal project, I prioritized minimizing costs and operational overhead.

Infrastructure

I do not use EC2, RDS, or ALB at all. Costs are nearly zero during hours with no traffic.

Technologies Used

Domain Technology
Language TypeScript
API Framework Hono
MCP Server @modelcontextprotocol/sdk
Infrastructure AWS CDK
Runtime Lambda (Node.js 22) + API Gateway (HTTP API)
Website Next.js 15 + OpenNext + CloudFront
DB DynamoDB (Single-table design)
Auth (Web) Auth.js v5
Payments Stripe

Monorepo Structure

thousand-api/
├── apps/
│   └── web/          # Next.js 15 (HP)
├── packages/
│   ├── api/          # Lambda functions (API for AI)
│   ├── mcp/          # MCP server
│   └── shared/       # Shared type definitions, DynamoDB access, Auth
└── infra/            # AWS CDK

Hono on Lambda

I use Hono on top of API Gateway HTTP API. By splitting Lambda functions per category (1 Lambda = 1 category), I can minimize the impact of cold starts.

// packages/api/src/functions/calendar/index.ts
import { Hono } from 'hono';
import { handle } from 'hono/aws-lambda';

const app = new Hono();
app.use('*', trackUsage());
app.get('/v1/calendar/holidays',      holidaysHandler);
app.get('/v1/calendar/is-holiday',    isHolidayHandler);
app.get('/v1/calendar/business-days', businessDaysHandler);

export const handler = handle(app);

Lambda Support for MCP Server

To run the MCP Streamable HTTP transport on Lambda, I use Express as a lightweight adapter with serverless-express.

// packages/mcp/src/index.ts
const app = express();
app.use(express.json());

app.post('/mcp', async (req, res) => {
  const server    = createServer();
  const transport = new StreamableHTTPServerTransport({
    sessionIdGenerator: undefined, // Stateless mode
  });
  await server.connect(transport);
  await transport.handleRequest(req, res, req.body);
});

export const handler = serverlessExpress({ app });

DynamoDB Single-Table Design

I manage users, API keys, and usage statistics all in a single table.

PK SK Purpose
USER#<userId> METADATA User Information
USER#<userId> APIKEY#<apiKeyId> API Key List
APIKEY#<hashedKey> METADATA API Key Lookup
USAGE#<userId> MONTH#<YYYYMM> Monthly Usage

API keys are saved only as SHA-256 hashes; the plain text is only shown once upon issuance.


Pricing Plan

Plan Monthly Requests Price
Free 1,000 requests Free
Starter 10,000 requests ¥480/month
Pro 100,000 requests ¥1,980/month

All tools are available even on the free plan.
Please register and give it a try.


Future Plans

These are tools currently under implementation or consideration:

  • Cron expression parser (Calculate next execution time)
  • JSON Schema Validator (Validate and auto-fix AI output JSON)
  • Text statistics (Character count, reading time)
  • TrimSilence (Remove silence from audio files)

The MCP ecosystem is still evolving, and I am developing this through trial and error while exploring "what an API for AI agents should be."

Feel free to send feedback or requests via the official contact page.


Conclusion

  • Built an MCP server that reliably solves tasks where AI is only capable of "vague inference."
  • Can be used by adding just one line of configuration to Claude or Cursor.
  • Minimized costs with a fully serverless architecture.
  • Free plan is available.

If you are developing using AI agents, please give it a try!

Discussion