Skip to main content
Glama

Sanity MCP Server

Official
by sanity-io
id.ts755 B
const ALLOWED_CHARS = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789' /** * Generates a valid Sanity document ID * * Creates an ID that follows Sanity's requirements: * - Contains only a-zA-Z0-9 characters * - Maximum 128 characters */ export function generateSanityId(length = 8, prefix = ''): string { // Ensure length is within valid range, accounting for prefix length const prefixLength = prefix.length const availableLength = 128 - prefixLength const finalLength = Math.min(Math.max(1, length), availableLength) // Generate random ID of specified length let id = prefix for (let i = 0; i < finalLength; i++) { id += ALLOWED_CHARS.charAt(Math.floor(Math.random() * ALLOWED_CHARS.length)) } return id }

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/sanity-io/sanity-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server