NitroStack SDK • Polyglot TypeScript & Python

Build Production-ReadyMCP Servers

The open-source polyglot framework for Model Context Protocol. Build in TypeScript or Python with Code Mode sandbox orchestration, stateless tasks, and zero-session edge scalability.

$npx @nitrostack/cli init my-server --preset code-mode
1import { Tool, z, ExecutionContext } from '@nitrostack/core';
2
3export class CalculatorTools {
4 @Tool({
5 name: 'add_numbers',
6 description: 'Add two numbers together with schema validation',
7 inputSchema: z.object({
8 a: z.number().describe('First number'),
9 b: z.number().describe('Second number'),
10 }),
11 metadata: {
12 category: 'math',
13 tags: ['calculator', 'stateless'],
14 },
15 })
16 async addNumbers(input: { a: number; b: number }, ctx: ExecutionContext) {
17 return {
18 result: input.a + input.b,
19 timestamp: new Date().toISOString(),
20 };
21 }
22}
calculator.tools.ts
Flagship Innovation • Code Mode

Zero Network Bloat. Up to 98% Fewer Tokens. Pure Execution.

Traditional MCP forces models to ingest hundreds of tool schemas and hop through serialized network round-trips. Code Mode transforms this: an in-memory QuickJS WebAssembly sandbox where AI models write and execute orchestration scripts atomically.

98%

Up to 98% Reduction

Collapses 100+ raw tool schemas (15,000–40,000 tokens) down to 3 meta-tools (~300 tokens).

1Round-Trip

Single Network Hop

Chains multi-step pipelines in a single atomic request instead of 6+ serialized HTTP calls over the wire.

<20ms

In-Memory Speed

Tools resolve in-memory inside the pre-warmed worker pool with zero HTTP serialization latency.

128MB

Sandboxed Safety

Strict WebAssembly memory caps, 15s CPU timeout, and zero Node.js/system API leakage.

Interactive Architecture Comparison

See how Code Mode transforms multi-step AI tool interactions in real numbers.

orchestrate.sandbox.js (QuickJS WASM)
// Model writes JS; NitroStack evaluates in QuickJS WASM sandbox
async function executePipeline() {
  // 1. In-memory micro-tool execution (zero network latency)
  const items = await callTool('inventory_check_stock', { warehouseId: 'W-9' });
  
  // 2. Filter & aggregate without sending intermediate payloads to the model
  const urgent = items.records.filter(i => i.qty < i.reorderThreshold);
  const audit = await callTool('finance_audit_ledger', {
    skus: urgent.map(u => u.sku)
  });

  // 3. Return ONLY the computed insight to the agent
  return {
    reorderCount: urgent.length,
    estimatedCost: audit.totalProjectedCost,
    recommendedBatchId: audit.batchReference
  };
}

return await executePipeline();
Atomic 1-Round-Trip Execution

The model searches tools with search, fetches parameter schemas with get_schema, and dispatches the script to execute.

Context Tokens Used~320 tokens (-98%)
Network Round-Trips1 Atomic Call (vs. 6+)
Intermediate Data On Wire0 KB (Kept in sandbox)
Execution Latency18 ms (In-memory worker)
Guest runtime has zero access to process, fs, or native sockets.
Scaffold a Code Mode server immediately with our dedicated preset:
$npx @nitrostack/cli init my-orchestrator --preset code-mode
01

search(query)

Queries tool catalog keywords and descriptions without returning bulky schemas. The model discovers relevant tools dynamically on demand.

02

get_schema(tool_names)

Fetches exact Zod or Pydantic parameter schemas only for the specific tools needed for the pending workflow script.

03

execute(script)

Evaluates JavaScript in the isolated QuickJS WebAssembly worker. Executes in-memory tool chains and returns only the final computed summary.

MCP 2026-07-28 Spec Ready

Engineered for Stateless Scale & Enterprise Security

Say goodbye to sticky TCP sessions and hanging SSE streams. NitroStack brings horizontally scalable cloud architecture to the Model Context Protocol.

MCP 2026-07-28

Stateless by Default

Zero session headers (Mcp-Session-Id eliminated). Any server replica can answer any tool call, enabling horizontal autoscaling across Kubernetes, serverless, and edge runtimes.

  • No sticky load balancing or session affinity needed
  • Deploys seamlessly on AWS Lambda, Cloudflare, or Docker
  • Zero memory bloat from dangling TCP connections
// Atomic per-request evaluation
POST /mcp HTTP/1.1
Content-Type: application/json
Authorization: Bearer <jwt>

{ "jsonrpc": "2.0", "method": "tools/call", ... }
SEP-2663 Tasks

Background Tasks Engine

Long-running operations decoupled from HTTP connection lifetimes. Pluggable TaskStore backends coordinate async executions across distributed nodes.

  • Pluggable stores: Redis, PostgreSQL, DynamoDB, Memory
  • Survives pod restarts and load balancer re-routing
  • Standardized task polling and status elicitation
@Tool({ name: 'process_dataset' })
async process(input, ctx: ExecutionContext) {
  return ctx.taskManager.startTask({
    status: 'working',
    statusMessage: 'Processing 100k items...'
  });
}
SEP-2549 & SEP-2243

