Skip to content

Connect NationsGlory to AI Agents: Automate Planning & HDV

Learn how to connect NationsGlory to AI agents using Truto's /tools endpoint. Fetch tools programmatically and build autonomous workflows for auction houses.

Sidharth Verma Sidharth Verma · · 10 min read
Connect NationsGlory to AI Agents: Automate Planning & HDV

You want to connect NationsGlory to an AI agent so your systems can independently query the auction house, analyze matchmaking ratings (MMR), automate guild planning, and register event webhooks based on real-time server conditions. Here is exactly how to do it using Truto's /tools endpoint and SDK, bypassing the need to manually reverse-engineer the API or manage complex schema transformations.

Giving a Large Language Model (LLM) read and write access to a specialized platform like NationsGlory is a severe engineering challenge. You either spend weeks building and maintaining a custom wrapper that understands the nuances of multi-server state routing, or you use a managed infrastructure layer that standardizes the abstraction for you. If your team uses ChatGPT, check out our guide on connecting NationsGlory to ChatGPT, or if you are building on Anthropic's models, read our guide on connecting NationsGlory to Claude. For developers building custom autonomous workflows, you need a programmatic way to fetch these tools and bind them natively to your agent framework.

This guide breaks down exactly how to fetch AI-ready tools for NationsGlory, bind them to an LLM using LangChain (or any framework like LangGraph, CrewAI, or Vercel AI SDK), and execute complex server coordination workflows. For a deeper look at the architecture behind this tool-calling approach, refer to our research on architecting AI agents and the SaaS integration bottleneck.

The Engineering Reality of Custom NationsGlory Connectors

Building AI agents is easy. Connecting them to external APIs is hard. Giving an LLM access to external data sounds simple in a Jupyter notebook - you write a fetch request and wrap it in an @tool decorator. In a production environment, this collapses rapidly, especially when dealing with gaming and community management APIs like NationsGlory.

If you decide to integrate NationsGlory manually, you own the entire integration lifecycle. The NationsGlory API introduces highly specific challenges that break the standard assumptions of most agent frameworks.

The Missing Schema Trap

Agent frameworks rely on detailed OpenAPI specifications to teach the LLM what a tool does and what data it will return. The NationsGlory API is notorious for undocumented response payloads. Core endpoints like listing auction house (HDV) items or querying planning events return successful 200 responses, but the upstream documentation does not enumerate the response fields.

If you hand an LLM an empty or generic response schema, it hallucinates. The agent might assume an auction house item has a price_usd field when the actual API returns an internal currency integer. To fix this in-house, you have to manually execute every endpoint, map the raw JSON to a TypeScript interface, and write a custom OpenAPI spec just to make the tool safe for an LLM to consume. With Truto, Proxy APIs map these endpoints to standardized resources, and you can edit the schema definitions directly in the UI to give your agent the exact context it needs.

Server-Specific Routing and State Fragmentation

Unlike standard SaaS APIs where data is globally scoped to an organization ID, NationsGlory heavily shards its data across individual game servers. An agent cannot simply ask "List all countries." It must know to target the france country on the blue server.

Endpoints like country lookups and notations require mandatory server parameters. If your agent is operating across multiple guild environments, you must engineer a routing layer that forces the LLM to inject the correct server context into every single request. Without strict validation, the LLM will mix state, attempting to query a country ID from the red server on an endpoint authenticated for the blue server.

Deprecated Endpoint Landmines

The NationsGlory API surface is currently fragmented between active endpoints and a massive /deprecated/ namespace. Endpoints for NaBot sessions, webhook management, and OAuth services exist in both states. If you build a custom integration, your agent might confidently select a deprecated endpoint to manage webhooks, leading to unhandled 404s or malformed data downstream. Maintaining a safe whitelist of tools for an LLM requires constant manual auditing.

Handling NationsGlory Rate Limits in Agent Loops

Before diving into tool execution, we have to address rate limits. Autonomous agents are aggressive. An LLM tasked with finding a specific item in the auction house will execute an unoptimized WHILE loop, paginating through hundreds of records as fast as the network allows.

Truto does not retry, throttle, or apply backoff on rate limit errors. This is a critical architectural decision. If a unified API absorbs rate limits and queues requests silently, your agent's execution thread hangs, leading to timeout errors and broken conversational states.

When the NationsGlory API returns an HTTP 429 Too Many Requests error, Truto passes that error immediately back to the caller. We normalize the upstream rate limit information into standard IETF headers:

  • ratelimit-limit
  • ratelimit-remaining
  • ratelimit-reset

Your agent framework is strictly responsible for inspecting these headers, pausing its execution loop, and applying the correct backoff strategy. For a deeper technical overview of these strategies, refer to our guide on how to handle third-party API rate limits when an AI agent is scraping data. Do not deploy an agent to production without explicit 429 error handling in your execution chain.

High-Leverage NationsGlory AI Tools

