MCP Server for DataGovMy
This project is an MCP (Model Context Protocol) server written in Go that exposes tools and resources from DataGovMy — Malaysia's open government data platform. It allows you to access Malaysian government datasets (such as population statistics) programmatically via Cline (an AI agent) and Cursor (an AI-powered code editor).
Features
- Exposes DataGovMy datasets (e.g., population by state, age, ethnicity, etc.) as MCP tools
- Enables AI-powered access to Malaysian government data via Cline and Cursor
- Written in Go for performance and portability
- Easily extensible to support more DataGovMy datasets
About This Project
This repository provides an MCP (Model Context Protocol) server that acts as an interface to connect to the data.gov.my API (where available). It is designed for MCP integration and is not specific to any single assistant or application.
Why Go? You might be wondering why this project uses Go instead of the official MCP package in Node.js. The answer is simple: I know Go better, it has fewer dependencies, and I can easily release binaries for different operating systems.
No vector database, custom LLM training, or RAG: This project does not use any kind of vector database, custom large language model training, or retrieval-augmented generation (RAG). It is purely an MCP server that exposes DataGovMy datasets as tools for AI agents and developer tools.
Upcoming DataGovMy Assistant: The DataGovMy team is working on a ChatGPT-style assistant, MyDataGPT, which will provide a conversational interface to Malaysian government data. This MCP server is a separate project focused on MCP integration.
Available Tools
This MCP server currently exposes the following tools:
- births: Number of people born daily in Malaysia, based on registrations with JPN from 1920 to the present.
- fuelprice: Weekly retail prices of RON95 petrol, RON97 petrol, and diesel in Malaysia.
- population_malaysia: Population at national level from 1970 to 2024, by sex, age group and ethnicity.
- population_state: Population at state level from 1970 to 2024, by sex, age group and ethnicity.
- registration_transactions_car: Car registration transactions from 2000 to the present. Filter by registration date, type (motokar, MPV, jeep, pick-up, window van), maker, model, colour, fuel type (petrol, diesel, green diesel, natural gas, LNG, hydrogen, electric, hybrid), and state of registration.
- hh_income: Mean and median monthly gross household income in Malaysia from 1970 to 2022.
Want to add more tools? Contributions are welcome! Please open an issue or submit a pull request if you'd like to help extend the server with additional DataGovMy datasets or features.
Download
You can download the latest release for Windows, macOS, or Linux from the GitHub Releases page.
- Go to the Releases page.
- Find the version you want (e.g.,
v1.0.0
). - Download the binary for your operating system:
*_windows_amd64.zip
for Windows*_darwin_amd64.tar.gz
for macOS*_linux_amd64.tar.gz
for Linux
- Extract the downloaded file and follow the usage instructions.
What is DataGovMy?
DataGovMy is Malaysia's open data platform, providing datasets on demographics, economics, health, and more. This MCP server makes those datasets accessible to AI agents and developer tools.
Prerequisites
- Go 1.18 or newer
- Cline (installed and configured)
- Cursor (optional, for AI-powered code editing)
- (Optional) Node.js if you want to use Cline's browser tools
Installation
Clone this repository:
git clone <your-repo-url> cd custom
Install Go dependencies:
go mod tidy
Build the server:
go build -o mcp-datagovmy
Run the server:
./mcp-datagovmy
By default, the server will start on
localhost:8080
. You can change the port by editing the code or using environment variables if supported.
Using with Cline or Cursor (via stdio)
You can configure Cline (and Cursor) to launch this MCP server as a subprocess and communicate via stdio, which is more robust for local development than HTTP.
Build the server:
go build -o mcp-datagovmy
Update your Cline (or Cursor) MCP config file (usually
cline_mcp_settings.json
). Add an entry like this:{ "mcpServers": { "datagovmy": { "disabled": false, "timeout": 60, "command": "/absolute/path/to/mcp-datagovmy", "transportType": "stdio", "autoApprove": [ "population_malaysia", "population_state" ] } } }
- command: Absolute path to your built server binary (e.g.,
/Users/youruser/Documents/Codes/mcp/custom/mcp-datagovmy
) - transportType: Must be
"stdio"
for subprocess communication - autoApprove: (Optional) List of tool names to auto-approve without prompting
- timeout: (Optional) How long to wait for a response (in seconds)
- disabled: Set to
false
to enable the server
- command: Absolute path to your built server binary (e.g.,
Save and reload Cline or Cursor. The server will be launched automatically as needed.
Use Cline or Cursor to access DataGovMy tools.
Example usage:
Use the "population_malaysia" tool from the "datagovmy" server with age="overall", date="2024-01-01", ethnicity="overall", sex="both".
Using with Cursor
- Open your project in Cursor.
- Ensure Cline is connected and your MCP server is running.
- Use Cursor's AI features to interact with DataGovMy tools.
- For example, you can ask Cursor to "use the population_state tool from the datagovmy server with state='Selangor', age='0-4', date='2024-01-01', ethnicity='chinese', sex='male'".
Example Workflow
Start your MCP server:
./mcp-datagovmy
Connect Cline to your server as described above.
In Cline or Cursor, run a command like:
Use the "population_state" tool from the "datagovmy" server with state="Selangor", age="0-4", date="2024-01-01", ethnicity="chinese", sex="male".
Extending the Server
The server is now modularized for easier extension. To add a new DataGovMy tool:
Create a new file in the
tools/
directory (e.g.,tools/my_new_tool.go
).- Define your tool using
mcp.NewTool
and implement its handler function in this file. - See existing files in
tools/
(likebirths.go
,population_malaysia.go
) for examples.
- Define your tool using
Register your tool and handler in
tools/tool.go
:Import your new tool and handler at the top if needed.
Add an entry to the map returned by
LoadTools()
:&myNewTool: myNewToolHandler,
Rebuild and restart the server to apply your changes.
This modular structure makes it easy to add, update, or debug individual tools without affecting others.
Tip for contributors: When implementing new tools or handlers, refer to the DataGovMy Developer Portal for guidance on API request structure, available endpoints, and best practices.
Troubleshooting
- Port already in use: Change the port in the code or stop the conflicting process.
- Cline can't connect: Ensure the server is running and the URL is correct in Cline's settings.
- Go build errors: Make sure you have the correct Go version and all dependencies installed.
License
MIT License
For more information, see the Model Context Protocol documentation and DataGovMy.