GnistAI GnistAI
Log in

Getting Started with Phone Number Validation

Phone number validation and parsing — country detection, number type, formatting.

All Tutorials   |   Overview   |   Playground   |   MCP   |   REST API   |   Home
Utilities

Data source: Curated dataset (ITU numbering plans)

Overview

Phone Number Validation wraps Curated dataset (ITU numbering plans), handling authentication, pagination, and rate limits for you. This tutorial covers all 5 tools with working code examples you can copy and run.

Prerequisites

  1. Sign up at https://context.gnist.ai/signup for a free API key (100 calls/day).
  2. Choose your integration method: MCP protocol or REST API.

Connect via MCP

Add to your MCP client config (Claude Desktop, Cursor, etc.):

MCP Config
{
  "mcpServers": {
    "gnist-phone-validation": {
      "url": "https://context.gnist.ai/mcp/phone-validation/",
      "headers": {
        "Gnist-API-Key": "YOUR_API_KEY"
      }
    }
  }
}

Tools (5)

validate_phone_number

Validate and parse a phone number. Returns country, number type (mobile/landline/toll_free/premium), and formatted versions (E.164, international, national).

ParameterTypeRequiredDescription
numberstringrequiredPhone number to validate (E.164, international, or national format, e.g. +14155551234, 00441234567890).
curl -X POST "https://context.gnist.ai/mcp/phone-validation/" \
  -H "Content-Type: application/json" \
  -H "Gnist-API-Key: YOUR_API_KEY" \
  -d '{"jsonrpc": "2.0", "method": "tools/call", "id": 1, "params": {"name": "validate_phone_number", "arguments": {"number": "+14155551234"}}}'
import httpx

resp = httpx.post(
    "https://context.gnist.ai/mcp/phone-validation/",
    headers={"Gnist-API-Key": "YOUR_API_KEY"},
    json={'id': 1,
 'jsonrpc': '2.0',
 'method': 'tools/call',
 'params': {'arguments': {'number': '+14155551234'},
            'name': 'validate_phone_number'}},
)
print(resp.json())

format_phone_number

Format a phone number in the specified style. Returns the number formatted as E.164 (+1234567890), international (+1 234 567 890), or national (0234 567 890).

ParameterTypeRequiredDescription
numberstringrequiredPhone number to format.
fmtstringoptionalOutput format: e164, international, or national. (default: e164)
curl -X POST "https://context.gnist.ai/mcp/phone-validation/" \
  -H "Content-Type: application/json" \
  -H "Gnist-API-Key: YOUR_API_KEY" \
  -d '{"jsonrpc": "2.0", "method": "tools/call", "id": 1, "params": {"name": "format_phone_number", "arguments": {"number": "12345"}}}'
import httpx

resp = httpx.post(
    "https://context.gnist.ai/mcp/phone-validation/",
    headers={"Gnist-API-Key": "YOUR_API_KEY"},
    json={'id': 1,
 'jsonrpc': '2.0',
 'method': 'tools/call',
 'params': {'arguments': {'number': '12345'}, 'name': 'format_phone_number'}},
)
print(resp.json())

list_calling_codes

List all known country calling codes with metadata. Returns calling code, country name, trunk prefix, number length ranges, and example numbers for ~50 countries.

curl -X POST "https://context.gnist.ai/mcp/phone-validation/" \
  -H "Content-Type: application/json" \
  -H "Gnist-API-Key: YOUR_API_KEY" \
  -d '{"jsonrpc": "2.0", "method": "tools/call", "id": 1, "params": {"name": "list_calling_codes", "arguments": {}}}'
import httpx

resp = httpx.post(
    "https://context.gnist.ai/mcp/phone-validation/",
    headers={"Gnist-API-Key": "YOUR_API_KEY"},
    json={'id': 1,
 'jsonrpc': '2.0',
 'method': 'tools/call',
 'params': {'arguments': {}, 'name': 'list_calling_codes'}},
)
print(resp.json())

get_calling_code

Get calling code details for a specific country. Returns calling code, trunk prefix, number length, example numbers, and known prefix patterns for mobile/landline.

ParameterTypeRequiredDescription
country_codestringrequiredISO 3166-1 alpha-2 country code (e.g. US, GB, NO, DE).
curl -X POST "https://context.gnist.ai/mcp/phone-validation/" \
  -H "Content-Type: application/json" \
  -H "Gnist-API-Key: YOUR_API_KEY" \
  -d '{"jsonrpc": "2.0", "method": "tools/call", "id": 1, "params": {"name": "get_calling_code", "arguments": {"country_code": "US"}}}'
import httpx

resp = httpx.post(
    "https://context.gnist.ai/mcp/phone-validation/",
    headers={"Gnist-API-Key": "YOUR_API_KEY"},
    json={'id': 1,
 'jsonrpc': '2.0',
 'method': 'tools/call',
 'params': {'arguments': {'country_code': 'US'}, 'name': 'get_calling_code'}},
)
print(resp.json())

report_feedback

Report a bug, feature request, or general feedback for this data source. Use this when something doesn't work as expected, when you'd like a new feature, or when you have suggestions for improvement. Args: feedback: Describe the issue or suggestion. feedback_type: One of 'bug', 'feature_request', or 'general'.

ParameterTypeRequiredDescription
feedbackstringrequired
feedback_typestringoptional (default: general)
curl -X POST "https://context.gnist.ai/mcp/phone-validation/" \
  -H "Content-Type: application/json" \
  -H "Gnist-API-Key: YOUR_API_KEY" \
  -d '{"jsonrpc": "2.0", "method": "tools/call", "id": 1, "params": {"name": "report_feedback", "arguments": {"feedback": "example"}}}'
import httpx

resp = httpx.post(
    "https://context.gnist.ai/mcp/phone-validation/",
    headers={"Gnist-API-Key": "YOUR_API_KEY"},
    json={'id': 1,
 'jsonrpc': '2.0',
 'method': 'tools/call',
 'params': {'arguments': {'feedback': 'example'}, 'name': 'report_feedback'}},
)
print(resp.json())

Common Patterns

Search then retrieve
Use list_calling_codes to find items, then get_calling_code to get full details. This two-step pattern is common for exploring data before drilling down.

FAQ

What data does Phone Number Validation provide?

Phone number validation and parsing — country detection, number type, formatting. It exposes 5 tools: validate_phone_number, format_phone_number, list_calling_codes, get_calling_code, report_feedback.

What do I need to get started?

A Gnist API key (free tier: 100 calls/day). Sign up at https://context.gnist.ai/signup.

What format does the Phone Number Validation API return?

JSON, via either MCP protocol (JSON-RPC 2.0) or REST API.

Next Steps

Related Tutorials