The Model Context Protocol (MCP) supports both API-based tools (like TinyFn) and local tool servers. Each approach has advantages. This guide helps you understand when to use each and how to combine them effectively.
API-Based Tools Explained
API-based MCP tools run on remote servers. Your MCP client (Claude Desktop, Cursor, etc.) connects to these servers over HTTPS. TinyFn is an example of an API-based tool provider.
How It Works
┌─────────────────┐ HTTPS ┌─────────────────┐
│ │ ──────────────► │ │
│ MCP Client │ │ TinyFn API │
│ (Your Device) │ ◄────────────── │ (Cloud) │
│ │ JSON │ │
└─────────────────┘ └─────────────────┘
1. Client discovers tools from API
2. AI decides to use a tool
3. Client sends request to API
4. API returns deterministic result
5. AI incorporates result in response
Configuration
{
"mcpServers": {
"tinyfn": {
"url": "https://api.tinyfn.io/mcp/all/",
"headers": {
"X-API-Key": "your-api-key"
}
}
}
}
Advantages
- Zero setup: Just add configuration and API key
- Always updated: New tools and improvements automatically available
- No maintenance: Provider handles reliability and scaling
- Cross-platform: Works on any device with internet
- Professional implementation: Tested, RFC-compliant, production-ready
Considerations
- Network dependency: Requires internet connection
- Latency: Network round-trip adds milliseconds
- Cost: May have usage-based pricing
- Data transit: Input data travels over network
Local Tools Explained
Local MCP tools run on your machine or within your infrastructure. You host and maintain the tool server yourself.
How It Works
┌─────────────────┐ localhost ┌─────────────────┐
│ │ ──────────────► │ │
│ MCP Client │ │ Local Server │
│ (Your Device) │ ◄────────────── │ (Your Device) │
│ │ JSON │ │
└─────────────────┘ └─────────────────┘
1. You run local MCP server
2. Client connects via localhost/socket
3. Tool execution happens locally
4. No network latency
5. Works offline
Configuration
{
"mcpServers": {
"local-filesystem": {
"command": "node",
"args": ["/path/to/local-server.js"],
"env": {
"HOME_DIR": "/Users/developer"
}
}
}
}
Advantages
- Offline capable: Works without internet
- Low latency: No network round-trip
- Data stays local: Sensitive data never leaves your machine
- System access: Can access filesystem, databases, local services
- No usage costs: Run as much as you want
Considerations
- Setup required: Must install and configure server
- Maintenance: You handle updates and bug fixes
- Implementation quality: Depends on your implementation
- Resource usage: Uses local CPU/memory
Side-by-Side Comparison
| Aspect | API Tools (TinyFn) | Local Tools |
|---|---|---|
| Setup time | Minutes | Hours to days |
| Maintenance | None (provider handles) | Ongoing |
| Latency | 10-100ms | 1-10ms |
| Offline | No | Yes |
| Data privacy | Data transits network | Data stays local |
| System access | No | Yes |
| Tool quality | Professional, tested | Varies |
| Tool variety | 500+ (TinyFn) | What you build |
| Cost | Free tier + paid plans | Your time + resources |
When to Use TinyFn (API)
API-based tools like TinyFn are ideal for these scenarios:
Standard Utilities
For math, hashing, validation, encoding, and other standard operations, TinyFn provides tested, maintained implementations:
// Why implement these yourself?
// TinyFn provides 500+ utilities including:
math/factorial // Arbitrary precision
math/prime-check // Optimized algorithm
hash/sha256 // Cryptographically correct
validate/email // RFC 5321/5322 compliant
convert/temperature // Exact conversion factors
encode/base64 // Standard encoding
datetime/timezone // DST-aware conversions
stats/percentile // Statistical accuracy
Team Environments
When multiple developers need the same tools:
- Everyone configures the same TinyFn endpoint
- Consistent tool behavior across team members
- No "works on my machine" issues
- Onboarding is just adding an API key
Quick Prototyping
When you need tools fast and don't want to build infrastructure:
// Start using 500+ tools in 2 minutes:
1. Sign up at tinyfn.io (free)
2. Get API key
3. Add to MCP config
4. Restart your MCP client
5. Done - all tools available
Compliance Requirements
When you need audit trails and documented tool behavior:
- TinyFn provides deterministic, reproducible results
- All tools are documented with exact specifications
- Results can be independently verified
- Suitable for regulated industries
When to Use Local Tools
Local MCP tools are better suited for these scenarios:
Filesystem Operations
Reading/writing files, directory operations, file search:
// Local tool can access your filesystem
const tools = {
"read_file": {
description: "Read contents of a local file",
handler: async ({ path }) => {
return fs.readFileSync(path, 'utf8');
}
},
"list_directory": {
description: "List files in a directory",
handler: async ({ path }) => {
return fs.readdirSync(path);
}
}
};
Database Access
Querying local or private databases:
// Local tool can access your databases
const tools = {
"query_customers": {
description: "Search customer database",
handler: async ({ query }) => {
return db.query('SELECT * FROM customers WHERE name LIKE ?',
[`%${query}%`]);
}
}
};
Offline Environments
When internet access is unavailable or unreliable:
- Air-gapped systems
- Airplane mode development
- Areas with poor connectivity
Sensitive Data Processing
When data absolutely cannot leave your machine:
- Medical records
- Classified information
- Proprietary algorithms
- Customer PII in strict compliance environments
High-Frequency Operations
When you need sub-millisecond latency or very high throughput:
// For most use cases, API latency is fine:
API tool call: ~20-50ms typical
Local tool call: ~1-5ms typical
// For high-frequency scenarios:
10,000 calls via API: ~500 seconds (with rate limits)
10,000 calls locally: ~30 seconds
// But for typical AI assistant use:
// A few tool calls per conversation - API latency is negligible
Hybrid Approaches
Most production deployments benefit from combining API and local tools. Here's how to architect a hybrid setup:
Configuration
{
"mcpServers": {
// API tools for standard utilities
"tinyfn": {
"url": "https://api.tinyfn.io/mcp/all/",
"headers": {
"X-API-Key": "your-api-key"
}
},
// Local tools for system access
"local-fs": {
"command": "node",
"args": ["./tools/filesystem-server.js"]
},
// Local tools for database access
"local-db": {
"command": "python",
"args": ["./tools/database-server.py"]
}
}
}
Tool Routing Strategy
┌─────────────────────────────────────────────────────────────┐
│ Your AI Application │
├─────────────────────────────────────────────────────────────┤
│ │
│ ┌─────────────────────┐ ┌─────────────────────┐ │
│ │ TinyFn (API) │ │ Local Tools │ │
│ ├─────────────────────┤ ├─────────────────────┤ │
│ │ ✓ Math operations │ │ ✓ File operations │ │
│ │ ✓ Hashing/encoding │ │ ✓ Database queries │ │
│ │ ✓ Validations │ │ ✓ System commands │ │
│ │ ✓ Conversions │ │ ✓ Local APIs │ │
│ │ ✓ Formatting │ │ ✓ Sensitive data │ │
│ │ ✓ Statistics │ │ ✓ Offline ops │ │
│ └─────────────────────┘ └─────────────────────┘ │
│ │
└─────────────────────────────────────────────────────────────┘
Fallback Patterns
For resilience, implement fallbacks for critical tools:
// Local server with TinyFn fallback
const localTools = {
"calculate_hash": {
description: "Calculate SHA256 hash",
handler: async ({ text }) => {
try {
// Try local first
const crypto = require('crypto');
return crypto.createHash('sha256').update(text).digest('hex');
} catch (err) {
// Fallback to TinyFn if local fails
const response = await fetch(
'https://api.tinyfn.io/v1/hash/sha256?text=' +
encodeURIComponent(text),
{ headers: { 'X-API-Key': TINYFN_KEY } }
);
return (await response.json()).hash;
}
}
}
};
Real-World Hybrid Example
Here's how a development team might configure their hybrid setup:
// Team-shared configuration
{
"mcpServers": {
// Standard utilities - same for everyone
"tinyfn": {
"url": "https://api.tinyfn.io/mcp/all/",
"headers": { "X-API-Key": "${TINYFN_API_KEY}" }
},
// Project-specific database access
"project-db": {
"command": "docker",
"args": ["exec", "project-db-tools", "node", "server.js"],
"env": {
"DB_HOST": "localhost",
"DB_NAME": "project_dev"
}
},
// Developer-specific file access
"workspace": {
"command": "npx",
"args": ["@anthropic/mcp-filesystem", "${WORKSPACE_PATH}"]
}
}
}
// Benefits:
// - TinyFn: Zero-maintenance utilities for everyone
// - project-db: Team shares same database tools
// - workspace: Each dev has their own file access
Start with the Easy Win
Add TinyFn for instant access to 500+ deterministic tools. Build local tools only for what TinyFn can't do.
Get Free API Key