Skip to main content
Glama
by alucardeht
TokenEstimator.js368 B
class TokenEstimator { static LIMITS = { DEFAULT: 4000, HARD: 5000, SUMMARY: 500, }; estimate(obj) { const str = typeof obj === "string" ? obj : JSON.stringify(obj); return Math.ceil(str.length / 4); } willExceed(obj, limit = TokenEstimator.LIMITS.DEFAULT) { return this.estimate(obj) > limit; } } export default TokenEstimator;

Latest Blog Posts

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/alucardeht/figma-mcp'

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