Edge Caching & Zero-Body Routing

Cache discovery metadata at edge CDNs for ~2ms responses. Enterprise API gateways inspect Mcp-Method and Mcp-Name headers without JSON body parsing.

  • Sub-2ms server/discover via CDN cache hints
  • Rate-limit individual expensive tools at gateway layer
  • Envoy, Kong, and AWS ALB native header routing
Mcp-Method: tools/call
Mcp-Name: financial_summary
Cache-Control: public, max-age=300
Dual Ecosystem

Polyglot: TypeScript & Python

Complete architectural parity between TypeScript and Python. Choose your team's preferred language with zero compromise on features or developer experience.

  • TypeScript: Zod schemas, NestJS-inspired decorators
  • Python: Pydantic v2 models, uv lockfiles, nitrostack-py CLI
  • Automated agent skills scaffolding (.cursor, .claude)
# Python CLI
$ pip install nitrostack
$ nitrostack-py init my-server --template python-starter

# TypeScript CLI
$ npx @nitrostack/cli init my-server --preset code-mode
OAuth 2.1 & CIMD

Defense-in-Depth Security

Zero-trust authentication evaluated per request. Client ID Metadata Documents (CIMD) eliminate dynamic client registration sprawl with strict anti-mixup protection.

  • RFC 9207 Issuer Anti-Mixup & JWKS validation
  • SSRF protection on external resource resolvers
  • Declarative @Guard decorators protecting sensitive tools
@UseGuards(OAuthGuard)
@Tool({ name: 'transfer_funds' })
async transfer(input, ctx: ExecutionContext) {
  // Verified user claims in ctx.auth
}
Extensible Lifecycle

Transforms Pipeline Engine

Intercept tools/list and tools/call requests. Dynamically reshape catalogs, gate tenant-specific capabilities, or attach BM25 semantic discovery.

  • BM25SearchTransform for progressive tool discovery
  • VisibilityTransform for tenant or role capability gating
  • CodeModeTransform for sandboxed QuickJS execution
@McpApp({
  transforms: [
    new VisibilityTransform(),
    new CodeModeTransform({ workerPoolSize: 4 })
  ]
})
Architectural Advantage

Why Developers Choose NitroStack

The patterns you already trust, the efficiency breakthroughs AI models demand, and the stateless cloud primitives enterprise production requires.

  • Code Mode Orchestration

    Slash token consumption by up to 98% and collapse multi-step tool calls into a single network round-trip. AI models execute JavaScript inside an isolated QuickJS WebAssembly sandbox with sub-20ms local chaining.

  • First-Class Polyglot DX

    Complete architectural parity across TypeScript and Python. Use decorators, Zod or Pydantic schemas, dependency injection, and hot reload. One framework, two world-class ecosystems.

  • Stateless by Default

    Fully aligned with MCP 2026-07-28. Zero sticky sessions, zero dangling SSE streams. Long-running tasks decouple cleanly via pluggable Redis and Postgres TaskStores with sub-2ms edge CDN caching.

  • Enterprise Defense-in-Depth

    OAuth 2.1, Client ID Metadata Documents (CIMD), SSRF protection, and RFC 9207 anti-mixup validation evaluated per request. Declarative guards protect tools before execution ever begins.

Getting Started

From Zero to Production in Minutes

Pick your language. Scaffold with one command. Run locally with hot reload and test in NitroStudio.

Step 1

Initialize your project

Scaffold a production-ready MCP server with our official CLI. Pick starter templates or activate Code Mode presets with a single command.

$ npx @nitrostack/cli init my-server --preset code-mode
$ cd my-server && npm run dev

Step 2

Define tools, resources & prompts

Declare tools with type-safe schemas. TypeScript uses Zod validation; Python uses Pydantic v2 models with automatic JSON schema generation.

@Tool({
  name: 'calculate_tax',
  description: 'Compute regional tax rates',
  inputSchema: z.object({
    amount: z.number(),
    state: z.string().length(2)
  })
})
async calculateTax(input) {
  return { tax: input.amount * 0.08 };
}

Step 3

Configure Modules & Stateless Scale

Group controllers cleanly into modules, configure stateless HTTP transport, or attach Code Mode transforms in TypeScript.

@McpApp({
  transforms: [
    new CodeModeTransform({
      workerPoolSize: 4,
      memoryLimitMb: 128,
      timeoutMs: 15000,
      allowDestructive: false
    })
  ],
  taskStore: new RedisTaskStore({ url: process.env.REDIS_URL })
})
@Module({ controllers: [TaxController] })
export class AppModule {}

Step 4

Test visually & deploy

Inspect tools, run guest sandbox scripts, and verify auth tokens in NitroStudio before deploying to serverless or Kubernetes.

$ npx @nitrostack/cli dev
# Connected to NitroStudio at http://localhost:4567/mcp-test-server

Built by developers, for developers

Join thousands of engineers building production-ready MCP servers with NitroStack. Early access, shared patterns, and a roadmap shaped by real usage.

Your next MCP server starts here.

Open source. Polyglot TypeScript and Python. Code Mode and Stateless ready.