Skip to main content
Glama

get_context_suggestions

Generate relevant context suggestions based on current user input and file history to maintain conversation continuity in AI-assisted development sessions.

Instructions

获取相关上下文建议

基于当前输入和文件推荐历史记录

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
currentInputYes当前用户输入
currentFilesNo当前涉及的文件
projectNo项目过滤(可选)

Implementation Reference

  • Main execution logic for the get_context_suggestions tool. Validates input, extracts keywords from user input, searches for matching past conversations in the project, and formats relevant suggestions.
    async getContextSuggestions(params: unknown): Promise<{ content: Array<{ type: string; text: string }> }> {
      try {
        const validatedParams = validateGetContextSuggestions(params);
        const { currentInput, currentFiles, project } = validatedParams;
    
        // 获取项目信息
        const projectInfo = await this.fileManager.getProjectInfo();
        const searchProject = project || projectInfo.name;
    
        // 构建搜索关键词:从输入中提取关键词
        const keywords = currentInput.split(/\s+/).filter(word => word.length > 2);
        
        // 搜索相关对话
        const searchResults = await this.searchInProject(searchProject, {
          keywords,
          limit: 5,
          filePattern: currentFiles && currentFiles.length > 0 ? currentFiles[0] : undefined,
          tags: [],
          platform: undefined,
          days: 30
        });
    
        if (searchResults.count === 0) {
          return {
            content: [
              {
                type: 'text',
                text: '💡 暂无相关历史记录建议'
              }
            ]
          };
        }
    
        return {
          content: [
            {
              type: 'text',
              text: `💡 找到 ${searchResults.count} 条相关历史记录:\n\n${searchResults.content}`
            }
          ]
        };
      } catch (error) {
        const errorMessage = error instanceof ValidationError 
          ? `参数验证失败: ${error.message}`
          : `获取上下文建议时出错: ${String(error)}`;
        
        return {
          content: [
            {
              type: 'text',
              text: `❌ ${errorMessage}`
            }
          ]
        };
      }
    }
  • Zod schema defining the input structure and validation for get_context_suggestions parameters.
    export const GetContextSuggestionsSchema = z.object({
      currentInput: z.string().min(1, '当前输入不能为空'),
      currentFiles: z.array(z.string()).optional(),  // 当前涉及的文件
      project: z.string().optional()
    }).transform((data) => ({
      ...data,
      currentFiles: data.currentFiles || []
    }));
  • src/index.ts:116-137 (registration)
    Tool registration in the MCP server's listTools request handler, providing name, description, and simplified input schema.
      name: 'get_context_suggestions',
      description: '获取相关上下文建议\n\n基于当前输入和文件推荐历史记录',
      inputSchema: {
        type: 'object',
        properties: {
          currentInput: {
            type: 'string',
            description: '当前用户输入'
          },
          currentFiles: {
            type: 'array',
            items: { type: 'string' },
            description: '当前涉及的文件'
          },
          project: {
            type: 'string',
            description: '项目过滤(可选)'
          }
        },
        required: ['currentInput']
      }
    },
  • src/index.ts:167-168 (registration)
    Dispatch logic in the MCP server's callTool request handler that routes get_context_suggestions calls to the ConversationLogger handler.
    case 'get_context_suggestions':
      return await this.conversationLogger.getContextSuggestions(args || {});
  • Validation function for get_context_suggestions input parameters using the defined Zod schema.
    export const validateGetContextSuggestions = (data: unknown): GetContextSuggestionsParams => {
      const result = GetContextSuggestionsSchema.safeParse(data);
      if (!result.success) {
        const errorMessages = result.error.errors.map(err => `${err.path.join('.')}: ${err.message}`).join('; ');
        throw new Error(`${CONSTANTS.ERROR_MESSAGES.INVALID_PARAMETERS}: ${errorMessages}`);
      }
      return result.data as GetContextSuggestionsParams;
    };
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It mentions the tool provides suggestions based on input and file history, but doesn't describe what the suggestions look like, whether they're ranked, how many are returned, or any rate limits or authentication requirements. For a suggestion tool with zero annotation coverage, this leaves significant behavioral gaps.

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 brief (two short sentences) and gets straight to the point without unnecessary elaboration. However, it could be more front-loaded with the most critical information about what type of suggestions are provided.

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?

For a suggestion-generation tool with 3 parameters, no annotations, and no output schema, the description is insufficient. It doesn't explain what format the suggestions take, what they're useful for, or how they relate to the sibling tools. The agent lacks crucial context about what this tool actually returns and when it should be preferred over alternatives.

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 three parameters with Chinese descriptions. The description mentions '基于当前输入和文件推荐历史记录' (based on current input and file recommendation history), which aligns with currentInput and currentFiles parameters but doesn't add meaningful semantic context beyond what the schema provides. The project parameter isn't mentioned in the description at all.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose3/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states the tool '获取相关上下文建议' (get relevant context suggestions) and mentions it's based on current input and file recommendation history. This provides a general purpose but lacks specificity about what type of suggestions are returned or what 'context' means. It doesn't clearly differentiate from sibling tools like search_conversations or log_conversation.

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. There's no mention of when this tool is appropriate versus using search_conversations or other siblings, nor any prerequisites or constraints for usage. The agent must infer usage from the tool name alone.

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/fablefang/ai-conversation-logger-mcp'

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