Programmatic Tool Calling

v1.0.0Developer Toolsstable

⚡ Cut LLM inference costs 80% with Programmatic Tool Calling. Instead of N tool call round-trips, generate JavaScript to orchestrate tools in Vercel Sandbox. Supports Anthropic, OpenAI, 100+ models via AI Gateway. Novel MCP Bridge for external servic

ai-elementsai-gatewayai-sdkllm-optimizationmcp-client
Share:
17
Stars
0
Downloads
0
Weekly
0/5

What is Programmatic Tool Calling?

Programmatic Tool Calling is a Model Context Protocol (MCP) server that allows AI assistants like Claude, Cursor, and VS Code to ⚡ cut llm inference costs 80% with programmatic tool calling. instead of n tool call round-trips, generate javascript to orchestrate tools in vercel sandbox. supports anthropic, openai, 100+ models vi...

⚡ Cut LLM inference costs 80% with Programmatic Tool Calling. Instead of N tool call round-trips, generate JavaScript to orchestrate tools in Vercel Sandbox. Supports Anthropic, OpenAI, 100+ models via AI Gateway. Novel MCP Bridge for external servic

This server falls under the Developer Tools category on MCPgee, the world's largest MCP server directory with 33,000+ servers.

Features

  • ⚡ Cut LLM inference costs 80% with Programmatic Tool Calling

Use Cases

Reduce LLM inference costs by 80% using orchestrated tool calls.
Generate JavaScript to orchestrate multiple tools in one step.
Support multiple AI models and providers through a unified interface.
cameronking4

Maintainer

LicenseMIT
Languagetypescript
Versionv1.0.0
UpdatedMay 12, 2026
Statushealthy
Maintenanceactive

Works with

ClaudeOpenAIwindowsmacoslinux

Installation

Manual Installation

npx programmatic-tool-calling-ai-sdk

Configuration

Configuration Details

Config File

claude_desktop_config.json

Performance

Response Metrics

Response Time< 200ms
ThroughputMedium

Resource Usage

Memory UsageLow
CPU UsageLow

How to Set Up and Use Programmatic Tool Calling

Programmatic Tool Calling AI SDK is a developer framework that dramatically reduces LLM inference costs by replacing sequential tool-call round-trips with generated JavaScript that orchestrates multiple tools in a single Vercel Sandbox execution. Instead of the model making N separate tool calls (each requiring a new inference round-trip), it generates a small program that runs all the logic at once, cutting token usage by roughly 80% and latency by 3-5x. It supports 100+ models via Vercel AI Gateway and includes an MCP Bridge for connecting external MCP servers.

Prerequisites

  • Node.js 18 or higher installed
  • A Vercel account for Sandbox execution (free tier available)
  • At least one AI provider API key: ANTHROPIC_API_KEY or OPENAI_API_KEY
  • Familiarity with the Vercel AI SDK (ai package)
  • An MCP-compatible client if using the MCP server mode
1

Install the package and peer dependencies

Install the programmatic tool calling library along with the Vercel AI SDK and Zod for schema validation. These are required peer dependencies.

npm install @task-orchestrator/programmatic-tools ai@^5.0.0 @vercel/sandbox@^1.0.0 zod@^3.0.0
2

Set environment variables

Create a .env file with your AI provider credentials and Vercel token for sandbox execution. At least one AI provider key is required; VERCEL_TOKEN enables isolated code execution in Vercel Sandbox.

ANTHROPIC_API_KEY=sk-ant-...
OPENAI_API_KEY=sk-...
VERCEL_TOKEN=your_vercel_token
# Optional: AI Gateway
AI_GATEWAY_API_KEY=your_gateway_api_key
3

Wrap your tools with programmatic calling

Use the withProgrammaticCalling wrapper around your existing tool definitions. This intercepts tool calls and generates JavaScript to orchestrate them in one pass instead of sequential round-trips.

import { withProgrammaticCalling } from '@task-orchestrator/programmatic-tools';
import { tool } from 'ai';
import { z } from 'zod';

const myTools = {
  getUser: tool({
    description: 'Retrieve user information',
    inputSchema: z.object({ id: z.string() }),
    execute: async ({ id }) => ({ id, name: `User ${id}` }),
  }),
};

const { tools } = withProgrammaticCalling(myTools);
4

Stream results with the Vercel AI SDK

Pass the wrapped tools to streamText just as you would normal tools. The SDK handles code generation, sandbox execution, and result parsing transparently.