Truto abstracts the NationsGlory API into standardized Proxy APIs, which are then exposed as fully described JSON schemas via the /tools endpoint. If you are building with newer protocols, Truto is the best MCP server platform for AI agents connecting to enterprise SaaS and specialized platforms like NationsGlory. Here are the highest-leverage tools available for your agents. We have filtered out basic CRUD and deprecated endpoints to focus on the operations that actually matter for automation.

List Auction House (HDV) Items

Tool Name: list_all_nations_glory_hdv

This tool allows the agent to fetch current auction house listings for a specific game server. Because market data changes rapidly, this tool is critical for building autonomous market makers or pricing alert systems. The agent must supply the target server name.

"Query the auction house on the blue server. Find any diamond-tier building materials listed in the last hour and summarize their average asking price."

List Planning Events

Tool Name: list_all_nations_glory_planning

Retrieves event schedules filtered by server, month, and year. Agents use this to synchronize internal guild calendars, track upcoming server resets, or automate resource allocation ahead of major coordinated events.

"Fetch the NationsGlory planning events for the red server for October 2024. Cross-reference this with our Notion database and create a summary of critical dates."

Query Matchmaking Rating (MMR)

Tool Name: list_all_nations_glory_mmr

Allows the agent to fetch public MMR records. This is highly useful for competitive analysis, allowing an AI to autonomously rank rival countries or track performance trends over time on a specific server.

"Retrieve the current MMR records for the green server. Identify the top 5 countries that have moved up the rankings this week."

List Countries by Server

Tool Name: list_all_nations_glory_country

Lists all countries available on a specific server. This is often used as a dependency tool. An agent will call this first to resolve a country ID before executing subsequent commands targeting that specific country.

"List all active countries on the yellow server, then find the internal ID for 'Germany' so we can query their notation history."

Manage Event Webhooks

Tool Name: create_a_nations_glory_webhook

Registers a new webhook URL to receive real-time notifications for country events. Instead of polling the API endlessly, an agent can dynamically spin up a listener endpoint on your infrastructure and use this tool to subscribe to live NationsGlory events.

"Register a new webhook on NationsGlory pointing to our production alerting URL. Configure it to trigger on all alliance-level event types."

Query Server Player Count

Tool Name: list_all_nations_glory_playercount

Fetches the current real-time player count on the network. This is a crucial operational metric used to scale underlying bot infrastructure or determine if the server is currently experiencing peak load.

"Check the current player count on NationsGlory. If it is over 500 active users, initiate the high-traffic market monitoring routine."

For the complete inventory of available methods, endpoint schemas, and required parameters, visit the NationsGlory integration page.

Workflows in Action

Providing an LLM with tools is only useful if the agent knows how to chain them together to solve actual problems. Here is how specialized personas leverage the NationsGlory toolset in the real world.

Scenario 1: Autonomous Market Maker

An in-game economics team needs to monitor the auction house for mispriced assets during off-peak hours.

"Monitor the blue server auction house. If the player count drops below 200, find any rare ores priced under 50 units and log them to my Slack channel."

Agent Execution Steps:

  1. The agent calls list_all_nations_glory_playercount to establish the current network load.
  2. Seeing the load is 145, it determines the condition is met.
  3. The agent calls list_all_nations_glory_hdv passing server="blue" as the parameter.
  4. It filters the returned JSON array in-memory, extracting objects where the item type matches rare ores and the price is below the threshold.
  5. It formats the resulting data and passes it to an external Slack notification tool.

Scenario 2: Competitive Guild Intel

A guild coordinator wants daily briefings on rival countries' performance and notation changes.

"Give me an intelligence report on the red server. Get the latest MMR standings, find the top ranked country, and check their notations for the current week."

Agent Execution Steps:

  1. The agent calls list_all_nations_glory_mmr with server="red".
  2. It sorts the unstructured response data to identify the entity with the highest rating.
  3. It calls list_all_nations_glory_country to map the top entity's string name to its internal slug identifier.
  4. The agent calls list_all_nations_glory_notations passing server="red", country="slug_id", and week="current_week_number".
  5. The agent synthesizes the results into a readable intelligence briefing and returns it to the user.

Building Multi-Step Workflows

To build autonomous workflows, you must connect Truto's /tools endpoint to your framework. Truto treats every integration as a comprehensive JSON object where Resources (like hdv or mmr) have Methods defined on them. Truto acts as the Proxy API, handling authentication and query parameter processing, while your framework handles the agent loop. If you are standardizing your connections, see our hands-on guide to building MCP servers for AI agents.

The following architecture demonstrates how your application, the agent framework, Truto, and the NationsGlory API interact during a multi-step execution.

