Skip to main content
Glama
iletimerkezi

iletiMerkezi MCP Server

Official

get_balance

Check your account balance and the number of standard SMS messages it can fund. This endpoint has no side effects, making it safe for verifying authentication and remaining budget before campaigns.

Instructions

The get-balance endpoint returns the TL balance remaining on your account and the number of standard SMS messages that balance can fund. It has no side effects and consumes no credits, making it the safest call for verifying authentication and checking remaining budget before a campaign.

Reference: https://www.iletimerkezi.com/en/docs/api/get-balance

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The tool 'get_balance' is registered in the test manifest fixture via the mcp_tool field on line 27, linking the endpoint slug 'get-balance' to the MCP tool name 'get_balance'.
    mcp_tool: 'get_balance',
  • The manifest.ts file loads the API manifest (which includes the 'get_balance' endpoint definition) from a remote URL, cache, or fallback. This provides the configuration data (path, method, input_schema, etc.) for the get_balance tool.
    import { promises as fs, readFileSync } from 'node:fs'
    import os from 'node:os'
    import path from 'node:path'
    import type { ApiManifest, ManifestLoadResult, ManifestSource } from './types.js'
    
    const DEFAULT_MANIFEST_URL = 'https://www.iletimerkezi.com/api/manifest.json'
    const FETCH_TIMEOUT_MS = 5_000
    const CACHE_TTL_MS = 24 * 60 * 60 * 1_000
    
    export interface LoadOptions {
      manifestUrl?: string
      cacheDir?: string
      cacheFile?: string
      fetchImpl?: typeof fetch
      now?: () => number
      /**
       * Override the fallback search path list. Pass `[]` to disable the fallback
       * lookup entirely (useful in tests). When omitted, the production candidate
       * list is used.
       */
      fallbackPaths?: string[]
    }
    
    export function getManifestUrl(env: NodeJS.ProcessEnv = process.env): string {
      return (env.ILETIMERKEZI_MANIFEST_URL || DEFAULT_MANIFEST_URL).replace(/\/$/, '')
    }
    
    export function getCachePath(env: NodeJS.ProcessEnv = process.env): { dir: string; file: string } {
      const root = env.ILETIMERKEZI_MCP_CACHE_DIR || path.join(os.homedir(), '.cache', 'iletimerkezi-mcp')
      return { dir: root, file: path.join(root, 'manifest.json') }
    }
    
    interface CacheEnvelope {
      fetched_at: string
      manifest: ApiManifest
    }
    
    async function readCache(file: string, now: number): Promise<CacheEnvelope | null> {
      try {
        const raw = await fs.readFile(file, 'utf8')
        const parsed = JSON.parse(raw) as CacheEnvelope
        if (!parsed.fetched_at || !parsed.manifest) return null
        const age = now - new Date(parsed.fetched_at).getTime()
        if (Number.isNaN(age) || age < 0 || age > CACHE_TTL_MS) return null
        return parsed
      } catch {
        return null
      }
    }
    
    async function writeCache(dir: string, file: string, envelope: CacheEnvelope): Promise<void> {
      await fs.mkdir(dir, { recursive: true })
      const tmp = `${file}.tmp.${process.pid}`
      await fs.writeFile(tmp, JSON.stringify(envelope, null, 2), 'utf8')
      await fs.rename(tmp, file)
    }
    
    async function fetchLive(url: string, fetchImpl: typeof fetch): Promise<ApiManifest> {
      const controller = new AbortController()
      const timer = setTimeout(() => controller.abort(), FETCH_TIMEOUT_MS)
      try {
        const res = await fetchImpl(url, {
          method: 'GET',
          headers: { Accept: 'application/json' },
          signal: controller.signal,
        })
        if (!res.ok) throw new Error(`Manifest fetch failed: HTTP ${res.status}`)
        const json = (await res.json()) as ApiManifest
        if (!Array.isArray(json.endpoints)) throw new Error('Manifest missing endpoints array')
        return json
      } finally {
        clearTimeout(timer)
      }
    }
    
    function defaultFallbackPaths(): string[] {
      const scriptDir = process.argv[1] ? path.dirname(process.argv[1]) : process.cwd()
      return [
        process.env.ILETIMERKEZI_FALLBACK_MANIFEST,
        path.resolve(scriptDir, 'manifest.fallback.json'),
        path.resolve(scriptDir, '../manifest.fallback.json'),
        path.resolve(process.cwd(), 'dist/manifest.fallback.json'),
      ].filter((p): p is string => typeof p === 'string' && p.length > 0)
    }
    
    function loadFallback(overridePaths?: string[]): ApiManifest {
      const candidates = overridePaths !== undefined ? overridePaths : defaultFallbackPaths()
      for (const candidate of candidates) {
        try {
          return JSON.parse(readFileSync(candidate, 'utf8')) as ApiManifest
        } catch {
          // try next
        }
      }
      throw new Error(
        'iletiMerkezi manifest is unavailable: live fetch failed, no cache, and no fallback shipped with the package.',
      )
    }
    
    export async function loadManifest(options: LoadOptions = {}): Promise<ManifestLoadResult> {
      const url = options.manifestUrl || getManifestUrl()
      const cache = options.cacheFile
        ? { dir: options.cacheDir || path.dirname(options.cacheFile), file: options.cacheFile }
        : getCachePath()
      const now = options.now ? options.now() : Date.now()
      const fetchImpl = options.fetchImpl || globalThis.fetch
    
      const cached = await readCache(cache.file, now)
      if (cached) {
        return { manifest: cached.manifest, source: 'cache', fetched_at: cached.fetched_at }
      }
    
      try {
        const live = await fetchLive(url, fetchImpl)
        const fetched_at = new Date(now).toISOString()
        void writeCache(cache.dir, cache.file, { fetched_at, manifest: live }).catch(() => {})
        return { manifest: live, source: 'live', fetched_at }
      } catch {
        const fallback = loadFallback(options.fallbackPaths)
        return {
          manifest: fallback,
          source: 'fallback' as ManifestSource,
          fetched_at: fallback.generated_at,
        }
      }
    }
  • The CallToolRequestSchema handler in server.ts looks up the tool by name (including 'get_balance') from the toolByName map and calls executeTool() with the tool definition, arguments, and credentials.
    server.setRequestHandler(CallToolRequestSchema, async (request) => {
      const tool = toolByName.get(request.params.name)
      if (!tool) {
        return {
          isError: true,
          content: [{ type: 'text', text: `Unknown tool: ${request.params.name}` }],
        }
      }
      let credentials
      try {
        credentials = readCredentials(env)
      } catch (err) {
        const message = err instanceof MissingCredentialsError ? err.message : String(err)
        return { isError: true, content: [{ type: 'text', text: message }] }
      }
      try {
        const outcome = await executeTool(tool, request.params.arguments, {
          credentials,
          fetchImpl: options.fetchImpl,
        })
        return { isError: outcome.isError, content: [{ type: 'text', text: outcome.text }] }
      } catch (err) {
        const message = err instanceof Error ? err.message : String(err)
        return {
          isError: true,
          content: [{ type: 'text', text: `Tool execution failed: ${message}` }],
        }
      }
    })
  • The executeTool function is the generic handler that executes any tool (including get_balance). It calls the endpoint, processes the response, formats output, and returns structured results.
    export async function executeTool(
      tool: McpToolDefinition,
      rawInput: unknown,
      ctx: ToolCallContext,
    ): Promise<ToolCallOutcome> {
      const input = (rawInput && typeof rawInput === 'object' ? rawInput : {}) as Record<string, unknown>
      const { status, body, request_url } = await callEndpoint({
        endpoint: tool.endpoint,
        input,
        credentials: ctx.credentials,
        fetchImpl: ctx.fetchImpl,
        baseUrl: ctx.baseUrl,
      })
    
      const apiCode = extractApiStatusCode(body)
      const ok = status >= 200 && status < 300 && (apiCode === null || apiCode === 200)
      const summary = ok
        ? `iletiMerkezi ${tool.endpoint.path} succeeded (HTTP ${status}${apiCode !== null ? `, response.status.code ${apiCode}` : ''}).`
        : `iletiMerkezi ${tool.endpoint.path} failed (HTTP ${status}${apiCode !== null ? `, response.status.code ${apiCode}` : ''}).`
      const guidance = ok ? '' : guidanceFor(apiCode, tool.endpoint)
      const payload = JSON.stringify(body, null, 2)
    
      return {
        isError: !ok,
        text: [summary, guidance, `Request URL: ${request_url}`, '```json', payload, '```']
          .filter(Boolean)
          .join('\n'),
      }
    }
  • src/tools.ts:11-20 (registration)
    buildToolDefinitions builds McpToolDefinition objects from manifest endpoints, creating a tool entry with name, description, inputSchema, and endpoint for each endpoint that has an mcp_tool name (including 'get_balance').
    export function buildToolDefinitions(manifest: ApiManifest): McpToolDefinition[] {
      return manifest.endpoints
        .filter((ep) => ep.mcp_tool && ep.input_schema)
        .map((ep) => ({
          name: ep.mcp_tool!,
          description: buildDescription(ep),
          inputSchema: ep.input_schema as Record<string, unknown>,
          endpoint: ep,
        }))
    }
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

The description states 'no side effects and consumes no credits,' which is valuable behavioral context beyond the lack of annotations. It also positions the tool as safe for authentication checks.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is two concise sentences plus a reference link. Every sentence adds value with no redundancy.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no parameters and no output schema, the description fully explains the return values (balance and SMS count) and the tool's safe nature, making it complete for invocation.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With no parameters and 100% schema coverage, the description adds no param info, which is acceptable. The baseline for zero parameter tools is 4.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool returns TL balance and standard SMS count. It distinguishes itself from sibling tools like 'send_sms' and 'get_report' by focusing on balance and safety.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

It explicitly says the tool is the 'safest call for verifying authentication and checking remaining budget before a campaign,' providing clear context for when to use it. It implicitly advises using it before campaigns but does not explicitly list when not to use.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/iletimerkezi/iletimerkezi-mcp-server'

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