Skip to main content
Glama
alcylu

Nightlife Search

list_cities

Retrieve a list of available cities with metadata to identify valid city slugs for querying nightlife events and concerts.

Instructions

List all available cities with metadata. Use this to discover valid city slugs before calling other tools.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
citiesYes

Implementation Reference

  • Core handler function that queries the 'cities' table from Supabase, filters out unknown slugs and optionally filters by topLevelCities config, then returns an array of city objects with slug, name, timezone, and country_code.
    export async function listCities(
      supabase: SupabaseClient,
      topLevelCities?: string[],
    ): Promise<{
      cities: Array<{ slug: string; name: string; timezone: string; country_code: string }>;
    }> {
      const { data, error } = await supabase
        .from("cities")
        .select("slug,name_en,timezone,country_code")
        .order("slug", { ascending: true });
    
      if (error || !data) {
        return { cities: [] };
      }
    
      let rows = data.filter(
        (row) => row.slug && !String(row.slug).startsWith("unknown"),
      );
    
      if (topLevelCities && topLevelCities.length > 0) {
        const allowed = new Set(
          topLevelCities
            .map((v) => v.trim().toLowerCase())
            .filter((v) => v.length > 0),
        );
        rows = rows.filter((row) => allowed.has(String(row.slug).trim().toLowerCase()));
      }
    
      return {
        cities: rows.map((row) => ({
          slug: String(row.slug).trim().toLowerCase(),
          name: row.name_en || row.slug,
          timezone: row.timezone || "UTC",
          country_code: row.country_code || "JP",
        })),
      };
    }
  • Zod output schema for list_cities tool defining the shape: { cities: Array<{ slug, name, timezone, country_code }> }
    const listCitiesOutputSchema = z.object({
      cities: z.array(
        z.object({
          slug: z.string(),
          name: z.string(),
          timezone: z.string(),
          country_code: z.string(),
        }),
      ),
    });
  • MCP tool registration via server.registerTool('list_cities', ...), which wires the tool name, description, input/output schemas, and the handler callback that calls listCities from the service layer.
    export function registerHelperTools(server: McpServer, deps: ToolDeps): void {
      server.registerTool(
        "list_cities",
        {
          description:
            "List all available cities with metadata. Use this to discover valid city slugs before calling other tools.",
          inputSchema: {},
          outputSchema: listCitiesOutputSchema,
        },
        async () =>
          runTool("list_cities", listCitiesOutputSchema, async () =>
            listCities(deps.supabase, deps.config.topLevelCities),
          ),
      );
  • The runTool wrapper function that invokes the handler, parses output through the schema, records metrics, and handles errors with proper tool error responses.
    async function runTool<Output>(
      toolName: string,
      outputSchema: z.ZodType<Output>,
      cb: () => Promise<Output>,
    ) {
      const startedAt = Date.now();
      try {
        const output = outputSchema.parse(await cb());
        const durationMs = Date.now() - startedAt;
        recordToolResult({ tool: toolName, durationMs });
        logEvent("tool.success", { tool: toolName, duration_ms: durationMs });
    
        return {
          content: [{ type: "text" as const, text: jsonText(output) }],
          structuredContent: output as unknown as Record<string, unknown>,
        };
      } catch (error) {
        const normalized = toNightlifeError(error);
        const durationMs = Date.now() - startedAt;
        recordToolResult({ tool: toolName, durationMs, errorCode: normalized.code });
        logEvent("tool.error", {
          tool: toolName,
          duration_ms: durationMs,
          code: normalized.code,
          message: normalized.message,
        });
    
        return {
          isError: true,
          content: [{ type: "text" as const, text: jsonText(toolErrorResponse(normalized)) }],
        };
      }
    }
  • OpenAPI schema definition for ListCitiesOutput used by the REST endpoint, matching the same structure as the MCP tool.
    ListCitiesOutput: {
      type: "object",
      properties: {
        cities: {
          type: "array",
          items: {
            type: "object",
            properties: {
              slug: { type: "string" },
              name: { type: "string" },
              timezone: { type: "string" },
              country_code: { type: "string" },
            },
            required: ["slug", "name", "timezone", "country_code"],
          },
        },
      },
      required: ["cities"],
    },
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Without annotations, the description carries the full burden. It discloses that the tool lists all cities with metadata, which implies a read-only operation. However, it does not elaborate on response size or pagination, though the output schema may cover that.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two sentences, perfectly front-loaded. The first sentence states the action, the second adds contextual usage. No redundant words.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given zero parameters, an output schema exists, and the tool is a simple list, the description is complete. It covers purpose, usage, and return type implicitly. No missing elements for this low-complexity tool.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The tool has zero parameters, so baseline is 4. The description adds context that it returns all cities with metadata, which is useful beyond the empty schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states 'List all available cities with metadata' as a specific verb-resource combination. It differentiates from siblings like list_areas by establishing this tool as a prerequisite for discovering city slugs.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicitly states 'Use this to discover valid city slugs before calling other tools.' This provides clear when-to-use guidance and implies it's a prerequisite, making it easy for the agent to sequence correctly.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/alcylu/nightlife-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server