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

@dotdo/mcp

v0.1.5

Published

MCP Server library with search, fetch, and do primitives - the core package for building MCP servers

Downloads

714

Readme

@dotdo/mcp

MCP Server library with search, fetch, and do primitives - the core package for building MCP (Model Context Protocol) servers.

Installation

npm install @dotdo/mcp
# or
pnpm add @dotdo/mcp

Quick Start

import { createMCPServer, createScope } from '@dotdo/mcp'
import { Hono } from 'hono'

// Define your domain bindings for the sandboxed `do` tool
const scope = createScope({
  bindings: {
    db: {
      query: async (sql: string) => {
        // Your database query implementation
        return []
      }
    },
    api: {
      fetch: async (url: string) => {
        // Your API fetch implementation
        return {}
      }
    }
  },
  permissions: {
    allowNetwork: false // Disable raw fetch in sandbox
  },
  timeout: 5000
})

// Create the MCP server
const mcp = createMCPServer({
  search: async (query, options) => {
    // Implement search logic
    return [{ id: '1', title: 'Result', content: 'Content...' }]
  },
  fetch: async (id, options) => {
    // Implement fetch logic
    return { id, content: 'Fetched content' }
  },
  do: scope
})

// Mount on Hono
const app = new Hono()
app.post('/mcp', mcp.getHttpHandler())

Three Primitives

The MCP server exposes three core tools:

search

Search for information in your knowledge base.

{
  query: string      // The search query
  limit?: number     // Maximum results (optional)
  offset?: number    // Skip results (optional)
}

fetch

Fetch a specific resource by identifier.

{
  id: string              // Resource identifier
  includeMetadata?: boolean // Include metadata (optional)
  format?: string         // Desired format (optional)
}

do

Execute TypeScript code in a sandboxed environment with your domain bindings.

{
  code: string  // TypeScript code to execute
}

Authentication

The library includes built-in authentication support:

import { createMCPServer, createAuthMiddleware } from '@dotdo/mcp'

const mcp = createMCPServer({
  // ... tools config
  auth: {
    mode: 'anon+auth', // 'anon' | 'anon+auth' | 'auth-required'
    oauth: {
      introspectionUrl: 'https://auth.example.com/introspect'
    },
    apiKey: {
      verifyUrl: 'https://keys.example.com/verify'
    }
  }
})

// Use with Hono middleware
const app = new Hono()
const authMiddleware = createAuthMiddleware(mcp.getAuthConfig())
app.use('/mcp/*', authMiddleware)
app.post('/mcp', mcp.getHttpHandler())

Auth Modes

  • anon - Anonymous access only (readonly)
  • anon+auth - Both anonymous and authenticated access
  • auth-required - Authentication required for all access

Token Types

The library auto-detects token types:

  • JWT tokens (three dot-separated parts)
  • API keys with sk_ prefix
  • API keys with do_ prefix

Exports

// Main entry
import { createMCPServer } from '@dotdo/mcp'

// Server for Node.js (uses vm2)
import { createMCPServerNode } from '@dotdo/mcp/node'

// Tools
import { createSearchTool, createFetchTool, createDoTool } from '@dotdo/mcp/tools'

// Scope creation
import { createScope, validateScope } from '@dotdo/mcp/scope'

// Authentication
import {
  createAuthMiddleware,
  authenticate,
  ANONYMOUS_CONTEXT
} from '@dotdo/mcp/auth'

Cloudflare Workers

For Cloudflare Workers with sandboxed code execution:

import { createMCPServer } from '@dotdo/mcp'

export default {
  async fetch(request: Request, env: Env): Promise<Response> {
    const mcp = createMCPServer(config, { env })
    return mcp.getHttpHandler()(request)
  }
}

Node.js

For Node.js environments:

import { createMCPServerNode } from '@dotdo/mcp/node'

const mcp = createMCPServerNode(config)

Type Integration

This package optionally integrates with @dotdo/types for shared type definitions. Install it as a peer dependency if you want to use types from the broader @dotdo ecosystem:

pnpm add @dotdo/types

License

MIT