psgc-mcp
Version:
Philippine Standard Geographic Code MCP Server - provides hierarchical geographic data for the Philippines
262 lines • 7.43 kB
TypeScript
import { IslandGroup, Region, Province, District, City, Municipality, CityMunicipality, SubMunicipality, Barangay } from '../types/index.js';
/**
* Configuration for PSGC API client
*/
export interface PSGCClientConfig {
baseURL?: string;
timeout?: number;
retries?: number;
retryDelay?: number;
cacheTTL?: number;
}
/**
* Custom error class for PSGC API errors
*/
export declare class PSGCApiError extends Error {
statusCode?: number | undefined;
endpoint?: string | undefined;
details?: unknown | undefined;
constructor(message: string, statusCode?: number | undefined, endpoint?: string | undefined, details?: unknown | undefined);
}
/**
* PSGC API Client - A robust HTTP client for the Philippine Standard Geographic Code API
*/
export declare class PSGCClient {
private client;
private cache;
private config;
constructor(config?: PSGCClientConfig);
/**
* Handle API errors with retry logic
*/
private handleError;
/**
* Generate cache key for request
*/
private getCacheKey;
/**
* Check if cache entry is valid
*/
private isCacheValid;
/**
* Get data from cache
*/
private getFromCache;
/**
* Store data in cache
*/
private setCache;
/**
* Clear expired cache entries
*/
private clearExpiredCache;
/**
* Make HTTP request with caching and retry logic
*/
private request;
/**
* Get all island groups
*/
getIslandGroups(): Promise<IslandGroup[]>;
/**
* Get specific island group by code
*/
getIslandGroup(code: string): Promise<IslandGroup>;
/**
* Get regions in an island group
*/
getIslandGroupRegions(islandGroupCode: string): Promise<Region[]>;
/**
* Get provinces in an island group
*/
getIslandGroupProvinces(islandGroupCode: string): Promise<Province[]>;
/**
* Get districts in an island group
*/
getIslandGroupDistricts(islandGroupCode: string): Promise<District[]>;
/**
* Get cities in an island group
*/
getIslandGroupCities(islandGroupCode: string): Promise<City[]>;
/**
* Get municipalities in an island group
*/
getIslandGroupMunicipalities(islandGroupCode: string): Promise<Municipality[]>;
/**
* Get cities and municipalities in an island group
*/
getIslandGroupCitiesMunicipalities(islandGroupCode: string): Promise<CityMunicipality[]>;
/**
* Get sub-municipalities in an island group
*/
getIslandGroupSubMunicipalities(islandGroupCode: string): Promise<SubMunicipality[]>;
/**
* Get barangays in an island group
*/
getIslandGroupBarangays(islandGroupCode: string): Promise<Barangay[]>;
/**
* Get all regions
*/
getRegions(): Promise<Region[]>;
/**
* Get specific region by code
*/
getRegion(code: string): Promise<Region>;
/**
* Get provinces in a region
*/
getRegionProvinces(regionCode: string): Promise<Province[]>;
/**
* Get districts in a region
*/
getRegionDistricts(regionCode: string): Promise<District[]>;
/**
* Get cities in a region
*/
getRegionCities(regionCode: string): Promise<City[]>;
/**
* Get municipalities in a region
*/
getRegionMunicipalities(regionCode: string): Promise<Municipality[]>;
/**
* Get cities and municipalities in a region
*/
getRegionCitiesMunicipalities(regionCode: string): Promise<CityMunicipality[]>;
/**
* Get sub-municipalities in a region
*/
getRegionSubMunicipalities(regionCode: string): Promise<SubMunicipality[]>;
/**
* Get barangays in a region
*/
getRegionBarangays(regionCode: string): Promise<Barangay[]>;
/**
* Get all provinces
*/
getProvinces(): Promise<Province[]>;
/**
* Get specific province by code
*/
getProvince(code: string): Promise<Province>;
/**
* Get cities in a province
*/
getProvinceCities(provinceCode: string): Promise<City[]>;
/**
* Get municipalities in a province
*/
getProvinceMunicipalities(provinceCode: string): Promise<Municipality[]>;
/**
* Get cities and municipalities in a province
*/
getProvinceCitiesMunicipalities(provinceCode: string): Promise<CityMunicipality[]>;
/**
* Get sub-municipalities in a province
*/
getProvinceSubMunicipalities(provinceCode: string): Promise<SubMunicipality[]>;
/**
* Get barangays in a province
*/
getProvinceBarangays(provinceCode: string): Promise<Barangay[]>;
/**
* Get all districts
*/
getDistricts(): Promise<District[]>;
/**
* Get specific district by code
*/
getDistrict(code: string): Promise<District>;
/**
* Get cities in a district
*/
getDistrictCities(districtCode: string): Promise<City[]>;
/**
* Get municipalities in a district
*/
getDistrictMunicipalities(districtCode: string): Promise<Municipality[]>;
/**
* Get cities and municipalities in a district
*/
getDistrictCitiesMunicipalities(districtCode: string): Promise<CityMunicipality[]>;
/**
* Get sub-municipalities in a district
*/
getDistrictSubMunicipalities(districtCode: string): Promise<SubMunicipality[]>;
/**
* Get barangays in a district
*/
getDistrictBarangays(districtCode: string): Promise<Barangay[]>;
/**
* Get all cities
*/
getCities(): Promise<City[]>;
/**
* Get specific city by code
*/
getCity(code: string): Promise<City>;
/**
* Get barangays in a city
*/
getCityBarangays(cityCode: string): Promise<Barangay[]>;
/**
* Get all municipalities
*/
getMunicipalities(): Promise<Municipality[]>;
/**
* Get specific municipality by code
*/
getMunicipality(code: string): Promise<Municipality>;
/**
* Get barangays in a municipality
*/
getMunicipalityBarangays(municipalityCode: string): Promise<Barangay[]>;
/**
* Get all sub-municipalities
*/
getSubMunicipalities(): Promise<SubMunicipality[]>;
/**
* Get specific sub-municipality by code
*/
getSubMunicipality(code: string): Promise<SubMunicipality>;
/**
* Get barangays in a sub-municipality
*/
getSubMunicipalityBarangays(subMunicipalityCode: string): Promise<Barangay[]>;
/**
* Get all cities and municipalities
*/
getCitiesMunicipalities(): Promise<CityMunicipality[]>;
/**
* Get specific city or municipality by code
*/
getCityMunicipality(code: string): Promise<CityMunicipality>;
/**
* Get barangays in a city or municipality
*/
getCityMunicipalityBarangays(cityOrMunicipalityCode: string): Promise<Barangay[]>;
/**
* Get all barangays
*/
getBarangays(): Promise<Barangay[]>;
/**
* Get specific barangay by code
*/
getBarangay(code: string): Promise<Barangay>;
/**
* Clear all cached data
*/
clearCache(): void;
/**
* Clear expired cache entries
*/
cleanupCache(): void;
/**
* Get cache statistics
*/
getCacheStats(): {
size: number;
entries: string[];
};
}
export declare const psgcClient: PSGCClient;
//# sourceMappingURL=psgc-client.d.ts.map