Using Anthropic Claude with TinyFn MCP Tools

Anthropic Claude is one of the most capable AI assistants available, and with MCP (Model Context Protocol) support, it becomes even more powerful. This guide shows you how to connect TinyFn's 500+ deterministic tools to Claude for accurate calculations, conversions, and validations.

Claude's MCP Support

Anthropic developed the Model Context Protocol (MCP) as an open standard for connecting AI models to external tools and data sources. Claude has native MCP support, meaning it can seamlessly discover and use tools from any MCP-compatible server.

When you connect TinyFn to Claude via MCP, Claude gains access to deterministic utilities that complement its language capabilities:

  • Math operations: Precise calculations instead of approximations
  • String operations: Character counting, formatting, encoding
  • Validations: RFC-compliant email, URL, and data validation
  • Conversions: Units, currencies, timezones with exact results
  • Hashing: SHA256, MD5, and other cryptographic operations
Why External Tools? LLMs process text probabilistically, which works great for language but can lead to errors in calculations and counting. TinyFn's deterministic tools guarantee correct results every time.

Setting Up Claude Desktop

Claude Desktop supports MCP servers through a configuration file. Here's how to add TinyFn:

Step 1: Get Your API Key

Sign up at tinyfn.io to get your free API key. The free tier includes 100 requests per month.

Step 2: Locate Your Configuration File

The MCP configuration file location depends on your operating system:

  • macOS: ~/Library/Application Support/Claude/mcp.json
  • Windows: %APPDATA%\Claude\mcp.json
  • Linux: ~/.config/Claude/mcp.json

Step 3: Add TinyFn Configuration

mcp.json
{
  "mcpServers": {
    "tinyfn": {
      "url": "https://api.tinyfn.io/mcp/all/",
      "headers": {
        "X-API-Key": "your-api-key-here"
      }
    }
  }
}

Step 4: Restart Claude Desktop

After saving your configuration, restart Claude Desktop. The TinyFn tools will be automatically discovered and available for use.

Tool Calling Examples

Once connected, Claude will automatically use TinyFn tools when appropriate. Here are some examples:

Math Calculations

User Prompt
What is 127 factorial?

Claude will call the math/factorial tool:

Tool Call
{
  "tool": "math/factorial",
  "parameters": { "n": 127 }
}

String Operations

User Prompt
How many times does the letter 'e' appear in "nevertheless"?
Tool Call
{
  "tool": "string/count-char",
  "parameters": {
    "text": "nevertheless",
    "char": "e"
  }
}

// Result: { "count": 4, "positions": [1, 4, 8, 10] }

Unit Conversions

User Prompt
Convert 98.6 Fahrenheit to Celsius
Tool Call
{
  "tool": "convert/temperature",
  "parameters": {
    "value": 98.6,
    "from": "fahrenheit",
    "to": "celsius"
  }
}

// Result: { "result": 37, "from": "fahrenheit", "to": "celsius" }

Hashing

User Prompt
What's the SHA256 hash of "hello world"?
Tool Call
{
  "tool": "hash/sha256",
  "parameters": { "text": "hello world" }
}

// Result: { "hash": "b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9" }

Claude API Integration

If you're building applications with the Claude API, you can integrate TinyFn tools programmatically:

Python Example

import anthropic
import httpx

client = anthropic.Anthropic()

# Define TinyFn as a tool
tools = [
    {
        "name": "tinyfn_math_factorial",
        "description": "Calculate the factorial of a number",
        "input_schema": {
            "type": "object",
            "properties": {
                "n": {"type": "integer", "description": "The number"}
            },
            "required": ["n"]
        }
    }
]

# Handle tool calls
def call_tinyfn(tool_name, params):
    endpoint = tool_name.replace("tinyfn_", "").replace("_", "/")
    response = httpx.get(
        f"https://api.tinyfn.io/v1/{endpoint}",
        params=params,
        headers={"X-API-Key": "your-api-key"}
    )
    return response.json()

# Use with Claude
response = client.messages.create(
    model="claude-sonnet-4-20250514",
    max_tokens=1024,
    tools=tools,
    messages=[{"role": "user", "content": "What is 20 factorial?"}]
)

# Process tool calls
for block in response.content:
    if block.type == "tool_use":
        result = call_tinyfn(block.name, block.input)
        print(f"Result: {result}")

JavaScript/Node.js Example

import Anthropic from '@anthropic-ai/sdk';

const client = new Anthropic();

const tools = [
  {
    name: "tinyfn_string_count_char",
    description: "Count occurrences of a character in text",
    input_schema: {
      type: "object",
      properties: {
        text: { type: "string" },
        char: { type: "string" }
      },
      required: ["text", "char"]
    }
  }
];

async function callTinyFn(toolName, params) {
  const endpoint = toolName.replace("tinyfn_", "").replace(/_/g, "/");
  const url = new URL(`https://api.tinyfn.io/v1/${endpoint}`);
  Object.entries(params).forEach(([k, v]) => url.searchParams.set(k, v));

  const response = await fetch(url, {
    headers: { "X-API-Key": "your-api-key" }
  });
  return response.json();
}

const response = await client.messages.create({
  model: "claude-sonnet-4-20250514",
  max_tokens: 1024,
  tools,
  messages: [{ role: "user", content: "Count the R's in strawberry" }]
});

// Handle tool use in response
for (const block of response.content) {
  if (block.type === "tool_use") {
    const result = await callTinyFn(block.name, block.input);
    console.log("Result:", result);
  }
}

Best Practices for Claude

Follow these practices to get the best results when using TinyFn with Claude:

1. Use Category-Specific Endpoints

Instead of loading all 500+ tools, use specific category endpoints to reduce token usage:

  • /mcp/math - Math operations only
  • /mcp/string - String operations only
  • /mcp/convert - Unit conversions only
  • /mcp/validate - Validation tools only

2. Be Specific in Prompts

Claude works best when you're clear about what you need:

// Good: Specific and clear
"Calculate the SHA256 hash of the string 'api-key-12345'"

// Less optimal: Vague
"Hash this for me: api-key-12345"

3. Trust Claude's Tool Selection

Claude is excellent at determining when to use tools. It will automatically call TinyFn for operations where precision matters.

4. Review Tool Outputs

For critical applications, verify that Claude correctly interprets and presents the tool output to the user.

Troubleshooting

Tools Not Appearing

  • Verify your mcp.json syntax is valid JSON
  • Check that your API key is correct
  • Ensure Claude Desktop is fully restarted
  • Confirm your API key has remaining quota

Tool Calls Failing

  • Check your network connection
  • Verify the API key in the headers
  • Review the TinyFn status page for any outages

Rate Limiting

The free tier includes 100 requests/month. For higher volumes, upgrade your TinyFn plan. Claude will gracefully handle rate limit responses.

Get Started with Claude + TinyFn

Sign up for a free API key and enhance your Claude experience with deterministic tools.

Get Free API Key

Ready to try TinyFn?

Get your free API key and start building in minutes.

Get Free API Key