All tutorials
MCP Address Validation: Integrate Swiftcomplete with Your AI Agent
Swiftcomplete’s Model Context Protocol (MCP) server lets any LLM-powered agent call one endpoint and return a verified, fully-formatted address in milliseconds. This tutorial shows you how to plug it in with just an API key and a couple of lines of code.
See it in action
Watch Jen from the what3words team demonstrate how an AI customer service agent uses the Swiftcomplete MCP to instantly validate an address.
Create a Swiftcomplete account (or sign in) if you’re already registered.
The Swiftcomplete MCP base URL is:
https://mcp.swiftcomplete.com/
You can inspect the MCP API using the OpenAPI manifest: https://mcp.swiftcomplete.com/openapi.yaml
You can import it into Postman, Swagger UI, or your favourite client for auto-generated docs and test calls.
You can use the OpenAPI spec directly to integrate the Swiftcomplete MCP endpoint into any AI agent framework that supports OpenAPI tool definitions.
Example (Code language + OpenAI function calling)
# This script sends a request to the MCP SwiftComplete API to validate an address # and prints the result or suggestions if the address is not found. # Make sure to replace YOUR-SWIFTCOMPLETE-API-KEY with your actual API key. # Usage: python test-openai-mcp.py import openai import requests # 1. Send the address to Swiftcomplete's /validate endpoint headers = { "X-API-Key": "YOUR-SWIFTCOMPLETE-API-KEY", # Paste your Swiftcomplete API key "Content-Type": "application/json" } payload = { "message": "what is the full address for Great Western Studios in London" } response = requests.post( "https://mcp.swiftcomplete.com/validate/", headers=headers, json=payload ) # 2. Handle the response data = response.json() if data["type"] == "match": print(f"Validated address: {data['address']}") elif data["type"] == "ambiguous": print("Suggestions:") for suggestion in data["suggestions"]: print(f"- {suggestion}")
// This code is a Java 8 implementation of a simple HTTP POST request to the Swiftcomplete MCP API. // It sends a JSON payload and prints the response from the server. // Make sure to replace "YOUR-SWIFTCOMPLETE-API-KEY" with your actual API key. // To compile and run this code, you can use the following commands // node test-mcp-sc.js const axios = require('axios'); const headers = { 'X-API-Key': 'YOUR-SWIFTCOMPLETE-API-KEY', // Replace with your actual API key 'Content-Type': 'application/json' }; const payload = { message: 'what is the full address for Great Western Studios in London' }; axios.post('https://mcp.swiftcomplete.com/validate/', payload, { headers }) .then(res => { if (res.data.type === 'match') { console.log('Validated address:', res.data.address); } else if (res.data.type === 'ambiguous') { console.log('Suggestions:'); res.data.suggestions.forEach(s => console.log('-', s)); } }) .catch(err => console.error('Request failed:', err.message));
// This code is a Java 8 implementation of a simple HTTP POST request to the Swiftcomplete MCP API. // It sends a JSON payload and prints the response from the server. // Make sure to replace "enter-your-api" with your actual API key. // To compile and run this code, you can use the following commands: // javac SwiftcompleteMCP.java // java SwiftcompleteMCP package main import ( "bytes" "encoding/json" "fmt" "io" "net/http" ) func main() { url := "https://mcp.swiftcomplete.com/validate/" apiKey := "YOUR-SWIFTCOMPLETE-API-KEY" // Replace with your actual API key body := map[string]string{"message": "what is the full address for Great Western Studios in London"} jsonBody, _ := json.Marshal(body) req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonBody)) req.Header.Set("X-API-Key", apiKey) req.Header.Set("Content-Type", "application/json") resp, err := http.DefaultClient.Do(req) if err != nil { fmt.Println("Request error:", err) return } defer resp.Body.Close() var result map[string]interface{} json.NewDecoder(resp.Body).Decode(&result) if result["type"] == "match" { fmt.Println("Validated address:", result["address"]) } else { fmt.Println("Suggestions:", result["suggestions"]) } }
// This script sends a request to the MCP SwiftComplete API to validate an address // and prints the result or suggestions if the address is not found. // Make sure to replace YOUR-SWIFTCOMPLETE-API-KEY with your actual API key. // Usage: go run test-mcp-sc.go package main import ( "bytes" "encoding/json" "fmt" "net/http" ) func main() { url := "https://mcp.swiftcomplete.com/validate/" apiKey := "YOUR-SWIFTCOMPLETE-API-KEY" // Replace with your actual API key body := map[string]string{"message": "what is the full address for Great Western Studios in London"} jsonBody, _ := json.Marshal(body) req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonBody)) req.Header.Set("X-API-Key", apiKey) req.Header.Set("Content-Type", "application/json") resp, err := http.DefaultClient.Do(req) if err != nil { fmt.Println("Request error:", err) return } defer resp.Body.Close() var result map[string]interface{} json.NewDecoder(resp.Body).Decode(&result) if result["type"] == "match" { fmt.Println("Validated address:", result["address"]) } else { fmt.Println("Suggestions:", result["suggestions"]) } }
# This script sends a request to the MCP SwiftComplete API to validate an address # and prints the result or suggestions if the address is not found. # Make sure to replace YOUR-SWIFTCOMPLETE-API-KEY with your actual API key. # Usage: ruby test-mcp-sc.rb require 'net/http' require 'uri' require 'net/http' require 'uri' require 'json' uri = URI('https://mcp.swiftcomplete.com/validate/') req = Net::HTTP::Post.new(uri) req['X-API-Key'] = 'YOUR-SWIFTCOMPLETE-API-KEY' # Replace with your actual API key req['Content-Type'] = 'application/json' req.body = { message: 'what is the full address for Great Western Studios in London' }.to_json res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http| http.request(req) end data = JSON.parse(res.body) if data['type'] == 'match' puts "Validated address: #{data['address']}" elsif data['type'] == 'ambiguous' puts "Suggestions:" data['suggestions'].each { |s| puts "- #{s}" } end
// This script sends a request to the MCP SwiftComplete API to validate an address // and prints the result or suggestions if the address is not found. // Make sure to replace YOUR-SWIFTCOMPLETE-API-KEY with your actual API key. // Usage: dotnet run using System; using System.Net.Http; using System.Net.Http.Headers; using System.Text; using System.Threading.Tasks; class SwiftcompleteMCP { static async Task Main() { var client = new HttpClient(); var url = "https://mcp.swiftcomplete.com/validate/"; var payload = "{\"message\": \"what is the full address for Great Western Studios in London\"}"; var content = new StringContent(payload, Encoding.UTF8, "application/json"); client.DefaultRequestHeaders.Add("X-API-Key", "YOUR-SWIFTCOMPLETE-API-KEY"); var response = await client.PostAsync(url, content); var result = await response.Content.ReadAsStringAsync(); Console.WriteLine("Response: " + result); } }
// This script sends a request to the MCP SwiftComplete API to validate an address // and prints the result or suggestions if the address is not found. // Make sure to replace YOUR-SWIFTCOMPLETE-API-KEY with your actual API key. // Usage: swift test-mcp-sc.swift import Foundation let url = URL(string: "https://mcp.swiftcomplete.com/validate/")! var request = URLRequest(url: url) request.httpMethod = "POST" request.setValue("application/json", forHTTPHeaderField: "Content-Type") request.setValue("YOUR-SWIFTCOMPLETE-API-KEY", forHTTPHeaderField: "X-API-Key") let payload: [String: String] = [ "message": "what is the full address for Great Western Studios in London" ] request.httpBody = try! JSONSerialization.data(withJSONObject: payload) let semaphore = DispatchSemaphore(value: 0) let task = URLSession.shared.dataTask(with: request) { data, response, error in defer { semaphore.signal() } guard let data = data else { print("No data received.") return } if let json = try? JSONSerialization.jsonObject(with: data) as? [String: Any] { if let type = json["type"] as? String, type == "match" { print("Validated address: \(json["address"] ?? "unknown")") } else if let suggestions = json["suggestions"] as? [String] { print("Suggestions:") for suggestion in suggestions { print("- \(suggestion)") } } else { print("Unexpected response format.") } } else { print("Failed to parse JSON.") } } task.resume() semaphore.wait()
// This script sends a request to the MCP SwiftComplete API to validate an address // and prints the result or suggestions if the address is not found. // Make sure to replace YOUR-SWIFTCOMPLETE-API-KEY with your actual API key. // Usage: dart test-mcp-sc.dart import 'dart:convert'; import 'package:http/http.dart' as http; void main() async { var url = Uri.parse('https://mcp.swiftcomplete.com/validate/'); var headers = { 'X-API-Key': 'YOUR-SWIFTCOMPLETE-API-KEY', 'Content-Type': 'application/json', }; var body = jsonEncode({ 'message': 'what is the full address for Great Western Studios in London', }); var response = await http.post(url, headers: headers, body: body); var data = jsonDecode(response.body); if (data['type'] == 'match') { print('Validated address: ${data['address']}'); } else if (data['type'] == 'ambiguous') { print('Suggestions:'); for (var s in data['suggestions']) { print('- $s'); } } }
// This script sends a request to the MCP SwiftComplete API to validate an address // and prints the result or suggestions if the address is not found. // Make sure to replace YOUR-SWIFTCOMPLETE-API-KEY with your actual API key. // Usage: cargo run use reqwest::blocking::Client; use serde_json::json; fn main() { let client = Client::new(); let api_key = "YOUR-SWIFTCOMPLETE-API-KEY"; // Replace with your actual API key let url = "https://mcp.swiftcomplete.com/validate/"; let body = json!({ "message": "what is the full address for Great Western Studios in London" }); let res = client .post(url) .header("X-API-Key", api_key) .header("Content-Type", "application/json") .json(&body) .send() .unwrap(); let data: serde_json::Value = res.json().unwrap(); match data["type"].as_str() { Some("match") => println!("Validated address: {}", data["address"]), Some("ambiguous") => { println!("Suggestions:"); for s in data["suggestions"].as_array().unwrap() { println!("- {}", s); } } _ => println!("Unexpected response"), } }
<?php // This script sends a request to the MCP SwiftComplete API to validate an address // and prints the result or suggestions if the address is not found. // Make sure to replace YOUR-SWIFTCOMPLETE-API-KEY with your actual API key. // Usage: php test-mcp-sc.php $apiKey = 'YOUR-SWIFTCOMPLETE-API-KEY'; // Replace with your actual API key $url = 'https://mcp.swiftcomplete.com/validate/'; $data = [ 'message' => 'what is the full address for Great Western Studios in London' ]; $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_HTTPHEADER, [ 'X-API-Key: ' . $apiKey, 'Content-Type: application/json' ]); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data)); $response = curl_exec($ch); if (curl_errno($ch)) { echo 'Request Error: ' . curl_error($ch); exit; } curl_close($ch); $result = json_decode($response, true); if ($result['type'] === 'match') { echo "Validated address: " . $result['address'] . "\n"; } elseif ($result['type'] === 'ambiguous') { echo "Suggestions:\n"; foreach ($result['suggestions'] as $s) { echo "- $s\n"; } } else { echo "Unexpected response:\n"; print_r($result); }
Response:
Validated address: Great Western Studios 65 Alfred Road LONDON W2 5EU United Kingdom
Note: Make sure you replace “
YOUR-SWIFTCOMPLETE-API-KEY
” with your Swiftcomplete API key
How your AI agent might benefit from Swiftcomplete:
- Customer service assistants: Ensuring address info in chats is accurate before updating CRMs
- Travel planners: Validating pick-up/drop-off points for smoother journeys
- e-Commerce agents: Confirming customer shipping info at checkout in real-time
- Voice-based assistants: Transcribing and resolving spoken address input into verified location data
- CRM assistants: Sales and support teams can rely on AI agents to maintain clean, validated address data across customer records
- Personal shopping assistants: validating delivery addresses to prevent fulfilment issues
Note: To find out more our the benefits of our MCP server, you can read our blog and to learn about Swiftcomplete, visit our webpage.
Need help, or have any questions? If your AI agents handle addresses, don’t leave accuracy to chance. Swiftcomplete’s MCP server makes it effortless to deliver reliable, instant validation, all with a single, powerful integration.
If you need any help getting started or to learn more about Swiftcomplete and our MCP, reach out to our customer support team at swiftcompletesales@what3words.com.