BREAKING CHANGE: Complete refactoring from single-tool to multi-tool package support Database Schema: - Split Tool model into Package (1) and Tool (many) with one-to-many relationship - Package stores npm metadata and package-level tpmjs fields (category, env, frameworks, tier) - Tool stores individual tool exports with tool-level metadata (exportName, description, parameters, returns, aiAgent) - Unique constraint on (packageId, exportName) to prevent duplicate tools - Cascade deletes when packages are removed Type System: - Updated tpmjs field schema to support tools array - Each tool has exportName, description, parameters, returns, aiAgent - Package-level fields: category, env, frameworks shared across all tools - Backward compatible with legacy single-tool format (auto-migrates to exportName: "default") API Updates: - Updated all /api/tools routes to query Tool model with Package relations - Updated /api/tools/[slug] to accept package/export path segments - Updated tool-executor-agent to use actual exportName instead of hardcoded "default" - Updated metrics sync to calculate quality scores per Tool Frontend Updates: - Updated tool search page to display exportName as primary heading - Updated tool detail pages to show package name as secondary info - Removed tag-based filtering (tags moved to package level) Manual Tool Registry: - Added manual-tools.ts with 23 curated tools from major providers - Created sync-manual-tools.ts script to sync manual tools to database - Added MANUAL_TOOLS.md documentation for manual tool system - Added GitHub workflow for automated daily sync - Includes tools from: Vercel, Exa, Firecrawl, AWS Bedrock, Perplexity, Tavily, Superagent, Valyu Playground Updates: - Updated tool loader to load multiple tools per package - Added sanitizeToolName for OpenAI API compatibility Sync System Updates: - Updated changes feed sync to handle multi-tool packages - Updated keyword sync to upsert multiple tools per package - Added orphaned tool deletion when tools removed from package.json Migration Strategy: - Database uses same Neon instance for dev and prod - Schema updated via prisma db push (no migration files yet) - All data repopulates from npm via sync system 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
8 KiB
Manual Tools Registry
Overview
This system allows TPMJS to include high-quality tools that don't follow the standard tpmjs field specification in their package.json. These tools are manually curated and synced to the database.
Why Manual Tools?
Some excellent tools (like Vercel's code execution, Exa search, Firecrawl, etc.) don't include the tpmjs field in their package.json. Rather than wait for these package maintainers to adopt the spec, we manually curate metadata for these tools.
Architecture
Files
manual-tools.ts- The registry of manually curated toolssync-manual-tools.ts- Script to sync manual tools to databaseMANUAL_TOOLS.md- This documentation
How It Works
-
Manual Tool Registry (
manual-tools.ts)- Exports a
manualToolsarray with metadata for each tool - Each entry includes npm package name, export name, category, description, parameters, etc.
- Follows the same schema as the standard
tpmjsfield
- Exports a
-
Sync Script (
sync-manual-tools.ts)- Fetches latest package metadata from npm
- Combines npm metadata with manual metadata
- Upserts Package + Tool records to database
- Marks tools with
discoveryMethod: 'manual'
-
Database Storage
- Manual tools stored in same
packagesandtoolstables as auto-discovered tools - No special handling needed in API or frontend
discoveryMethod: 'manual'field distinguishes them
- Manual tools stored in same
Adding a New Manual Tool
Step 1: Add to Registry
Edit manual-tools.ts and add a new entry:
{
npmPackageName: 'example-package',
category: 'search',
frameworks: ['vercel-ai'],
exportName: 'exampleTool',
description: 'A clear, concise description of what this tool does',
// Optional but recommended for 'rich' tier
parameters: [
{
name: 'query',
type: 'string',
description: 'The search query',
required: true,
},
],
returns: {
type: 'array',
description: 'Array of search results',
},
aiAgent: {
useCase: 'Use when you need to search for X',
limitations: 'Rate limits apply',
examples: [
'Search for current news',
'Find specific information',
],
},
// Environment variables
env: [
{
name: 'EXAMPLE_API_KEY',
description: 'API key for the service',
required: true,
},
],
// Additional metadata
tags: ['search', 'web'],
docsUrl: 'https://example.com/docs',
apiKeyUrl: 'https://example.com/api-keys',
websiteUrl: 'https://example.com',
}
Step 2: Run Sync Script
# From repository root
pnpm tsx sync-manual-tools.ts
This will:
- Fetch the package from npm
- Create/update Package record
- Create/update Tool record(s)
- Set
discoveryMethod: 'manual'
Step 3: Verify
Check that the tool appears on tpmjs.com:
# Start dev server
pnpm dev --filter=@tpmjs/web
# Visit http://localhost:3000/tool/tool-search
# Search for your package name
Multi-Tool Packages
If a package exports multiple tools, add multiple entries with the same npmPackageName but different exportName:
{
npmPackageName: 'firecrawl-aisdk',
exportName: 'scrapeTool',
description: 'Scrape websites...',
// ...
},
{
npmPackageName: 'firecrawl-aisdk',
exportName: 'searchTool',
description: 'Search the web...',
// ...
},
{
npmPackageName: 'firecrawl-aisdk',
exportName: 'crawlTool',
description: 'Crawl entire websites...',
// ...
},
Tier Calculation
Tools are automatically assigned a tier:
- Rich tier: Has
parametersORreturnsORaiAgentfields - Minimal tier: Only has basic metadata
Rich tier tools get 4x quality score multiplier, so add detailed metadata when possible.
Maintenance
Updating Manual Tools
- Edit the entry in
manual-tools.ts - Run
pnpm tsx sync-manual-tools.ts - The upsert will update existing records
Removing Manual Tools
- Remove the entry from
manual-tools.ts - Manually delete from database OR wait for metrics sync to mark as stale
Version Updates
The sync script automatically fetches the latest version from npm unless you specify npmVersion in the manual tool entry.
Production Deployment
Option 1: Manual Sync on Deploy
Add to your deployment workflow:
# .github/workflows/deploy.yml
- name: Sync manual tools
run: pnpm tsx sync-manual-tools.ts
env:
DATABASE_URL: ${{ secrets.DATABASE_URL }}
Option 2: Scheduled Sync
Create a cron job or GitHub Action to sync periodically:
# .github/workflows/sync-manual.yml
name: Sync Manual Tools
on:
schedule:
- cron: '0 0 * * 0' # Weekly on Sunday
workflow_dispatch: # Manual trigger
jobs:
sync:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v2
- uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'pnpm'
- run: pnpm install
- run: pnpm tsx sync-manual-tools.ts
env:
DATABASE_URL: ${{ secrets.DATABASE_URL }}
Option 3: API Endpoint
Create a sync endpoint (similar to keyword/changes sync):
// apps/web/src/app/api/sync/manual/route.ts
import { manualTools } from '@/manual-tools';
// ... sync logic
export async function POST(request: Request) {
// Verify CRON_SECRET
// Run manual sync
// Return results
}
Currently Included Manual Tools
As of this documentation:
- ai-sdk-tool-code-execution - Vercel Sandbox code execution
- @exalabs/ai-sdk - Exa web search
- @parallel-web/ai-sdk-tools - Parallel search and extraction (2 tools)
- ctx-zip - MCP + Vercel Sandbox integration
- @perplexity-ai/ai-sdk - Perplexity search
- @tavily/ai-sdk - Tavily web research
- firecrawl-aisdk - Firecrawl scraping, search, crawling (3 tools)
- bedrock-agentcore - AWS Bedrock code interpreter and browser (2 tools)
- @superagent-ai/ai-sdk - Superagent security tools (3 tools)
- @valyu/ai-sdk - Valyu domain-specific search tools (8 tools)
Total: 24 manually curated tools across 10 packages
FAQ
Why not just ask package maintainers to add the tpmjs field?
We should! But:
- Some packages are from large companies (Vercel, AWS, etc.) with slow adoption cycles
- We want these tools available on TPMJS now
- Manual curation lets us provide better metadata than package authors might
Will manual tools be replaced by auto-discovered ones?
Yes! If a package adds a proper tpmjs field, the auto-discovery sync will update it with discoveryMethod: 'keyword' or 'changes-feed'. Manual entries can then be removed from manual-tools.ts.
Can I mix manual and auto-discovered tools from the same package?
Yes. If a package has some tools in the tpmjs field but is missing others, you can manually add the missing ones. The sync scripts will coexist peacefully.
How do I know if a tool is manually curated?
Check the discoveryMethod field in the database:
'manual'= Manually curated'keyword'= Auto-discovered via keyword search'changes-feed'= Auto-discovered via npm changes feed
Best Practices
- Complete Metadata - Provide as much metadata as possible for rich tier
- Accurate Descriptions - Tool descriptions should be clear and specific
- AI-Friendly - Write
aiAgent.useCaseas guidance for LLMs - Keep Updated - Periodically check if packages have added native
tpmjssupport - Link to Docs - Always include
docsUrlwhen available - API Key URLs - Include
apiKeyUrlfor tools requiring authentication
Contributing
To contribute new manual tools:
- Fork the repository
- Add your tool to
manual-tools.ts - Test with
pnpm tsx sync-manual-tools.ts - Open a pull request with:
- Why this tool should be included
- Link to the npm package
- Screenshot of it working in TPMJS
Related Documentation
- HOW_TO_PUBLISH_A_TOOL.md - Standard tpmjs field spec
- CLAUDE.md - General project documentation
- packages/types/src/tpmjs.ts - TypeScript schema definitions