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

@a2akit/fastify

v0.2.0

Published

Fastify adapter for @a2akit/core A2A protocol servers

Downloads

22

Readme

@a2akit/fastify

Fastify adapter for @a2akit/core A2A protocol servers.

Installation

npm install @a2akit/fastify @a2akit/core fastify reflect-metadata

Quick Start

import 'reflect-metadata';
import Fastify from 'fastify';
import { createA2APlugin } from '@a2akit/fastify';
import { A2AAgent, Skill, TextPart } from '@a2akit/core';

@A2AAgent({
  name: 'Fastify Agent',
  description: 'An agent running on Fastify',
  version: '1.0.0',
})
class MyAgent {
  @Skill({
    name: 'Hello',
    description: 'Say hello',
  })
  hello(@TextPart() name: string): string {
    return `Hello, ${name}!`;
  }
}

const fastify = Fastify({ logger: true });

fastify.register(createA2APlugin(MyAgent), { prefix: '/a2a' });

fastify.listen({ port: 3000 }, (err, address) => {
  if (err) throw err;
  console.log(`A2A server running at ${address}`);
});

API Reference

createA2APlugin(agentClass)

Creates a Fastify plugin with A2A protocol endpoints.

import { createA2APlugin } from '@a2akit/fastify';

fastify.register(createA2APlugin(MyAgent), {
  prefix: '/a2a',  // Optional: route prefix
});

Options

| Option | Type | Default | Description | |--------|------|---------|-------------| | prefix | string | '' | Route prefix for all endpoints |

Endpoints

| Method | Path | Description | |--------|------|-------------| | GET | /.well-known/agent.json | Agent Card | | POST | / | JSON-RPC endpoint |

Fastify Decoration

The plugin decorates the Fastify instance with access to the task manager:

fastify.register(createA2APlugin(MyAgent));

// Access task manager
const taskManager = fastify.a2aTaskManager;
const task = taskManager?.get('task-id');

Examples

Basic Setup

import 'reflect-metadata';
import Fastify from 'fastify';
import { createA2APlugin } from '@a2akit/fastify';
import { A2AAgent, Skill, TextPart } from '@a2akit/core';

@A2AAgent({
  name: 'Greeting Agent',
  description: 'Greets users',
  version: '1.0.0',
})
class GreetingAgent {
  @Skill({ name: 'Greet', description: 'Greet by name' })
  greet(@TextPart() name: string): string {
    return `Hello, ${name}!`;
  }
}

const fastify = Fastify();
fastify.register(createA2APlugin(GreetingAgent));
fastify.listen({ port: 3000 });

Multiple Agents

import Fastify from 'fastify';
import { createA2APlugin } from '@a2akit/fastify';

const fastify = Fastify();

// Mount different agents on different paths
fastify.register(createA2APlugin(GreetingAgent), { prefix: '/agents/greeting' });
fastify.register(createA2APlugin(CalculatorAgent), { prefix: '/agents/calculator' });

fastify.listen({ port: 3000 });

With Logging

import Fastify from 'fastify';
import { createA2APlugin } from '@a2akit/fastify';

const fastify = Fastify({
  logger: {
    level: 'info',
    transport: {
      target: 'pino-pretty',
    },
  },
});

fastify.register(createA2APlugin(MyAgent), { prefix: '/a2a' });
fastify.listen({ port: 3000 });

With Other Plugins

import Fastify from 'fastify';
import cors from '@fastify/cors';
import { createA2APlugin } from '@a2akit/fastify';

const fastify = Fastify();

await fastify.register(cors, {
  origin: true,
});

await fastify.register(createA2APlugin(MyAgent), { prefix: '/a2a' });

fastify.listen({ port: 3000 });

Testing Your Agent

# Get Agent Card
curl http://localhost:3000/a2a/.well-known/agent.json | jq

# Call a skill
curl -X POST http://localhost:3000/a2a \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "id": "1",
    "method": "tasks/send",
    "params": {
      "id": "task-1",
      "message": {
        "role": "user",
        "parts": [{"type": "text", "text": "World"}]
      },
      "metadata": {"skillId": "hello"}
    }
  }'

TypeScript Support

The plugin includes TypeScript declaration merging for the Fastify instance:

declare module 'fastify' {
  interface FastifyInstance {
    a2aTaskManager?: TaskManager;
  }
}

License

MIT