Get started
AI & agents

Build your own agent

Build your own agent

Give your agent Mountaya's routing, places, and terrain. If your agent framework speaks MCP, connect it to the MCP server with a key pair and it gets 14 tools at once. Otherwise, write tools that call the Data API, as below.

1

Keep the keys on your server

Your agent's code reads both keys from its environment. Never put them in a prompt: the model must not see them.

Terminal
export MOUNTAYA_PUBLISHABLE_KEY="pk_your_publishable_key"
export MOUNTAYA_SECRET_KEY="sk_your_secret_key"

The publishable key needs the data scope. Create both under Organization → API keys in the Mountaya app.

2

Mint a session token, and reuse it

Every Data API call carries a session token. Mint one with the secret key, and reuse it until shortly before it expires.

export MOUNTAYA_SESSION_TOKEN=$(curl -s -X POST https://api.mountaya.com/v1/sessions \
  -H "X-API-Key: $MOUNTAYA_SECRET_KEY" \
  -H "Content-Type: application/json" \
  -d "{\"publishable_key\": \"$MOUNTAYA_PUBLISHABLE_KEY\"}" | jq -r .data.token)

3

Describe the tool to the model

Give the model a name, a description that says when to use the tool, and a JSON Schema for its input:

Tool definition
{
  "name": "plan_route",
  "description": "Plan a hiking route through two or more points. Returns the distance in meters, the duration in seconds, and a one-line summary of the ground.",
  "input_schema": {
    "type": "object",
    "properties": {
      "waypoints": {
        "type": "array",
        "description": "2 to 45 points to pass through, in order, each as [longitude, latitude].",
        "minItems": 2,
        "maxItems": 45,
        "items": {
          "type": "array",
          "items": { "type": "number" },
          "minItems": 2,
          "maxItems": 2
        }
      }
    },
    "required": ["waypoints"]
  }
}

Agent SDKs name the schema field differently, such as input_schema or parameters.

4

Run the tool

When the model calls plan_route, your handler queries directions and returns a compact result:

curl https://data.mountaya.com/graphql \
  -H "X-API-Key: $MOUNTAYA_PUBLISHABLE_KEY" \
  -H "X-Session-Token: $MOUNTAYA_SESSION_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "query": "query Directions($input: DirectionsInput!) { directions(input: $input) { routes { distance duration summary } } }",
    "variables": {
      "input": {
        "activity": "HIKING_AND_TRAIL",
        "waypoints": [[6.8712, 45.9231], [6.9271, 45.9822]]
      }
    }
  }'
Result
{
  "distance": 9005.14542243658,
  "duration": 9631.009017156648,
  "summary": "9.0 km, ~2h40m, +277m / -56m elevation, 67% path, 12% track, 8% road."
}

Select only the fields the model needs: every field it reads costs tokens.

Write safely

The Data API only reads, so these tools cannot change anything. Writes go through the Map Studio API, which comes with an agreement. Before you give your agent a tool that writes:

  • Ask first. Have the agent confirm each write with the person, naming what it changes.
  • Act as that person. Mint the token for the member your own sign-in vouches for, as act as a member shows.
  • Make retries safe. Send an Idempotency-Key with each write, and reuse it when the agent retries.

Next steps

Last updated