Gram Functions logo

Gram Functions

Define agent tools in TypeScript & deploy as MCP servers

2025-11-18

Product Introduction

  1. Gram Functions is a TypeScript framework that enables developers to define AI agent tools as code and deploy them as Model Context Protocol (MCP) servers on Gram's managed platform. It abstracts MCP protocol complexities while maintaining full compatibility with the MCP ecosystem through a high-level API.
  2. The core value lies in eliminating infrastructure management and protocol expertise requirements, allowing developers to focus on business logic while Gram handles server deployment, scaling, and enterprise-grade security. It provides a serverless environment for production-ready MCP servers with built-in observability and performance optimizations.

Main Features

  1. The framework offers a declarative TypeScript API for defining tools with Zod schema validation, enabling type-safe input parameters and automatic documentation generation for AI agents. Developers specify tool names, descriptions, input schemas, and execute functions containing custom logic.
  2. Serverless deployment workflow enables one-command publishing through npm run build and npm run push, automatically provisioning managed MCP infrastructure with automatic scaling, TLS encryption, and request tracing. Tools can combine API calls, database queries, and business logic in single atomic operations.
  3. Supports hybrid MCP configurations that combine code-defined tools with existing OpenAPI specifications, allowing gradual migration from API-based MCP implementations. Developers can remix tools across multiple functions into unified MCP server endpoints.

Problems Solved

  1. Eliminates the need for deep MCP protocol knowledge by abstracting transport layers and compliance requirements into framework internals, reducing initial implementation time from weeks to hours. The framework handles JSON-RPC 2.0 compliance, error code mapping, and payload serialization automatically.
  2. Targets TypeScript developers building AI agent ecosystems who require production-grade MCP servers without operational overhead, particularly teams transitioning from prototype API wrappers to optimized agent tooling.
  3. Addresses complex workflow scenarios like payment failure investigations that require chaining multiple systems (payment processors, CRM databases, risk engines) into single tool calls, reducing agent token usage and error rates through atomic operations.

Unique Advantages

  1. Unlike OpenAPI-first MCP solutions, Gram Functions uses code-as-configuration to enable dynamic tool generation with programmatic logic, supporting use cases where REST API endpoints don't map cleanly to agent capabilities. The framework generates OpenAPI specifications from tool definitions rather than requiring manual spec maintenance.
  2. Implements JIT compilation of TypeScript tools into WebAssembly modules for 10x faster cold starts compared to traditional Node.js MCP implementations, with automatic retry handling and circuit breaker patterns built into the execution runtime.
  3. Combines the developer experience of local TypeScript tool development with Gram's global MCP server network, offering sub-100ms latency for tool executions through edge-cached function deployments. The platform provides usage analytics per tool and automatic version rollback capabilities.

Frequently Asked Questions (FAQ)

  1. How does Gram Functions differ from using OpenAPI specifications for MCP tools? Gram Functions generates MCP tools directly from TypeScript code with Zod validation, eliminating OpenAPI spec maintenance while enabling complex logic beyond API calls. It automatically produces compliant OpenAPI documentation for tool discovery while allowing programmatic workflows.
  2. Can I handle database queries or legacy system integrations within tool definitions? Yes, the execute function supports any Node.js-compatible operations including database connections, gRPC calls, and custom business logic. The runtime provides managed connection pooling and automatic cleanup of resources.
  3. What deployment options exist for Gram Functions tools? Tools deploy exclusively to Gram's managed platform through CLI commands, with automatic provisioning of serverless infrastructure. For self-hosting, developers can use Speakeasy's open-source MCP SDK with manual server configuration.
  4. How does error handling work for complex multi-step tools? The framework provides contextual error wrapping with automatic retries for transient failures and circuit breakers for downstream dependencies. Developers receive detailed execution traces showing failure points in multi-service workflows.
  5. What monitoring capabilities exist for deployed MCP tools? Gram's dashboard shows real-time metrics including execution latency, success rates, and token usage per tool, with alerts for error rate thresholds. Developers can inject custom telemetry through the execution context's logging API.

Subscribe to Our Newsletter

Get weekly curated tool recommendations and stay updated with the latest product news