Complete reference for the TPMJS SDK packages: @tpmjs/registry-search and @tpmjs/registry-execute.
TPMJS SDK packages
The TPMJS SDK consists of two packages that give your AI agent access to the tool registry:
Search the TPMJS registry to find tools for any task
Execute any tool from the registry in a secure sandbox
npm install @tpmjs/registry-search @tpmjs/registry-executeBoth packages require ai (Vercel AI SDK) and zod as peer dependencies.
npm install ai zod@tpmjs/registry-search
An AI SDK tool that searches the TPMJS registry for tools matching a query.
import { registrySearchTool } from '@tpmjs/registry-search';import { generateText } from 'ai';
import { anthropic } from '@ai-sdk/anthropic';
import { registrySearchTool } from '@tpmjs/registry-search';
const result = await generateText({
model: anthropic('claude-sonnet-4-20250514'),
tools: { registrySearch: registrySearchTool },
prompt: 'Find tools for web scraping',
});| Parameter | Type | Required | Description |
|---|---|---|---|
| query | string | Yes | Search query (keywords, tool names, descriptions) |
| category | string | No | Filter by category |
| limit | number | No | Max results (1-20, default 5) |
interface SearchResult {
query: string;
matchCount: number;
tools: Array<{
toolId: string; // Format: package::name
name: string; // Tool export name
package: string; // npm package name
description: string; // Tool description
category: string; // Tool category
requiredEnvVars: string[]; // Required API keys
healthStatus: 'HEALTHY' | 'UNHEALTHY' | 'UNKNOWN';
qualityScore: number; // 0.00 - 1.00
}>;
}Filter results by category to narrow down your search:
web-scrapingsearch-enginesai-modelsdata-processingcommunicationfile-managementcode-executiondatabasecalendare-commercefinancesocial-mediaweathermapstranslationimage-processingaudio-processingvideo-processingutilitiesother@tpmjs/registry-execute
An AI SDK tool that executes any tool from the TPMJS registry in a secure sandbox.
import { registryExecuteTool } from '@tpmjs/registry-execute';import { generateText } from 'ai';
import { anthropic } from '@ai-sdk/anthropic';
import { registryExecuteTool } from '@tpmjs/registry-execute';
const result = await generateText({
model: anthropic('claude-sonnet-4-20250514'),
tools: { registryExecute: registryExecuteTool },
prompt: 'Execute the hello world tool',
});| Parameter | Type | Required | Description |
|---|---|---|---|
| toolId | string | Yes | Tool identifier in format: package::name |
| params | object | Yes | Parameters to pass to the tool |
| env | object | No | Environment variables (API keys) to pass to the tool |
interface ExecuteResult {
toolId: string; // The executed tool ID
executionTimeMs: number; // Execution time in milliseconds
output: unknown; // Tool output (varies by tool)
}// Direct usage with env parameter
const result = await registryExecuteTool.execute({
toolId: '@firecrawl/ai-sdk::scrapeTool',
params: { url: 'https://example.com' },
env: { FIRECRAWL_API_KEY: process.env.FIRECRAWL_API_KEY },
});Pre-configure API keys for seamless execution
Create a wrapper around registryExecuteTool to automatically inject your API keys:
import { tool } from 'ai';
import { registryExecuteTool } from '@tpmjs/registry-execute';
// Your pre-configured API keys
const API_KEYS: Record<string, string> = {
FIRECRAWL_API_KEY: process.env.FIRECRAWL_API_KEY!,
EXA_API_KEY: process.env.EXA_API_KEY!,
TAVILY_API_KEY: process.env.TAVILY_API_KEY!,
OPENAI_API_KEY: process.env.OPENAI_API_KEY!,
};
// Wrapped tool with pre-configured keys
export const registryExecute = tool({
description: registryExecuteTool.description,
parameters: registryExecuteTool.parameters,
execute: async ({ toolId, params }) => {
return registryExecuteTool.execute({
toolId,
params,
env: API_KEYS,
});
},
});Use the SDK without AI agent integration
Both tools can also be used directly without an AI agent:
import { registrySearchTool } from '@tpmjs/registry-search';
// Search for tools directly
const searchResult = await registrySearchTool.execute({
query: 'web scraping',
limit: 5,
});
console.log('Found tools:', searchResult.tools);import { registryExecuteTool } from '@tpmjs/registry-execute';
// Execute a tool directly
const result = await registryExecuteTool.execute({
toolId: '@tpmjs/hello::helloWorldTool',
params: { name: 'World' },
});
console.log('Result:', result.output);Configure SDK behavior
The SDK supports the following environment variables:
| Variable | Default | Description |
|---|---|---|
| TPMJS_API_URL | https://tpmjs.com | Base URL for the TPMJS registry API |
| TPMJS_EXECUTOR_URL | https://executor.tpmjs.com | URL for the tool executor service |
If you're running your own TPMJS registry, set these environment variables:
# .env
TPMJS_API_URL=https://registry.mycompany.com
TPMJS_EXECUTOR_URL=https://executor.mycompany.comType definitions exported by the SDK
import type {
SearchToolParams,
SearchToolResult,
ToolInfo,
} from '@tpmjs/registry-search';
// SearchToolParams
interface SearchToolParams {
query: string;
category?: string;
limit?: number;
}
// SearchToolResult
interface SearchToolResult {
query: string;
matchCount: number;
tools: ToolInfo[];
}
// ToolInfo
interface ToolInfo {
toolId: string;
name: string;
package: string;
description: string;
category: string;
requiredEnvVars: string[];
healthStatus: 'HEALTHY' | 'UNHEALTHY' | 'UNKNOWN';
qualityScore: number;
}import type {
ExecuteToolParams,
ExecuteToolResult,
} from '@tpmjs/registry-execute';
// ExecuteToolParams
interface ExecuteToolParams {
toolId: string;
params: Record<string, unknown>;
env?: Record<string, string>;
}
// ExecuteToolResult
interface ExecuteToolResult {
toolId: string;
executionTimeMs: number;
output: unknown;
}Handle errors from the SDK
Both SDK tools throw errors that can be caught and handled:
import { registryExecuteTool } from '@tpmjs/registry-execute';
try {
const result = await registryExecuteTool.execute({
toolId: '@firecrawl/ai-sdk::scrapeTool',
params: { url: 'https://example.com' },
env: { FIRECRAWL_API_KEY: process.env.FIRECRAWL_API_KEY },
});
console.log('Success:', result);
} catch (error) {
if (error instanceof Error) {
console.error('Tool execution failed:', error.message);
// Common error types:
// - "Tool not found: ..." - Invalid toolId
// - "Missing required env var: ..." - API key not provided
// - "Execution timeout" - Tool took too long
// - "Sandbox error: ..." - Tool runtime error
}
}Full agent implementation with both tools
import { streamText, tool } from 'ai';
import { anthropic } from '@ai-sdk/anthropic';
import { registrySearchTool } from '@tpmjs/registry-search';
import { registryExecuteTool } from '@tpmjs/registry-execute';
// Pre-configure API keys
const API_KEYS: Record<string, string> = {
FIRECRAWL_API_KEY: process.env.FIRECRAWL_API_KEY || '',
EXA_API_KEY: process.env.EXA_API_KEY || '',
};
// Wrapped execute tool with pre-configured keys
const registryExecute = tool({
description: registryExecuteTool.description,
parameters: registryExecuteTool.parameters,
execute: async ({ toolId, params }) => {
return registryExecuteTool.execute({ toolId, params, env: API_KEYS });
},
});
// System prompt that guides the agent
const systemPrompt = `You are a helpful assistant with access to thousands of tools.
To complete tasks, follow this workflow:
1. Use registrySearch to find relevant tools
2. Review the search results and pick the best tool
3. Use registryExecute to run the tool with appropriate parameters
4. Synthesize the results into a helpful response
Always explain what you're doing and why.`;
// Main function
async function runAgent(userPrompt: string) {
const result = await streamText({
model: anthropic('claude-sonnet-4-20250514'),
tools: {
registrySearch: registrySearchTool,
registryExecute,
},
maxSteps: 10,
system: systemPrompt,
prompt: userPrompt,
});
// Stream the response
for await (const chunk of result.textStream) {
process.stdout.write(chunk);
}
console.log('\n---');
console.log('Tool calls:', (await result.toolCalls).length);
}
// Usage
await runAgent('Find a web scraping tool and scrape https://example.com');Get started in 5 minutes
REST API for the registry
API key management
Source code and issues