Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[FEAT] Make tools into custom Endpoints #638

@fav-devs

Description

@fav-devs

Is your feature request related to a problem? Please describe.

Currently, VoltAgent tools can only be invoked through agent conversations. There's no built-in way to call tools directly as REST API endpoints without going through the agent chat flow. Problem scenarios:
When building frontend applications, developers need to call specific tools (like web_search, generate_drafts, get_user_context) directly via HTTP without triggering a full agent conversation
Microservice architectures require direct tool invocation for service-to-service communication
Testing tools in isolation requires manual wrapping of each tool in custom endpoints
Third-party integrations need standardized REST endpoints to call specific tool functionality

Current workaround: Developers must manually wrap each tool in a custom endpoint using configureApp:
configureApp: (app) => {
app.post("/api/tools/web-search", async (c) => {
const { query, count } = await c.req.json();
const result = await webSearchTool.execute({ query, count }, context);
return c.json(result);
});
// Repeat for every tool...
}

Describe alternatives you've considered

Add automatic REST API endpoint generation for all registered tools, similar to how agents are exposed via /agents/{id}/chat. Proposed API structure:
POST /tools/{toolName}/execute
Example request:
curl -X POST http://localhost:3141/tools/web_search/execute
-H "Authorization: Bearer "
-H "Content-Type: application/json"
-d '{
"input": {
"query": "latest AI news",
"count": 5
},
"context": {
"userId": "user-123",
"tenantId": "tenant-456"
}
}'
Example response:
{
"toolName": "web_search",
"success": true,
"result": {
"query": "latest AI news",
"count": 5,
"results": [...]
},
"executionTime": 234
}
Configuration:
new VoltAgent({
agents: { myAgent },
server: honoServer({
enableSwaggerUI: true,
exposeTools: true, // <-- NEW: Auto-generate tool endpoints
toolsConfig: {
prefix: "/tools", // Optional: custom prefix
requireAuth: true, // Optional: require JWT auth
allowedTools: ["web_search", "generate_drafts"], // Optional: whitelist
}
}),
});

Additional context

No response

Describe the thing to improve

Current State: VoltAgent tools are designed to be called by AI agents during conversations. There's no native way to expose these tools as standalone REST API endpoints for direct invocation. What needs improvement:
Tool accessibility: Tools should be accessible both through agent conversations AND as direct API endpoints
Automatic endpoint generation: VoltAgent should auto-generate REST endpoints for registered tools (similar to how it exposes agent chat endpoints)
Configuration flexibility: Developers should be able to choose which tools to expose, authentication requirements, and endpoint prefixes
Documentation integration: Tool endpoints should automatically appear in Swagger UI with proper schemas
What I would like to see: 1. Auto-generated tool endpoints:
// When you create tools
const webSearchTool = createTool({
name: "web_search",
description: "Search the web",
parameters: z.object({ query: z.string(), count: z.number() }),
execute: async ({ query, count }) => { /* ... */ }
});

// They automatically become available at:
// POST /tools/web_search/execute
2. Configuration options in VoltAgent server:
new VoltAgent({
agents: { myAgent },
tools: {
web_search: webSearchTool,
generate_drafts: generateDraftsTool,
// ... more tools
},
server: honoServer({
enableSwaggerUI: true,
toolsEndpoints: {
enabled: true, // Enable tool endpoints
prefix: "/tools", // URL prefix
requireAuth: true, // Require JWT
allowedTools: ["web_search"], // Optional whitelist
exposeInSwagger: true, // Show in Swagger UI
}
}),
});
3. Standardized request/response format:
// Request
POST /tools/web_search/execute
{
"input": { "query": "AI news", "count": 5 },
"context": { "userId": "123", "tenantId": "456" }
}

// Response
{
"toolName": "web_search",
"success": true,
"result": { /* tool output */ },
"executionTime": 234,
"timestamp": "2025-09-29T12:00:00Z"
}
4. Swagger UI integration:
Tools appear in a dedicated "Tools" section
Input/output schemas auto-generated from Zod
"Try it out" functionality for testing
Authentication configuration visible
Benefits this would provide:
✅ Direct tool invocation without LLM overhead
✅ Reduced latency and cost for simple operations
✅ Better microservice architecture support
✅ Easier testing and debugging
✅ Consistent API patterns across the framework
✅ Less boilerplate code for developers
✅ Frontend-friendly REST APIs
✅ Standard OpenAPI documentation
Why this matters: Not every use case requires a conversational agent. Sometimes you just need to execute a specific function (search, generate content, process data) via HTTP. Making tools accessible as endpoints would make VoltAgent more versatile and production-ready for diverse architectural patterns.
Copy this into the "Describe the thing to improve" section!

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions