New:Socket for Asana Is Now Available.Learn more
Get Started

@mastra/hono

Package Overview
Dependencies
Maintainers
7
Versions
791
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
This package has malicious versions linked to the ongoing "Mastra AI framework compromise" supply chain attack.

Affected versions:

1.4.26
View campaign page

@mastra/hono

Mastra Hono adapter for the server

Source
npmnpm
Version
1.5.10
Version published
Weekly downloads
43K
-26.09%
Maintainers
7
Weekly downloads
 
Created
Source

@mastra/hono

Hono server adapter for Mastra, enabling you to run Mastra with the Hono framework.

Installation

npm install @mastra/hono hono

Usage

import { Hono } from 'hono';
import { HonoBindings, HonoVariables, MastraServer } from '@mastra/hono';
import { mastra } from './mastra';

const app = new Hono<{ Bindings: HonoBindings; Variables: HonoVariables }>();
const server = new MastraServer({ app, mastra });

await server.init();

export default app;

Adding Custom Routes

Add routes directly to the Hono app with access to Mastra context:

// Routes added after init() have access to Mastra context
app.get('/health', c => {
  const mastraInstance = c.get('mastra');
  const agents = Object.keys(mastraInstance.listAgents());
  return c.json({ status: 'ok', agents });
});

Configuration Options

const server = new MastraServer({
  app,
  mastra,
  prefix: '/api/v2', // Route prefix
  openapiPath: '/openapi.json', // OpenAPI spec endpoint
  bodyLimitOptions: {
    maxSize: 10 * 1024 * 1024, // 10MB
    onError: err => ({ error: 'Payload too large' }),
  },
  streamOptions: { redact: true }, // Redact sensitive data from streams
});

Context Variables

Access these in route handlers via c.get():

KeyDescription
mastraMastra instance
requestContextRequest context map
abortSignalRequest cancellation signal
toolsAvailable tools

FAQs

Package last updated on 27 Jul 2026

Related posts