npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@voltagent/server-core

v2.1.20

Published

Framework-agnostic server core for VoltAgent

Downloads

13,140

Readme

GitHub issues GitHub pull requests License: MIT npm version npm downloads Discord

@voltagent/server-core

Framework-agnostic server core for VoltAgent. This package provides the shared infrastructure — route definitions, request handlers, WebSocket support, authentication utilities, MCP/A2A protocol helpers, and a base server provider — that all VoltAgent server adapters (e.g. @voltagent/server-hono) build on top of.

You typically do not use this package directly. Instead, choose a server adapter for your framework (such as @voltagent/server-hono) and pass it to the VoltAgent constructor. If you are building a custom server adapter, this package gives you everything you need.


Key Exports

Base Server Provider

BaseServerProvider — Abstract class that handles the common server lifecycle (port allocation, WebSocket setup, graceful shutdown, startup banner). Extend it when building a custom adapter.

import { BaseServerProvider } from "@voltagent/server-core";

Route Definitions

Pre-built, framework-agnostic route metadata objects you can use to register routes in any HTTP framework:

| Export | Routes covered | | ----------------------------- | -------------------------------------------- | | AGENT_ROUTES | Agent management and generation | | WORKFLOW_ROUTES | Workflow execute / stream / suspend / resume | | TOOL_ROUTES | Tool listing and direct execution | | MEMORY_ROUTES | Conversation and message management | | LOG_ROUTES | Log retrieval | | OBSERVABILITY_ROUTES | Traces, spans, and observability status | | OBSERVABILITY_MEMORY_ROUTES | Memory inspection for observability | | MCP_ROUTES | Model Context Protocol server endpoints | | A2A_ROUTES | Agent-to-Agent protocol endpoints | | ALL_ROUTES | All of the above combined |

Helper functions: getAllRoutesArray(), getRoutesByTag(tag).

Request Handlers

Framework-agnostic handler functions. Each handler receives a ServerProviderDeps context and returns a serialisable response object, making them easy to wrap in any HTTP framework:

  • Agent handlershandleGenerateText, handleStreamText, handleChatStream, handleResumeChatStream, handleGenerateObject, handleStreamObject
  • Workflow handlershandleGetWorkflows, handleGetWorkflow, handleExecuteWorkflow, handleStreamWorkflow, handleAttachWorkflowStream, handleSuspendWorkflow, handleResumeWorkflow, handleListWorkflowRuns, handleGetWorkflowState
  • Tool handlershandleListTools, handleExecuteTool
  • Memory handlershandleListMemoryConversations, handleCreateMemoryConversation, handleSaveMemoryMessages, and more
  • Observability handlersgetTracesHandler, getTraceByIdHandler, getObservabilityStatusHandler, and more
  • Log handlershandleGetLogs

Authentication

Plug-in auth via the AuthProvider interface. A built-in JWT provider is included:

import { jwtAuth, createJWT } from "@voltagent/server-core";

WebSocket Utilities

createWebSocketServer, setupWebSocketUpgrade — set up real-time log and observability streaming over WebSocket.

MCP & A2A Protocol Helpers

  • MCPServerRegistry, listMcpServers, lookupMcpServer — register and resolve MCP servers
  • A2AServerRegistry, listA2AServers, lookupA2AServer, executeA2ARequest — Agent-to-Agent protocol support

App Setup Utilities

getOpenApiDoc, shouldEnableSwaggerUI, getOrCreateLogger, DEFAULT_CORS_OPTIONS — helpers shared by all server adapters.

Edge Entry Point

A lighter entry point for edge runtimes (e.g. Cloudflare Workers, Vercel Edge) is available at the ./edge export:

import { AGENT_ROUTES, handleGenerateText } from "@voltagent/server-core/edge";

Usage Example — Custom Server Adapter

The snippet below shows the minimum required to build a custom server adapter on top of @voltagent/server-core:

import { createServer, type Server } from "node:http";
import { BaseServerProvider, type ServerProviderConfig } from "@voltagent/server-core";
import type { ServerProviderDeps } from "@voltagent/core";

export class MyCustomServerProvider extends BaseServerProvider {
  constructor(deps: ServerProviderDeps, config: ServerProviderConfig = {}) {
    super(deps, config);
  }

  protected async startServer(port: number): Promise<Server> {
    const server = createServer((req, res) => {
      // Route incoming requests to the framework-agnostic handlers
      res.writeHead(404);
      res.end("Not found");
    });

    await new Promise<void>((resolve) => server.listen(port, resolve));
    return server;
  }

  protected async stopServer(): Promise<void> {
    await new Promise<void>((resolve, reject) => {
      this.server?.close((err) => (err ? reject(err) : resolve()));
    });
  }
}

// Factory function consumed by VoltAgent
export function myCustomServer(config?: ServerProviderConfig) {
  return (deps: ServerProviderDeps) => new MyCustomServerProvider(deps, config);
}

Pass the factory to VoltAgent:

import { VoltAgent, Agent } from "@voltagent/core";
import { openai } from "@ai-sdk/openai";
import { myCustomServer } from "./my-custom-server";

const agent = new Agent({
  name: "my-agent",
  instructions: "A helpful assistant",
  model: openai("gpt-4o-mini"),
});

new VoltAgent({
  agents: { agent },
  server: myCustomServer({ port: 3141 }),
});

For a complete, production-ready server adapter see @voltagent/server-hono.


Documentation

License

Licensed under the MIT License, Copyright © 2026-present VoltAgent.