Skip to main content
Glama
es6kr
by es6kr

rename_session

Add a title prefix to the first message of a Claude Code conversation session to rename it for better organization and identification.

Instructions

Rename a session by adding a title prefix to the first message

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
project_nameYesProject folder name
session_idYesSession ID (filename without .jsonl)
new_titleYesNew title to add as prefix

Implementation Reference

  • src/mcp/index.ts:38-53 (registration)
    Tool registration for 'rename_session', including input schema using Zod and the handler function that calls the core renameSession implementation.
    server.tool(
      'rename_session',
      'Rename a session by adding a title prefix to the first message',
      {
        project_name: z.string().describe('Project folder name'),
        session_id: z.string().describe('Session ID (filename without .jsonl)'),
        new_title: z.string().describe('New title to add as prefix'),
      },
      async ({ project_name, session_id, new_title }) => {
        const result = await Effect.runPromise(
          session.renameSession(project_name, session_id, new_title)
        )
        return {
          content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],
        }
      }
  • Core implementation of renameSession: reads the session JSONL file, modifies the first message's content by prepending the new title in brackets (replacing any existing prefix), and writes back the updated file.
    export const renameSession = (projectName: string, sessionId: string, newTitle: string) =>
      Effect.gen(function* () {
        const filePath = path.join(getSessionsDir(), projectName, `${sessionId}.jsonl`)
        const content = yield* Effect.tryPromise(() => fs.readFile(filePath, 'utf-8'))
        const lines = content.trim().split('\n').filter(Boolean)
    
        if (lines.length === 0) {
          return { success: false, error: 'Empty session' }
        }
    
        const messages = lines.map((line) => JSON.parse(line) as Message)
        const firstMsg = messages[0]
    
        // Add title prefix to first message
        if (firstMsg && typeof firstMsg.message === 'object' && firstMsg.message !== null) {
          const msg = firstMsg.message as { content?: string }
          if (msg.content) {
            // Remove existing title prefix if any
            const cleanContent = msg.content.replace(/^\[.*?\]\s*/, '')
            msg.content = `[${newTitle}] ${cleanContent}`
          }
        }
    
        const newContent = messages.map((m) => JSON.stringify(m)).join('\n') + '\n'
        yield* Effect.tryPromise(() => fs.writeFile(filePath, newContent, 'utf-8'))
    
        return { success: true }
      })
  • Zod schema defining input parameters for the rename_session tool.
      project_name: z.string().describe('Project folder name'),
      session_id: z.string().describe('Session ID (filename without .jsonl)'),
      new_title: z.string().describe('New title to add as prefix'),
    },
Behavior2/5

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

With no annotations provided, the description carries full burden but only states the action without behavioral details. It doesn't disclose if this requires specific permissions, is reversible, affects other data, or has side effects (e.g., modifying the first message). This is inadequate for a mutation tool with zero annotation coverage.

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?

The description is a single, efficient sentence that directly states the tool's purpose without unnecessary words. It's front-loaded and every part earns its place, making it highly concise and well-structured.

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

Completeness2/5

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

Given the tool is a mutation with no annotations and no output schema, the description is incomplete. It lacks details on behavioral traits, return values, or error conditions, which are crucial for an agent to use it correctly in this context.

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

Parameters3/5

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

The schema description coverage is 100%, so parameters are fully documented in the schema. The description adds no additional meaning beyond implying 'new_title' is used as a prefix, which aligns with the schema. Baseline 3 is appropriate as the schema does the heavy lifting.

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 action ('Rename a session') and the mechanism ('by adding a title prefix to the first message'), which is specific and actionable. However, it doesn't explicitly differentiate from sibling tools like 'delete_session' or 'split_session', which would require mentioning it modifies rather than removes or divides content.

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 doesn't mention prerequisites (e.g., existing sessions), exclusions, or compare to siblings like 'clear_sessions' or 'delete_session', leaving the agent without context for selection.

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/es6kr/claude-sessions-mcp'

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