DocsBuilding ToolsBest Practices

Best Practices for Tool Builders


  1. Security
    • If you’re gating access to sensitive data or paid usage, ensure your gating logic is correct and secure.
    • Keep private keys secure if your server signs messages or interacts with on-chain data.
  2. Scalability
    • Tools that become popular with AI agents might see sudden spikes in requests. Use serverless or containerized hosting that can auto-scale.
    • Monitor usage carefully; consider caching or rate-limiting if needed.
  3. Rate-Limiting
    • Even if you’re gating by token balance, you may want to throttle calls to protect your backend from abuse.
    • The @strawberryprotocol/str-toolserver library can help integrate basic or advanced rate-limiting strategies.
  4. Documentation
    • Update your server.setRequestHandler(ListToolsRequestSchema, ...) with clear descriptions and input schemas. This ensures AI agents can interpret your tool’s parameters easily.
  5. Logging & Metrics
    • Track request volumes, token usage, and error rates. This helps you diagnose issues, plan capacity, and refine your gating thresholds.
  6. Future Enhancements
    • Consider migrating from a hold-to-use gating approach to metered billing if your tool has a high per-call cost or valuable data.
    • Keep an eye on the Strawberry roadmap for new contract features around pay-per-request and other types of transactions.