New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

flary

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

flary

mixed assortment of tools for cloudflare workers

latest
Source
npmnpm
Version
0.2.13
Version published
Maintainers
1
Created
Source

Flary

npm version license

A versatile toolkit for building and managing Cloudflare Workers applications, including AI integrations, project scaffolding, and component management.

Table of Contents

Prerequisites

Before you begin, ensure you have:

  • Node.js 18.x or later installed
  • A Cloudflare account
  • Wrangler CLI installed and configured:
    npm install -g wrangler
    wrangler login
    

Installation

npm install flary

Features

  • 🚀 Project Scaffolding: Quickly set up modern Cloudflare Workers projects.
  • 🎨 Component Management: Import and organize components from v0.dev.
  • 🤖 AI Integration: Tools and utilities for AI applications.
  • 🔒 Secure MCP Integration: Model Context Protocol integration with robust authentication.

CLI Usage

Project Initialization

Create a new Flary project interactively:

flary init

This command will:

  • Prompt for your project name.
  • Allow template selection (e.g., Full-Stack React App).
  • Set up a complete project structure.
  • Configure dependencies and Wrangler automatically.

Follow the provided steps after creation:

  • Navigate to your project:

    cd your-project-name
    
  • Install dependencies:

    npm install
    
  • Start development server:

    npm run dev
    

v0.dev Component Import

Import and organize components from v0.dev:

# Default directory (src/components)
flary v0 "https://v0.dev/chat/your-component-url"

# Custom directory
flary v0 --dir game-components "https://v0.dev/chat/your-component-url"

Options:

  • -d, --dir <directory>: Specify target subdirectory (relative to src/).
  • -h, --help: Display help information.

Deployment

Deploy your Flary application to Cloudflare Workers:

  • Build your application:

    npm run build
    
  • Deploy to Cloudflare Workers:

    npm run deploy
    # or directly with wrangler
    wrangler deploy
    

Your application will be deployed to https://<project-name>.<your-subdomain>.workers.dev

Environment Variables

Set environment variables for production:

# Set a secret
wrangler secret put MY_SECRET
# Set a variable in wrangler.toml
wrangler deploy --var MY_VAR=value

MCP Integration

Basic Usage

Initialize MCP instance and register tools:

import { z } from "zod";
import { MCP } from "flary";

const app = new MCP({
  name: "test-mcp",
  description: "A test MCP",
  version: "1.0.0",
});

const sumSchema = z
  .object({
    a: z.number().describe("The first number to add"),
    b: z.number().describe("The second number to add"),
  })
  .describe("Calculate the sum of two numbers");

async function calculateSum({ a, b }: z.input<typeof sumSchema>) {
  return a + b;
}
calculateSum.schema = sumSchema;

app.tool("calculate_sum", calculateSum);

export default app;
export const { McpObject } = app;

Authentication

Supports Bearer token authentication:

const app = new MCP({
  auth: {
    type: "bearer",
    token: "your-secret-token",
    validate: async (token) => token === (await getValidToken()),
  },
});

Connection Types

  • SSE (Server-Sent Events): Connect via / or /sse.
  • WebSockets: Connect via / or /ws.

Cursor Integration

Cursor uses SSE exclusively:

https://your-worker.workers.dev/?key=your-secret-token

No Authentication

Publicly accessible MCP server:

const app = new MCP({
  name: "test-mcp",
  description: "A test MCP",
  version: "1.0.0",
});

Durable Objects Setup

MCP requires Durable Objects for state management. Configure them in your wrangler.json:

{
  "durable_objects": {
    "bindings": [{ "name": "McpObject", "class_name": "McpObject" }]
  },
  "migrations": [{ "tag": "v1", "new_classes": ["McpObject"] }]
}

Make sure to export the McpObject from your worker entry point as shown in the Basic Usage example.

License

MIT © flary

Keywords

flary

FAQs

Package last updated on 10 Apr 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts