A Model Context Protocol (MCP) server that provides access to the Philippine Standard Geographic Code (PSGC) API, offering hierarchical geographic data for the Philippines.
- Complete Geographic Hierarchy: Access to island groups, regions, provinces, cities, municipalities, barangays, and districts
- Search Capabilities: Find geographic entities by name across all levels
- Code Validation: Validate PSGC codes and get complete hierarchy information
- Real-time Data: Direct access to the official PSGC API
- Type-safe: Built with TypeScript for reliable data structures
npm install -g psgc-mcp
Add to your MCP configuration file:
{
"mcpServers": {
"psgc-mcp": {
"command": "npx",
"args": ["-y", "psgc-mcp"],
"transport": "stdio"
}
}
}
Add to your Claude Desktop configuration:
{
"mcpServers": {
"psgc-mcp": {
"command": "npx",
"args": ["-y", "psgc-mcp"],
"transport": "stdio"
}
}
}
- Clone the repository
- Install dependencies:
npm install
- Build the project:
npm run build
- Run locally:
npm start
The server provides a comprehensive set of tools for accessing PSGC data, categorized by geographic level.
-
get_island_groups
: List all island groups. -
get_island_group
: Get a specific island group by its code (e.g.,"luzon"
). -
get_island_group_regions
: Get all regions within a specific island group. -
get_island_group_provinces
: Get all provinces within a specific island group. -
get_island_group_districts
: Get all districts within a specific island group. -
get_island_group_cities
: Get all cities within a specific island group. -
get_island_group_municipalities
: Get all municipalities within a specific island group. -
get_island_group_cities_municipalities
: Get all cities and municipalities within a specific island group. -
get_island_group_sub_municipalities
: Get all sub-municipalities within a specific island group. -
get_island_group_barangays
: Get all barangays within a specific island group.
-
get_regions
: List all regions. -
get_region
: Get a specific region by its code (e.g.,"130000000"
). -
get_region_provinces
: Get all provinces within a specific region. -
get_region_districts
: Get all districts within a specific region. -
get_region_cities
: Get all cities within a specific region. -
get_region_municipalities
: Get all municipalities within a specific region. -
get_region_cities_municipalities
: Get all cities and municipalities within a specific region. -
get_region_sub_municipalities
: Get all sub-municipalities within a specific region. -
get_region_barangays
: Get all barangays within a specific region.
-
get_provinces
: List all provinces. -
get_province
: Get a specific province by its code (e.g.,"012800000"
). -
get_province_cities
: Get all cities within a specific province. -
get_province_municipalities
: Get all municipalities within a specific province. -
get_province_cities_municipalities
: Get all cities and municipalities within a specific province. -
get_province_sub_municipalities
: Get all sub-municipalities within a specific province. -
get_province_barangays
: Get all barangays within a specific province.
-
get_districts
: List all districts. -
get_district
: Get a specific district by its code (e.g.,"133900000"
). -
get_district_cities
: Get all cities within a specific district. -
get_district_municipalities
: Get all municipalities within a specific district. -
get_district_cities_municipalities
: Get all cities and municipalities within a specific district. -
get_district_sub_municipalities
: Get all sub-municipalities within a specific district. -
get_district_barangays
: Get all barangays within a specific district.
-
get_cities
: List all cities. -
get_city
: Get a specific city by its code (e.g.,"012805000"
). -
get_city_barangays
: Get all barangays within a specific city.
-
get_municipalities
: List all municipalities. -
get_municipality
: Get a specific municipality by its code (e.g.,"012801000"
). -
get_municipality_barangays
: Get all barangays within a specific municipality.
-
get_sub_municipalities
: List all sub-municipalities. -
get_sub_municipality
: Get a specific sub-municipality by its code (e.g.,"133901000"
). -
get_sub_municipality_barangays
: Get all barangays within a specific sub-municipality.
-
get_cities_municipalities
: List all cities and municipalities. -
get_city_municipality
: Get a specific city or municipality by its code. -
get_city_municipality_barangays
: Get all barangays within a specific city or municipality.
-
get_barangays
: List all barangays. -
get_barangay
: Get a specific barangay by its code (e.g.,"012805001"
).
-
search_by_name
: Search for geographic entities by name across all levels. -
get_hierarchy
: Get the complete hierarchy for a specific PSGC code. -
validate_code
: Validate if a geographic code exists and get its details.
- Static Data: Access pre-loaded static data for all geographic levels.
- Dynamic Queries: Perform parameterized queries to fetch specific datasets.
- Hierarchical Data: Use resource templates to retrieve complete hierarchical information for any given PSGC code.
- Common Queries: Use pre-defined prompts for common geographic questions (e.g., "What is the capital of [province]?").
- Guided Discovery: Interactive prompts to help you explore the geographic hierarchy.
- Data Validation: Prompts to validate PSGC codes and geographic names.
{
"tool": "get_regions",
"arguments": {}
}
{
"tool": "get_provinces",
"arguments": {
"region_code": "130000000"
}
}
{
"tool": "search_by_name",
"arguments": {
"query": "Manila",
"type": "city"
}
}
{
"tool": "get_hierarchy",
"arguments": {
"code": "133900000"
}
}
The server connects to the official PSGC API at https://psgc.gitlab.io/api/
.
PSGC codes follow a hierarchical format:
- Island Groups: 010000000, 020000000, 030000000
- Regions: 130000000 (NCR), 140000000 (CAR), etc.
- Provinces: 133900000 (Manila), 137400000 (Cebu), etc.
- Cities/Municipalities: 133903000 (Manila City), 137404000 (Cebu City), etc.
- Barangays: 133903001 (Barangay 1, Manila), etc.
- Node.js 18 or higher
- npm or yarn
git clone https://github.com/your-username/psgc-mcp.git
cd psgc-mcp
npm install
npm run build
npm run dev
npm test
npm run inspect
- Fork the repository
- Create a feature branch:
git checkout -b feature-name
- Make your changes
- Add tests for new functionality
- Run tests:
npm test
- Commit your changes:
git commit -am 'Add feature'
- Push to the branch:
git push origin feature-name
- Submit a pull request
MIT License - see LICENSE file for details.
For issues and questions, please open an issue on the GitHub repository.