flowchart TD
    A["User Prompt"] --> B["Agent Framework<br>(LangChain/Vercel)"]
    
    subgraph TrutoInfrastructure ["Truto Managed Infrastructure"]
        C["Truto /tools<br>Endpoint"] 
        D["Proxy API<br>Translation Layer"]
    end
    
    B -->|"1. Fetch schemas"| C
    C -->|"Returns JSON schemas"| B
    B -->|"2. Execute tool call"| D
    
    D -->|"3. Authenticated request"| E["NationsGlory<br>Upstream API"]
    E -->|"4. Raw JSON or 429 Status"| D
    D -->|"5. Standardized response/headers"| B
    B -->|"6. Final Synthesis"| A

Implementation with LangChain

Here is a concrete example of how to fetch the tools and execute an agent loop in TypeScript. This example explicitly demonstrates how to handle Truto's transparent rate limits. The agent checks for the 429 status code and respects the ratelimit-reset header.

import { ChatOpenAI } from "@langchain/openai";
import { TrutoToolManager } from "truto-langchainjs-toolset";
import { AgentExecutor, createOpenAIToolsAgent } from "langchain/agents";
import {
  ChatPromptTemplate,
  MessagesPlaceholder,
} from "@langchain/core/prompts";
 
async function executeNationsGloryWorkflow() {
  // 1. Initialize Truto Tool Manager with your NationsGlory integrated account ID
  const truto = new TrutoToolManager({
    apiKey: process.env.TRUTO_API_KEY,
  });
 
  // 2. Fetch all available Proxy APIs as LangChain-ready tools
  // Using 'read' methods to safely query the auction house and player counts
  const tools = await truto.getTools("nationsglory_account_id_123", ["read", "custom"]);
 
  // 3. Initialize the LLM
  const llm = new ChatOpenAI({
    modelName: "gpt-4-turbo-preview",
    temperature: 0,
  });
 
  // 4. Bind the tools to the LLM
  const llmWithTools = llm.bindTools(tools);
 
  // 5. Create the prompt instruction
  const prompt = ChatPromptTemplate.fromMessages([
    ["system", "You are a competitive intelligence AI for a NationsGlory guild. Use the provided tools to query server state and MMR. If a tool fails with a rate limit, explicitly state that you are backing off."],
    ["human", "{input}"],
    new MessagesPlaceholder("agent_scratchpad"),
  ]);
 
  const agent = await createOpenAIToolsAgent({
    llm: llmWithTools,
    tools,
    prompt,
  });
 
  const executor = new AgentExecutor({
    agent,
    tools,
    maxIterations: 10,
  });
 
  console.log("Starting NationsGlory intelligence workflow...");
 
  // 6. Execute with custom retry logic for Truto's rate limit passthrough
  let attempt = 0;
  const maxRetries = 3;
 
  while (attempt < maxRetries) {
    try {
      const result = await executor.invoke({
        input: "Query the auction house on the blue server. Find any diamond-tier building materials listed in the last hour and summarize their average asking price.",
      });
      
      console.log("Workflow Complete:");
      console.log(result.output);
      break; // Success, exit loop
 
    } catch (error: any) {
      // Intercept rate limit errors passed through from Truto
      if (error.status === 429 || error.message.includes("429")) {
        attempt++;
        // Extract the standardized IETF rate limit header provided by Truto
        const resetTime = error.headers?.['ratelimit-reset'] || 5;
        console.warn(`[Rate Limit Hit] NationsGlory API is throttling. Retrying in ${resetTime} seconds... (Attempt ${attempt}/${maxRetries})`);
        
        await new Promise(resolve => setTimeout(resolve, resetTime * 1000));
      } else {
        console.error("Agent execution failed due to a non-rate-limit error:", error);
        break;
      }
    }
  }
}
 
executeNationsGloryWorkflow();

The Safest Way to Build AI Integrations

Building an AI agent that talks to NationsGlory requires more than just an API key. You have to handle undocumented schemas, enforce server context routing, navigate deprecated endpoints, and gracefully manage hard rate limits.

By leveraging Truto's Proxy API architecture and the /tools endpoint, you abstract away the structural chaos of the underlying API. You give your agent framework a clean, fully typed JSON surface to interact with, while maintaining complete control over rate limit backoffs in your own code.

FAQ

How do I pass NationsGlory API tools to my AI agent?
You can fetch tool schemas directly from Truto's /tools endpoint. Truto translates NationsGlory's underlying Proxy APIs into framework-ready schemas that can be passed to LangChain, CrewAI, or the Vercel AI SDK using functions like .bindTools().
Does Truto automatically handle NationsGlory rate limits?
No. Truto does not retry or apply backoff on rate limit errors. When NationsGlory returns an HTTP 429, Truto passes that error directly to your application. Truto normalizes the upstream rate limit information into standard headers (ratelimit-limit, ratelimit-remaining, ratelimit-reset) so your agent framework can manage its own retry logic.
Can I customize the NationsGlory tools my agent uses?
Yes. Every tool maps to a Resource and Method in Truto. You can edit the descriptions and query schemas for these methods directly in the Truto dashboard. These updates immediately reflect in the output of the /tools endpoint, allowing you to fine-tune prompts for your LLM.

More from our Blog