Skip to main content
Glama

suggest_persona

Analyzes conversation context to recommend appropriate expert personas for AI interactions, activating them only when triggered for efficient responses.

Instructions

대화 컨텍스트를 분석하여 적합한 페르소나를 제안합니다 (트리거 시에만 활성화)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contextYes분석할 대화 컨텍스트 또는 질문 내용

Implementation Reference

  • Core handler function that implements the suggest_persona tool logic by analyzing context keywords and usage analytics to recommend a suitable persona.
    async function suggestPersona(context: string): Promise<PersonaSuggestion | null> { const personas = await listPersonas(); if (personas.length === 0) { return null; } const analytics = await loadAnalytics(); const contextLower = context.toLowerCase(); // 컨텍스트 키워드 분석 const detectionRules = [ { keywords: ['explain', 'teach', 'learn', 'understand', 'how', 'what', 'why'], persona: 'teacher', weight: 3 }, { keywords: ['code', 'function', 'bug', 'debug', 'program', 'implement'], persona: 'coder', weight: 3 }, { keywords: ['professional', 'business', 'formal', 'report', 'meeting'], persona: 'professional', weight: 2 }, { keywords: ['casual', 'chat', 'friendly', 'hey', 'talk'], persona: 'casual', weight: 2 }, { keywords: ['brief', 'short', 'quick', 'summary', 'concise'], persona: 'concise', weight: 2 }, ]; const scores: Record<string, number> = {}; // 규칙 기반 점수 detectionRules.forEach(rule => { if (personas.includes(rule.persona)) { const matchCount = rule.keywords.filter(kw => contextLower.includes(kw)).length; if (matchCount > 0) { scores[rule.persona] = (scores[rule.persona] || 0) + matchCount * rule.weight; } } }); // 과거 사용 패턴 기반 점수 (가중치 낮게) const contextKeywords = contextLower.match(/\b\w{4,}\b/g) || []; personas.forEach(persona => { if (analytics.contextPatterns[persona]) { contextKeywords.forEach(kw => { if (analytics.contextPatterns[persona][kw]) { scores[persona] = (scores[persona] || 0) + 0.5; } }); } }); // 최고 점수 페르소나 반환 const sorted = Object.entries(scores).sort((a, b) => b[1] - a[1]); if (sorted.length > 0 && sorted[0][1] > 1) { return { persona: sorted[0][0], confidence: Math.min(sorted[0][1] / 10, 0.95), reason: `Context matches ${sorted[0][0]} pattern`, }; } return null; }
  • Zod schema for validating the input parameters of the suggest_persona tool, specifically the 'context' string.
    export const suggestPersonaSchema = z.object({ context: z.string().min(1).max(10000), });
  • src/index.ts:382-394 (registration)
    Tool registration in the ListToolsRequestHandler, defining the name, description, and input schema for suggest_persona.
    name: 'suggest_persona', description: '대화 컨텍스트를 분석하여 적합한 페르소나를 제안합니다 (트리거 시에만 활성화)', inputSchema: { type: 'object', properties: { context: { type: 'string', description: '분석할 대화 컨텍스트 또는 질문 내용', }, }, required: ['context'], }, },
  • Dispatcher case in CallToolRequestHandler that validates input, calls the suggestPersona handler, and formats the response.
    case 'suggest_persona': { const validated = suggestPersonaSchema.parse(args); const suggestion = await suggestPersona(validated.context); if (!suggestion) { return { content: [ { type: 'text', text: '💡 현재 컨텍스트에 적합한 페르소나를 찾을 수 없습니다.\n사용 가능한 페르소나 목록을 보려면 list_personas 도구를 사용하세요.', }, ], }; } return { content: [ { type: 'text', text: `💡 페르소나 제안\n\n추천: @persona:${suggestion.persona}\n신뢰도: ${(suggestion.confidence * 100).toFixed(0)}%\n이유: ${suggestion.reason}\n\n이 페르소나를 사용하려면 @persona:${suggestion.persona} 리소스를 참조하세요.`, }, ], }; }

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/seanshin0214/persona-mcp'

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