claude-code-api-tools

Implement Anthropic tool_use and tool_result compatibility for Claude Code gateway servers.

4|1|Updated Apr 29, 2026
One-click install
npx skills add https://github.com/ZipperCode/lingma2api --skill claude-code-api-tools-zippercode
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: claude-code-api-tools
Source: https://github.com/ZipperCode/lingma2api/tree/main/.claude/skills/claude-code-api-tools
Command: npx skills add https://github.com/ZipperCode/lingma2api --skill claude-code-api-tools-zippercode

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Building an OpenAI-compatible or Anthropic-compatible gateway that works with Claude Code requires correctly handling tool schemas, streaming tool_use blocks, and tool_result messages; this Skill provides the exact wire-format rules so the gateway interoperates with Claude Code without protocol errors. ## Core Features & Use Cases - Tool Schema Handling: Parse incoming tools arrays and tool_choice from /v1/messages, preserving tool names (including MCP-style mcp__server__tool names) and tolerating extension fields like strict, defer_loading, and cache_control. - Streaming tool_use Emission: Emit Anthropic SSE events (content_block_start, input_json_delta, content_block_stop) with valid JSON fragments and stop_reason: tool_use, plus non-streaming equivalents. - tool_result Round-Trip: Accept tool_result content blocks in follow-up user messages and forward them to the upstream model, matching tool_use_id values. - Use Case: When a Claude Code client sends a Bash tool definition to your gateway, convert it for the upstream model, stream back a well-formed tool_use block, and correctly route the client's tool_result on the next turn. ## Quick Start Ask the AI to implement tool-call compatibility in the gateway's /v1/messages handler following this Skill's protocol rules.

Frequently Asked Questions about claude-code-api-tools

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I stream Anthropic tool_use blocks from a gateway?

Emit content_block_start with type tool_use, then send the input as input_json_delta events containing partial_json string fragments, followed by content_block_stop and a message_delta with stop_reason tool_use. The concatenated partial_json must form a valid JSON object.

How to handle tool_result messages in a Claude Code gateway?

Claude Code sends tool_result blocks in the next user message with a tool_use_id matching the earlier tool_use id. The gateway forwards these results to the upstream model as the tool execution output and should accept content as either a string or content block array.

Does the gateway need to execute tools for Claude Code?

No, the gateway never executes tools. Claude Code runs tools locally on the client side; the gateway only lets the model request tool calls via tool_use blocks and reads the tool_result in the following turn.

Can I convert OpenAI function calls to Anthropic tool_use format?

Yes, when the upstream model returns an OpenAI-style function call, the gateway converts it into an Anthropic tool_use block with matching name and input. If the arguments are not valid JSON, return a 502 or synthesized text error instead of malformed input_json_delta.

What are MCP tool names like mcp__server__tool in requests?

MCP tool names follow the format mcp__<server_name>__<tool_name>, with hyphens in server names typically converted to underscores. The gateway treats them as ordinary tool names without connecting to any MCP server or splitting the name.

Should defer_loading tools be handled differently by the gateway?

A minimal gateway can ignore defer_loading and pass the tool to the upstream model as a normal tool. The field indicates the full schema may be loaded later via a ToolSearch workflow, but it must not cause an error.