Skip to main content
Glama

get_session_context

Retrieve a snapshot of your RPG session context including location, party details, notes, combat state, and summary. Customize output with specific sections, formats, and limits to track game progress.

Instructions

Get comprehensive session context snapshot. Includes location, party, notes, combat state, and summary. Options: include (array of sections), format (detailed|compact|brief), maxNotes (limit), includeTimestamps (boolean).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
includeNo
formatNo
maxNotesNo
includeTimestampsNo

Implementation Reference

  • Main handler function that parses input, gathers session context from various modules (location, party, notes, combat, summary), formats it according to specified format (detailed/compact/brief), and returns boxed ASCII output.
    export async function getSessionContext(input: unknown): Promise<{ content: { type: 'text'; text: string }[] }> {
      try {
        const parsed = getSessionContextSchema.parse(input);
        const format = parsed.format || 'detailed';
        const sections = parsed.include || ['location', 'party', 'notes', 'combat', 'summary'];
        const maxNotes = parsed.maxNotes;
        const includeTimestamps = parsed.includeTimestamps || false;
    
        const lines: string[] = [];
    
        // Build context based on requested sections
        for (const section of sections) {
          switch (section) {
            case 'location':
              lines.push(...getLocationContext(format));
              break;
            case 'party':
              lines.push(...getPartyContext(format));
              break;
            case 'notes':
              lines.push(...getNotesContext(format, maxNotes, includeTimestamps));
              break;
            case 'combat':
              lines.push(...getCombatContext(format));
              break;
            case 'summary':
              lines.push(...getSummaryContext());
              break;
          }
          if (format !== 'brief') {
            lines.push(''); // spacing between sections
          }
        }
    
        // Remove trailing empty lines
        while (lines.length > 0 && lines[lines.length - 1] === '') {
          lines.pop();
        }
    
        const output = createBox('SESSION CONTEXT', lines, DISPLAY_WIDTH);
        return { content: [{ type: 'text' as const, text: output }] };
      } catch (error) {
        const lines: string[] = [];
    
        if (error instanceof z.ZodError) {
          for (const issue of error.issues) {
            lines.push(`${issue.path.join('.')}: ${issue.message}`);
          }
        } else if (error instanceof Error) {
          lines.push(error.message);
        } else {
          lines.push('An unknown error occurred');
        }
    
        return { content: [{ type: 'text' as const, text: createBox('ERROR', lines, DISPLAY_WIDTH) }] };
      }
    }
  • Zod schema defining input parameters for the get_session_context tool: sections to include, output format, note limit, and timestamp inclusion.
    export const getSessionContextSchema = z.object({
      include: z.array(fuzzyEnum(['location', 'party', 'notes', 'combat', 'summary'] as const)).optional(),
      format: fuzzyEnum(['detailed', 'compact', 'brief'] as const, 'verbosity').optional(),
      maxNotes: z.number().int().positive().optional(),
      includeTimestamps: z.boolean().optional(),
    });
  • Tool registration in the central registry, including name, description, input schema conversion, and wrapper handler that calls the actual getSessionContext function.
    get_session_context: {
      name: 'get_session_context',
      description: 'Get comprehensive session context snapshot. Includes location, party, notes, combat state, and summary. Options: include (array of sections), format (detailed|compact|brief), maxNotes (limit), includeTimestamps (boolean).',
      inputSchema: toJsonSchema(getSessionContextSchema),
      handler: async (args) => {
        try {
          const result = await getSessionContext(args);
          return result;
        } catch (err) {
          if (err instanceof z.ZodError) {
            const messages = err.errors.map(e => `${e.path.join('.')}: ${e.message}`).join(', ');
            return error(`Validation failed: ${messages}`);
          }
          const message = err instanceof Error ? err.message : String(err);
          return error(message);
        }
      },
    },
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool 'Get[s]' data, implying a read-only operation, but doesn't clarify permissions, rate limits, or response format. While it lists included sections and options, it lacks details on what 'comprehensive' entails, how data is structured, or potential side effects. This is inadequate for a tool with multiple parameters and no output schema.

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

Conciseness4/5

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

The description is appropriately sized and front-loaded, starting with the core purpose followed by parameter options in a single sentence. Every element adds value, with no redundant or verbose phrasing. It could be slightly improved by structuring parameter details more clearly, but it remains efficient.

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

Completeness3/5

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

Given the tool's complexity (4 parameters, no annotations, no output schema), the description is partially complete. It covers the purpose and parameters well but lacks behavioral context, usage guidelines, and output details. For a read operation with multiple options, this leaves gaps in understanding how to effectively use the tool and interpret results.

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 description adds significant meaning beyond the input schema, which has 0% description coverage. It explains all four parameters: 'include' (array of sections), 'format' (detailed|compact|brief), 'maxNotes' (limit), and 'includeTimestamps' (boolean), providing context not in the schema. However, it doesn't specify valid values for 'include' or details on format differences, leaving some ambiguity.

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

Purpose4/5

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

The description clearly states the tool's purpose with a specific verb ('Get') and resource ('comprehensive session context snapshot'), listing key components like location, party, notes, combat state, and summary. It distinguishes itself from siblings by focusing on retrieving a holistic snapshot rather than managing specific aspects (e.g., manage_notes, manage_party). However, it doesn't explicitly differentiate from get_character or get_encounter, which might retrieve similar data subsets.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. It lists options but doesn't explain scenarios where get_session_context is preferred over sibling tools like get_character, get_encounter, or manage_notes for accessing session data. There's no mention of prerequisites, dependencies, or typical use cases.

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/Mnehmos/mnehmos.chatrpg.game'

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