MCPcopy Create free account
hub / github.com/IBM/mcp-cli / ExportCommand

Class ExportCommand

src/mcp_cli/commands/export/export.py:17–128  ·  view source on GitHub ↗

Export conversation to file.

Source from the content-addressed store, hash-verified

15
16
17class ExportCommand(UnifiedCommand):
18 """Export conversation to file."""
19
20 @property
21 def name(self) -> str:
22 return "export"
23
24 @property
25 def aliases(self) -> list[str]:
26 return ["save-chat"]
27
28 @property
29 def description(self) -> str:
30 return "Export conversation to markdown or JSON"
31
32 @property
33 def help_text(self) -> str:
34 return """
35Export the current conversation to a file.
36
37Usage:
38 /export markdown [filename] - Export as formatted Markdown
39 /export json [filename] - Export as structured JSON
40
41Default filenames: chat-<session_id>.md / .json
42"""
43
44 @property
45 def modes(self) -> CommandMode:
46 return CommandMode.CHAT
47
48 @property
49 def parameters(self) -> list[CommandParameter]:
50 return [
51 CommandParameter(
52 name="format",
53 type=str,
54 required=False,
55 help="Export format: markdown or json (default: markdown)",
56 ),
57 CommandParameter(
58 name="filename",
59 type=str,
60 required=False,
61 help="Output filename (optional)",
62 ),
63 ]
64
65 async def execute(self, **kwargs) -> CommandResult:
66 """Execute the export command."""
67 from mcp_cli.chat.exporters import MarkdownExporter, JSONExporter
68
69 chat_context = kwargs.get("chat_context")
70 if not chat_context:
71 return CommandResult(success=False, error="No chat context available.")
72
73 # Parse arguments
74 args = kwargs.get("args", "").strip().split()

Callers 2

register_all_commandsFunction · 0.90
cmdFunction · 0.90

Calls

no outgoing calls

Tested by 1

cmdFunction · 0.72