Documentation
¶
Overview ¶
Package worldmonitor is the official Go SDK for the World Monitor global-intelligence API (https://worldmonitor.app) — country briefs, risk scores, conflict/cyber/market/news feeds, and MCP tools without writing an HTTP integration.
Stdlib-only (zero dependencies), MCP-first — the same design as the worldmonitor npm CLI this mirrors (cli/ in the main repository). The MCP server (https://worldmonitor.app/mcp) is the live, documented agent surface: tools/list is public, and tools/call (used by the curated helpers) authenticates with a user API key. A small REST escape hatch (Get/Health) rounds it out for host-relative and self-hosted use.
client := worldmonitor.New("wm_...") // or "" to read WORLDMONITOR_API_KEY
risk, err := client.CountryRisk(ctx, "IR", nil)
quotes, err := client.CallTool(ctx, "get_market_data", worldmonitor.Args{"asset_class": "crypto"})
health, err := client.Get(ctx, "/api/health", nil)
Every tool accepts an optional "jmespath" argument for server-side projection (typically an 80-95% response-size cut), e.g. Args{"jmespath": "hotspots[].name"}.
Index ¶
- Constants
- type APIError
- type Args
- type Client
- func (c *Client) CallTool(ctx context.Context, name string, args Args) (json.RawMessage, error)
- func (c *Client) ConflictEvents(ctx context.Context, args Args) (json.RawMessage, error)
- func (c *Client) CountryBrief(ctx context.Context, countryCode string, args Args) (json.RawMessage, error)
- func (c *Client) CountryRisk(ctx context.Context, countryCode string, args Args) (json.RawMessage, error)
- func (c *Client) CyberThreats(ctx context.Context, args Args) (json.RawMessage, error)
- func (c *Client) ForecastPredictions(ctx context.Context, args Args) (json.RawMessage, error)
- func (c *Client) Get(ctx context.Context, path string, params Args) (json.RawMessage, error)
- func (c *Client) Health(ctx context.Context) (json.RawMessage, error)
- func (c *Client) ListPrompts(ctx context.Context) (json.RawMessage, error)
- func (c *Client) ListResources(ctx context.Context) (json.RawMessage, error)
- func (c *Client) ListTools(ctx context.Context) (json.RawMessage, error)
- func (c *Client) MaritimeActivity(ctx context.Context, countryCode string, args Args) (json.RawMessage, error)
- func (c *Client) MarketData(ctx context.Context, args Args) (json.RawMessage, error)
- func (c *Client) NaturalDisasters(ctx context.Context, args Args) (json.RawMessage, error)
- func (c *Client) NewsIntelligence(ctx context.Context, args Args) (json.RawMessage, error)
- func (c *Client) SanctionsData(ctx context.Context, args Args) (json.RawMessage, error)
- func (c *Client) WorldBrief(ctx context.Context, args Args) (json.RawMessage, error)
- type MCPError
Constants ¶
const ( DefaultBaseURL = "https://api.worldmonitor.app" DefaultMCPURL = "https://worldmonitor.app/mcp" // APIKeyHeader is the header the API accepts for a user-issued key // (alias: X-Api-Key). APIKeyHeader = "X-WorldMonitor-Key" // MCPAuthErrorCode is the JSON-RPC error code the MCP server returns // when a call needs authentication. MCPAuthErrorCode = -32001 )
const UserAgent = "worldmonitor-go/" + Version + " (+https://worldmonitor.app)"
UserAgent identifies the SDK on every request. Cloudflare's WAF challenges generic library User-Agents (Go-http-client, curl, empty) on the API edge, so we always identify ourselves.
const Version = "0.1.1"
Version of this SDK. The release workflow checks it against the sdk/go/vX.Y.Z tag before warming the module proxy.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type APIError ¶
type APIError struct {
Status int
Body json.RawMessage
}
APIError is a REST or transport-level failure (non-2xx HTTP response).
type Client ¶
type Client struct {
// APIKey is the user API key sent as X-WorldMonitor-Key.
APIKey string
// BaseURL is the REST base (default https://api.worldmonitor.app).
BaseURL string
// MCPURL is the MCP endpoint (default https://worldmonitor.app/mcp).
MCPURL string
// HTTPClient performs requests; override its Transport in tests.
HTTPClient *http.Client
}
Client is a thin client for the World Monitor MCP server and REST API. The zero value is not usable; construct it with New.
func New ¶
New returns a Client. An empty apiKey falls back to the WORLDMONITOR_API_KEY (or WM_API_KEY) environment variable; the REST and MCP endpoints honour WORLDMONITOR_BASE_URL and WORLDMONITOR_MCP_URL.
func (*Client) CallTool ¶
CallTool calls an MCP tool by name and returns the unwrapped JSON-RPC result. A nil args map is allowed.
func (*Client) ConflictEvents ¶
ConflictEvents returns recent conflict events (country, min_fatalities, limit, ...).
func (*Client) CountryBrief ¶
func (c *Client) CountryBrief(ctx context.Context, countryCode string, args Args) (json.RawMessage, error)
CountryBrief returns the AI strategic brief for a country (ISO 3166-1 alpha-2 code).
func (*Client) CountryRisk ¶
func (c *Client) CountryRisk(ctx context.Context, countryCode string, args Args) (json.RawMessage, error)
CountryRisk returns country risk / resilience scores (ISO 3166-1 alpha-2 code).
func (*Client) CyberThreats ¶
CyberThreats returns cyber-threat indicators (min_severity, threat_type, country, ...).
func (*Client) ForecastPredictions ¶
ForecastPredictions returns scenario forecasts (domain, region, ...).
func (*Client) Get ¶
Get performs a GET against a raw REST path (host-relative, e.g. "/api/health") with optional query parameters.
func (*Client) ListPrompts ¶
ListPrompts lists MCP prompt templates (public).
func (*Client) ListResources ¶
ListResources lists MCP resources (public).
func (*Client) MaritimeActivity ¶
func (c *Client) MaritimeActivity(ctx context.Context, countryCode string, args Args) (json.RawMessage, error)
MaritimeActivity returns maritime / port activity for a country (ISO 3166-1 alpha-2 code).
func (*Client) MarketData ¶
MarketData returns equities, commodities, crypto and FX quotes.
func (*Client) NaturalDisasters ¶
NaturalDisasters returns earthquakes, fires and storms (dataset, active_only, min_magnitude, ...).
func (*Client) NewsIntelligence ¶
NewsIntelligence returns classified news intelligence (topic, country, alerts_only, ...).
func (*Client) SanctionsData ¶
SanctionsData returns sanctions designations (country, entity_type, query, ...).
func (*Client) WorldBrief ¶
WorldBrief returns the live global situation brief.