BUILD WITH HAZE
Connect your assistant
to Haze.
Ask a compatible AI assistant for Singapore air readings, trends and source-dated guidance. The public MCP server also provides mask and air-purifier affiliate links when requested.
API version 1 · Guide updated
Connect a remote MCP client
Use a client that supports remote Streamable HTTP MCP servers. Add this server URL:
https://haze.danielk.am/mcpNo Haze account, API key or OAuth login is required. The server is public and read-only. It provides request-time tools, not background monitoring or push notifications.
- Open your client’s MCP or connector settings and choose its remote HTTP server option.
- Enter the endpoint above. Choose Streamable HTTP if the client asks for a transport.
- Connect and inspect the four Haze tools. Approve a tool call using your client’s normal controls.
- Ask for a region and the source times, for example: “Show central Singapore’s 24-hour PSI and 1-hour PM2.5, including their source times and any warnings.”
Client support depends on the installed version, account features and administrator policy. Some clients accept only local commands or a different transport. Check your client’s documentation if the URL field is missing; the public REST API remains available.
Codex CLI
In a Codex CLI version with remote MCP support, add the server:
codex mcp add haze --url https://haze.danielk.am/mcpThen reopen your Codex session and check that Haze’s tools are available. OpenAI’s official Codex MCP documentation covers MCP configuration and environment-specific restrictions.
A remote-client JSON example
For clients that use the portable mcpServers format with HTTP entries, the configuration is:
{
"mcpServers": {
"haze": {
"type": "http",
"url": "https://haze.danielk.am/mcp"
}
}
}This is not a universal client configuration file. For example, VS Code’s .vscode/mcp.json uses servers as the top-level key. The official VS Code guide documents both formats. Use the format and location your client requires.
Choose a Haze tool
| Tool | Arguments and result |
|---|---|
haze_get_conditions | region: all (default) or north, south, east, west, central. Returns readings, severity labels, source times and warnings. |
haze_get_trends | region: central (default), all or one region. metric: all (default), psi or pm25. Returns the fixed last-24-hour hourly history, including gaps. |
haze_get_products | category: masks (default) or purifiers. limit: integer 1–10 (default 2). offset: integer 0–10 (default 0). Returns catalogue entries, actual affiliate links and a disclosure. |
haze_get_guide | No arguments. Returns structured, source-dated PM2.5 and PSI forecast-advisory guidance with caveats. It does not fetch a live forecast. |
Results include structured data and a text representation. Product results also include Markdown affiliate links and a commission disclosure. The tools do not place orders, change accounts or store a location. For individual product links, preserve the returned affiliate URL rather than constructing one from the product ID.
Try: “Compare the five regions’ PM2.5 trend over the last 24 hours. Mark missing points.” Or: “Show two air purifiers with their price-check times, product links and affiliate disclosure.”
Test the connection with curl
These requests use the 2025-11-25 MCP protocol version. A normal browser GET to /mcp is not a connection test: this stateless endpoint uses HTTP POST and JSON-RPC.
- Initialize. Send the client information and the protocol version.
curl --fail-with-body https://haze.danielk.am/mcp \
-H 'Content-Type: application/json' \
-H 'Accept: application/json, text/event-stream' \
--data '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-11-25","capabilities":{},"clientInfo":{"name":"haze-curl","version":"1.0.0"}}}'Expect a JSON-RPC result with the negotiated protocolVersion, server information and tool capability. Use that negotiated version in MCP-Protocol-Version on later requests. The examples below use 2025-11-25.
- Finish initialization. Send the notification. A notification has no JSON-RPC
id.
curl --fail-with-body https://haze.danielk.am/mcp \
-H 'Content-Type: application/json' \
-H 'Accept: application/json, text/event-stream' \
-H 'MCP-Protocol-Version: 2025-11-25' \
--data '{"jsonrpc":"2.0","method":"notifications/initialized"}'- List the tools. Confirm that the four Haze tool names appear.
curl --fail-with-body https://haze.danielk.am/mcp \
-H 'Content-Type: application/json' \
-H 'Accept: application/json, text/event-stream' \
-H 'MCP-Protocol-Version: 2025-11-25' \
--data '{"jsonrpc":"2.0","id":2,"method":"tools/list","params":{}}'- Call a tool. Request the west region’s readings.
curl --fail-with-body https://haze.danielk.am/mcp \
-H 'Content-Type: application/json' \
-H 'Accept: application/json, text/event-stream' \
-H 'MCP-Protocol-Version: 2025-11-25' \
--data '{"jsonrpc":"2.0","id":3,"method":"tools/call","params":{"name":"haze_get_conditions","arguments":{"region":"west"}}}'Read the tool’s result and any isError flag, not just the HTTP status. Haze is stateless, so no session ID needs to be saved. With the 2025 protocol used in these curl examples, the JSON-RPC result is wrapped in a Server-Sent Events response: read the JSON after data:. The response then finishes. This is Streamable HTTP, with no separate /sse endpoint or persistent GET subscription. The MCP transport specification explains the headers and initialization sequence.
Keep readings and recommendations accurate
Tell your assistant to retain each source timestamp and any delayed, partial or unavailable status. A fetch time is not a measurement time. A null value means unavailable data, never zero. Keep gaps in trends visible.
The 24-hour PSI is a measured index; 1-hour PM2.5 is a concentration in µg/m³. The PSI health-advisory table applies to a forecast category and must not be presented as a live forecast from a measured reading. The air-quality guide explains the distinction.
Product links may earn us a commission. Keep the affiliate disclosure beside those links, and show the returned price-check time when quoting a price. Ask readers to check their variant and final price on Shopee. Commercial results do not imply NEA endorsement.
Readings are from NEA via data.gov.sg under the Singapore Open Data Licence. Preserve attribution, source dates and the independent-project disclaimer. Haze’s hosting providers process standard web request information. Your client’s own privacy policy also applies to prompts and tool results it handles.
Data is cached for 10 minutes. Request a refresh no more than once every 10 minutes. The public API and MCP endpoint share a limit of 60 requests per minute per network address seen by the server. Shared networks, reverse proxies and gateways may share that allowance. Haze has no availability guarantee.
If the client cannot connect
- 400 · Request or protocol problem
- Use valid JSON-RPC, an accepted protocol version and the exact tool argument names. Don’t add query parameters to the MCP URL.
- 403 · Host or origin rejected
- Use the public HTTPS hostname directly. Browser-based clients with an unapproved
Origincannot call this endpoint. Use a remote client with a server-side HTTP connection, or the public REST API for a browser integration. - 405 · Method not allowed
- Use the HTTP
POSTrequests above. A normal browser visit or an older SSE-only client does not use this transport. - 406 · Response type not accepted
- Send
Accept: application/json, text/event-stream. - 413 · Request too large
- Keep the JSON request below 64 KiB. Send the tool arguments only, rather than a conversation history.
- 415 · Wrong content type
- Send
Content-Type: application/json. - 429 · Request limit reached
- Wait for
Retry-Afterseconds. Stop automatic rapid retries and respect the 10-minute data refresh interval. - 503 or an error tool result
- Read the message, back off and try later. If a source is delayed or unavailable, preserve that state in your answer rather than filling in a value.
If curl succeeds but your assistant cannot connect, check its remote Streamable HTTP support, version and administrator settings. Don’t add an API key: Haze does not require one. To build a direct integration instead, follow the REST API guide.