MCPcopy Create free account
hub / github.com/diillson/chatcli / FormatForPrompt

Method FormatForPrompt

cli/mcp/channels.go:341–355  ·  view source on GitHub ↗

FormatForPrompt renders the most recent N messages as a single system-prompt block, suitable for injection into the LLM turn. An empty ring returns "" so the caller can omit the block.

(maxMessages int)

Source from the content-addressed store, hash-verified

339// system-prompt block, suitable for injection into the LLM turn. An
340// empty ring returns "" so the caller can omit the block.
341func (cm *ChannelManager) FormatForPrompt(maxMessages int) string {
342 recent := cm.GetRecent(maxMessages)
343 if len(recent) == 0 {
344 return ""
345 }
346 var sb strings.Builder
347 sb.WriteString("## MCP Channel Messages (Recent)\n\n")
348 for _, msg := range recent {
349 sb.WriteString(fmt.Sprintf("[%s/%s %s] %s\n",
350 msg.ServerName, msg.Channel,
351 msg.Timestamp.Format("15:04:05"),
352 msg.Content))
353 }
354 return sb.String()
355}
356
357// ProcessSSENotification handles a JSON-RPC notification body received
358// from an MCP server transport. Recognized shapes:

Callers 4

mcpChannelPartMethod · 0.45
runChannelInjectMethod · 0.45
RunMethod · 0.45

Calls 2

GetRecentMethod · 0.95
StringMethod · 0.45