Skip to main content
Glama
vltansky

Cursor Conversations MCP Server

export_conversation_data

Export chat conversations from Cursor in JSON, CSV, or Graph formats for analysis, visualization, or integration with external tools.

Instructions

Export chat data in various formats (JSON, CSV, Graph) for external analysis, visualization, or integration with other tools. TIP: Use filters.projectPath to export only project-specific conversations for focused analysis of a particular codebase. Use this to create datasets for machine learning, generate reports for stakeholders, prepare data for visualization tools like Gephi or Tableau, or backup chat data in structured formats.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
conversationIdsNoSpecific conversation IDs to export (if not provided, exports all conversations)
formatNoExport format: JSON for structured data, CSV for spreadsheets, Graph for network analysisjson
includeContentNoInclude full conversation content in the export
includeRelationshipsNoInclude relationship data between conversations
flattenStructureNoFlatten nested structures for easier processing
filtersNoFilters to apply when selecting conversations to export
outputModeNoOutput format: "json" for formatted JSON (default), "compact-json" for minified JSONjson

Implementation Reference

  • Core implementation of the export_conversation_data tool handler. Connects to database, filters conversations, retrieves summaries/content, exports to JSON/CSV/Graph formats using utility functions, generates metadata, and returns structured ExportedData.
    export async function exportConversationData(
      input: ExportConversationDataInput
    ): Promise<ExportedData> {
      const reader = new CursorDatabaseReader();
    
      try {
        await reader.connect();
    
        // Build filters
        const filters: ConversationFilters = {
          format: 'both',
          minLength: input.filters?.minSize || 1000
        };
    
        if (input.filters?.hasCodeBlocks !== undefined) {
          filters.hasCodeBlocks = input.filters.hasCodeBlocks;
        }
    
        if (input.filters?.projectPath) {
          filters.projectPath = input.filters.projectPath;
        }
    
        // Get conversation IDs to export
        let conversationIds = input.conversationIds;
        if (!conversationIds || conversationIds.length === 0) {
          conversationIds = await reader.getConversationIds(filters);
        }
    
        // Get conversation summaries
        const summaries = await reader.getConversationSummariesForAnalytics(conversationIds);
    
        // Get full conversation data if needed
        let conversationData: Map<string, any> | undefined;
        if (input.includeContent) {
          conversationData = new Map();
          for (const id of conversationIds) {
            try {
              const conversation = await reader.getConversationById(id);
              if (conversation) {
                conversationData.set(id, conversation);
              }
            } catch (error) {
              console.error(`Failed to get full conversation data for ${id}:`, error);
            }
          }
        }
    
        // Export in requested format
        let exportedData: any;
    
        switch (input.format) {
          case 'json':
            exportedData = exportAsJSON(summaries, input.includeContent, conversationData);
            break;
    
          case 'csv':
            exportedData = exportAsCSV(summaries, input.flattenStructure);
            break;
    
          case 'graph':
            exportedData = exportAsGraph(summaries, input.includeRelationships);
            break;
    
          default:
            exportedData = exportAsJSON(summaries, input.includeContent, conversationData);
        }
    
        // Create metadata
        const metadata = createExportMetadata(
          summaries.length,
          conversationIds.length,
          input.filters || {}
        );
    
        return {
          format: input.format,
          data: exportedData,
          metadata
        };
    
      } catch (error) {
        throw new DatabaseError(`Failed to export conversation data: ${error instanceof Error ? error.message : 'Unknown error'}`);
      } finally {
        reader.close();
      }
  • Zod schema defining the input validation for exportConversationData function, exported for reuse.
    export const exportConversationDataSchema = z.object({
      conversationIds: z.array(z.string()).optional(),
      format: z.enum(['json', 'csv', 'graph']).optional().default('json'),
      includeContent: z.boolean().optional().default(false),
      includeRelationships: z.boolean().optional().default(false),
      flattenStructure: z.boolean().optional().default(false),
      filters: z.object({
        minSize: z.number().optional(),
        hasCodeBlocks: z.boolean().optional(),
        projectPath: z.string().optional()
      }).optional()
    });
  • src/server.ts:340-383 (registration)
    MCP server registration of the 'export_conversation_data' tool, defining its description, input schema, and async handler wrapper that validates input, maps parameters, calls the core exportConversationData function, formats the response, and handles errors.
    server.tool(
      'export_conversation_data',
      'Export chat data in various formats (JSON, CSV, Graph) for external analysis, visualization, or integration with other tools. **TIP: Use filters.projectPath to export only project-specific conversations** for focused analysis of a particular codebase. Use this to create datasets for machine learning, generate reports for stakeholders, prepare data for visualization tools like Gephi or Tableau, or backup chat data in structured formats.',
      {
        conversationIds: z.array(z.string()).optional().describe('Specific conversation IDs to export (if not provided, exports all conversations)'),
        format: z.enum(['json', 'csv', 'graph']).optional().default('json').describe('Export format: JSON for structured data, CSV for spreadsheets, Graph for network analysis'),
        includeContent: z.boolean().optional().default(false).describe('Include full conversation content in the export'),
        includeRelationships: z.boolean().optional().default(false).describe('Include relationship data between conversations'),
        flattenStructure: z.boolean().optional().default(false).describe('Flatten nested structures for easier processing'),
        filters: z.object({
          minSize: z.number().optional().describe('Minimum conversation size to include'),
          hasCodeBlocks: z.boolean().optional().describe('Only include conversations with code blocks'),
                  projectPath: z.string().optional().describe('**RECOMMENDED** Only include conversations related to this project/codebase name or path. Dramatically improves relevance by filtering to conversations that actually worked on files in that project.')
        }).optional().describe('Filters to apply when selecting conversations to export'),
        outputMode: z.enum(['json', 'compact-json']).optional().default('json').describe('Output format: "json" for formatted JSON (default), "compact-json" for minified JSON')
      },
      async (input) => {
        try {
          const mappedInput = {
            conversationIds: input.conversationIds,
            format: input.format,
            includeContent: input.includeContent,
            includeRelationships: input.includeRelationships,
            flattenStructure: input.flattenStructure,
            filters: input.filters
          };
    
          const result = await exportConversationData(mappedInput);
          return {
            content: [{
              type: 'text',
              text: formatResponse(result, input.outputMode)
            }]
          };
        } catch (error) {
          return {
            content: [{
              type: 'text',
              text: `Error: ${error instanceof Error ? error.message : 'Unknown error occurred'}`
            }]
          };
        }
      }
    );
Behavior3/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 effectively describes the tool's function and use cases but lacks details on permissions, rate limits, side effects (e.g., whether it's read-only or generates files), or error handling. It adds value by explaining the purpose and applications but misses operational constraints.

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 and formats, followed by a TIP and use cases. Every sentence adds value (e.g., explaining applications), but it could be slightly more concise by integrating the TIP into the main flow rather than as a separate note.

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 (7 parameters, nested objects, no output schema) and lack of annotations, the description is adequate but incomplete. It covers purpose and usage well but does not address output behavior (e.g., what is returned or how data is delivered), error conditions, or performance aspects, leaving gaps for an AI agent to infer.

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?

Schema description coverage is 100%, so the schema already documents all parameters thoroughly. The description adds minimal parameter-specific semantics beyond the schema, only emphasizing 'filters.projectPath' in a TIP. It does not explain parameter interactions or provide additional syntax/format details, aligning with the baseline score when schema coverage is high.

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 the tool's purpose with specific verb ('Export') and resource ('chat data'), and distinguishes it from siblings by specifying it exports data for external analysis/visualization/integration, unlike tools like 'get_conversation' (fetch single) or 'list_conversations' (list metadata). The mention of formats (JSON, CSV, Graph) further clarifies its unique role.

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

Usage Guidelines4/5

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

The description provides clear context for when to use this tool (e.g., for machine learning datasets, stakeholder reports, visualization tools, or backups) and includes a TIP recommending 'filters.projectPath' for project-specific conversations. However, it does not explicitly state when NOT to use it or name alternatives among siblings (e.g., 'extract_conversation_elements' might overlap for specific elements).

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/vltansky/cursor-conversations-mcp'

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