import { streamText } from 'ai';
import { anthropic } from '@ai-sdk/anthropic';

const result = await streamText({
  model: anthropic('claude-3-5-sonnet-20241022'),
  tools,
  messages: [{ role: 'user', content: 'Get users 1 through 5 and summarize them' }],
});
5

Optionally enable MCP Bridge

To connect external MCP servers as tool sources, install the MCP adapter and configure the transports (HTTP, SSE, or Stdio). This lets any MCP-compatible server's tools be called programmatically.

npm install @ai-sdk/mcp@^0.0.11
6

Add to MCP client configuration

If you want to expose the programmatic tool calling server as an MCP server itself, add it to your claude_desktop_config.json.

{
  "mcpServers": {
    "programmatic-tool-calling": {
      "command": "npx",
      "args": ["programmatic-tool-calling-ai-sdk"],
      "env": {
        "ANTHROPIC_API_KEY": "sk-ant-...",
        "VERCEL_TOKEN": "your_vercel_token"
      }
    }
  }
}

Programmatic Tool Calling Examples

Client configuration

Add this to claude_desktop_config.json to run the MCP server with Anthropic and Vercel credentials.

{
  "mcpServers": {
    "programmatic-tool-calling": {
      "command": "npx",
      "args": ["programmatic-tool-calling-ai-sdk"],
      "env": {
        "ANTHROPIC_API_KEY": "sk-ant-YOUR_KEY",
        "VERCEL_TOKEN": "your_vercel_token"
      }
    }
  }
}

Prompts to try

Prompts that benefit most from programmatic tool calling — tasks that would normally require many sequential tool calls.

- "Fetch user profiles for IDs 1 through 10 and return a summary table"
- "Look up inventory for all 20 product SKUs and flag any below threshold"
- "Run these 5 database queries in parallel and join the results"
- "Check the status of all open GitHub issues and group them by label"

Troubleshooting Programmatic Tool Calling

Sandbox execution fails with authentication error

Verify your VERCEL_TOKEN is set correctly and belongs to an account with Sandbox access. Generate a new token at vercel.com/account/tokens if needed, and ensure it has the correct scope.

Generated JavaScript throws ReferenceError at runtime

Ensure all tool execute functions are pure and do not rely on external closures or Node.js globals unavailable in the Vercel Sandbox environment. Tools must be self-contained with explicit imports or dependencies passed through parameters.

No cost savings observed compared to normal tool calling

Programmatic calling benefits are largest when multiple tool calls are needed in one user turn. For single-tool tasks, the overhead of code generation may negate savings. Check that your prompts ask for work that requires 3 or more tool invocations.

Frequently Asked Questions about Programmatic Tool Calling

What is Programmatic Tool Calling?

Programmatic Tool Calling is a Model Context Protocol (MCP) server that ⚡ cut llm inference costs 80% with programmatic tool calling. instead of n tool call round-trips, generate javascript to orchestrate tools in vercel sandbox. supports anthropic, openai, 100+ models via ai gateway. novel mcp bridge for external servic It connects AI assistants to external tools and data sources through a standardized interface.

How do I install Programmatic Tool Calling?

Follow the installation instructions on the Programmatic Tool Calling GitHub repository. Clone the repo, install dependencies, and add the server config to your AI client.

Which AI clients work with Programmatic Tool Calling?

Programmatic Tool Calling works with all major MCP-compatible AI clients including Claude Desktop, Claude Code, Cursor, VS Code (GitHub Copilot), Windsurf, and Cline.

Is Programmatic Tool Calling free to use?

Yes, Programmatic Tool Calling is open source and available under the MIT license. You can use it freely in both personal and commercial projects.

Browse More Developer Tools MCP Servers

Explore all developer tools servers available in the MCPgee directory. Each server includes setup guides for Claude, Cursor, and VS Code.

Quick Config Preview

{ "mcpServers": { "programmatic-tool-calling-ai-sdk": { "command": "npx", "args": ["-y", "programmatic-tool-calling-ai-sdk"] } } }

Add this to your claude_desktop_config.json or .cursor/mcp.json

Read the full setup guide →

Ready to use Programmatic Tool Calling?

Browse our complete directory of 33,000+ MCP servers, read setup guides for your editor, and start building with the Model Context Protocol.

33,000+ ServersFree & Open SourceStep-by-Step Guides