T

typescript-sdk

Created Oct 19, 2025 by smithery-ai

Language:

TypeScript

Stars:

160

Forks:

19

README

Smithery SDK

TypeScript types for building MCP servers on the Smithery hosted runtime.

Docs: https://smithery.ai/docs/build

Installation

npm install @smithery/sdk

Usage

The SDK provides types for the Smithery runtime context that your MCP server receives when deployed.

import type {
  ServerModule,
  ServerContext,
  Session,
} from "@smithery/sdk"
import { z } from "zod"

// Define your configuration schema
export const configSchema = z.object({
  apiKey: z.string(),
})

// Create your server
export default const createServer = async (context: ServerContext) => {
  const { config, env } = context

  // Access user configuration
  console.log(config.apiKey)

  // Access environment variables
  console.log(env.MY_SECRET)

  // For stateful servers, access session storage
  if ("session" in context) {
    await context.session.set("key", "value")
    const value = await context.session.get("key")
  }

  // Return your MCP server instance
  return new Server({ name: "my-server", version: "1.0.0" }, { capabilities: {} })
}

Types

ServerContext

The context object passed to your server factory function:

  • config: TConfig - User-provided configuration (validated against your configSchema)
  • env: Record - Environment variables
  • session?: Session - Session storage (only for stateful servers)

Session

Key-value storage scoped to the user session:

  • get(key: string): Promise
  • set(key: string, value: unknown): Promise
  • delete(key: string): Promise

ServerModule

The expected exports from your server entry point:

  • default: CreateServerFn - Factory function that creates your MCP server
  • configSchema?: z.ZodSchema - Zod schema for configuration validation
  • createSandboxServer?: CreateSandboxServerFn - Optional function for deployment scanning
  • stateful?: boolean - Whether the server maintains state between requests (default: false)

Documentation

For complete documentation, see:

License

MIT

Last updated: Oct 19, 2025

Publisher info

smithery-ai's avatar

smithery-ai

United States of America
424
followers
0
following
501
repos

More MCP servers built with TypeScript

Vue.js

This is the repo for Vue 2. For Vue 3, go to https://github.com/vuejs/core

By vuejs 209.9K
Excalidraw

Virtual whiteboard for sketching hand-drawn like diagrams

By excalidraw 114.9K
Angular

Deliver web apps with confidence 🚀

By angular 99.7K