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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@tmcp/adapter-effect

v0.2.1

Published

Effect Schema adapter for TMCP JSON Schema conversion

Readme

@tmcp/adapter-effect

Effect Schema adapter for TMCP JSON Schema conversion.

Installation

pnpm add @tmcp/adapter-effect effect tmcp

Usage

import { EffectJsonSchemaAdapter } from '@tmcp/adapter-effect';
import * as S from 'effect/Schema';

const adapter = new EffectJsonSchemaAdapter();

// Define an Effect schema
const UserSchema = S.Struct({
	name: S.String,
	age: S.Number,
	email: S.String.pipe(S.pattern(/^[^\s@]+@[^\s@]+\.[^\s@]+$/)),
});

// Convert to JSON Schema
const jsonSchema = await adapter.toJsonSchema(UserSchema);
console.log(jsonSchema);

Usage with TMCP Server

import { McpServer } from 'tmcp';
import { EffectJsonSchemaAdapter } from '@tmcp/adapter-effect';
import * as S from 'effect/Schema';

const adapter = new EffectJsonSchemaAdapter();
const server = new McpServer(
	{
		name: 'my-server',
		version: '1.0.0',
		description: 'Server with Effect schemas',
	},
	{
		adapter,
		capabilities: {
			tools: { listChanged: true },
		},
	},
);

// Define a tool with Effect schema
server.tool(
	{
		name: 'create_user',
		description: 'Create a new user',
		schema: S.Struct({
			name: S.String,
			age: S.Number.pipe(S.positive()),
			email: S.String.pipe(S.pattern(/^[^\s@]+@[^\s@]+\.[^\s@]+$/)),
		}),
	},
	async ({ name, age, email }) => {
		return {
			content: [
				{
					type: 'text',
					text: `Created user: ${name}, age ${age}, email ${email}`,
				},
			],
		};
	},
);

Advanced Usage

Custom JSON Schema Options

import { EffectJsonSchemaAdapter } from '@tmcp/adapter-effect';
import * as S from 'effect/Schema';

const adapter = new EffectJsonSchemaAdapter();

// Schema with custom descriptions and metadata
const UserSchema = S.Struct({
	name: S.String.annotations({
		title: 'Full Name',
		description: 'Full name of the user',
	}),
	age: S.Number.pipe(S.positive()).annotations({
		description: 'Age in years',
	}),
	email: S.String.pipe(S.pattern(/^[^\s@]+@[^\s@]+\.[^\s@]+$/)).annotations({
		description: 'Valid email address',
	}),
	preferences: S.optional(
		S.Struct({
			theme: S.Literal('light', 'dark').annotations({ default: 'light' }),
			notifications: S.Boolean.annotations({ default: true }),
		}),
	),
});

const jsonSchema = await adapter.toJsonSchema(UserSchema);

Complex Schemas

import * as S from 'effect/Schema';

// Union types
const ContactSchema = S.Union(
	S.Struct({
		type: S.Literal('email'),
		value: S.String.pipe(S.pattern(/^[^\s@]+@[^\s@]+\.[^\s@]+$/)),
	}),
	S.Struct({
		type: S.Literal('phone'),
		value: S.String.pipe(S.pattern(/^\+?\d+$/)),
	}),
);

// Arrays and nested objects
const CompanySchema = S.Struct({
	name: S.String,
	employees: S.Array(UserSchema),
	contacts: S.Array(ContactSchema),
	founded: S.Date.pipe(
		S.transform(
			S.String,
			(date) => date.toISOString(),
			(dateStr) => new Date(dateStr),
		),
	),
});

API

EffectJsonSchemaAdapter

A class that extends the base JsonSchemaAdapter from TMCP and provides Effect Schema-specific schema conversion.

Methods

  • toJsonSchema(schema) - Converts an Effect schema to JSON Schema format

Dependencies

  • effect - Peer dependency for schema validation and type definitions (^3.0.0)
  • tmcp - Peer dependency for the base adapter

Features

  • Full Effect Schema support - Supports all Effect schema types and transformations
  • Type safety - Full TypeScript support with proper type inference
  • Rich metadata - Preserves annotations, descriptions, and validation rules
  • Easy integration - Drop-in replacement for other TMCP adapters
  • Native JSON Schema - Uses Effect's built-in JSON Schema generation

Acknowledgments

Huge thanks to Sean O'Bannon that provided us with the @tmcp scope on npm.