mcpster

Documentation

TypeScript SDK for building MCP servers — chainable API, Zod validation, stdio + HTTP transports.

Overview

mcpster is a TypeScript SDK for building MCP servers. It wraps @modelcontextprotocol/sdk with a chainable builder API, adds Zod schema validation at the tool input layer, and ships a deploy CLI that targets Railway, Fly, and Cloudflare Workers.

Install

npm install @ruco-ai/mcpster

Quickstart

import { createServer } from '@ruco-ai/mcpster'
import { z } from 'zod'

const server = createServer({ name: 'my-server', version: '1.0.0' })
  .tool('greet', {
    description: 'Greet a user by name',
    input: z.object({ name: z.string() }),
    handler: async ({ name }) => `Hello, ${name}!`,
  })

server.start() // stdio by default

Tools

Add tools with .tool(name, config). The input field accepts any Zod schema — validation happens before the handler runs, and errors are returned as structured MCP errors.

.tool('search', {
  description: 'Search documents',
  input: z.object({
    query: z.string().min(1),
    limit: z.number().int().min(1).max(100).default(10),
  }),
  handler: async ({ query, limit }) => {
    // ...
  },
})

Resources

Expose static or dynamic resources with .resource(uri, config):

.resource('data://index', {
  description: 'The resource index',
  handler: async () => ({ contents: [{ uri: 'data://index', text: '...' }] }),
})

Prompts

Register prompt templates with .prompt(name, config):

.prompt('summarize', {
  description: 'Summarize a document',
  arguments: [{ name: 'text', required: true }],
  handler: async ({ text }) => ({
    messages: [{ role: 'user', content: { type: 'text', text: `Summarize: ${text}` } }],
  }),
})

Transports

mcpster supports two transports. Pass transport to start():

// stdio (default — for Claude Desktop and local tools)
server.start()

// HTTP/Express (for remote / deployed servers)
server.start({ transport: 'http', port: 3000 })

Deploy CLI

Deploy the server to a hosting provider:

# Railway
mcpster deploy --target railway

# Fly.io
mcpster deploy --target fly

# Cloudflare Workers
mcpster deploy --target cloudflare

Each target reads provider credentials from environment variables. See the GitHub repo for per-provider setup instructions.