Skip to main content
Glama

answer_question

Submit your answer (1-5) to the current MBTI test question and receive the next question or test progress. Requires complete session state.

Instructions

提交当前问题的答案(1-5分),并获取下一题或测试进度。需要传入完整的测试会话状态。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sessionYes测试会话状态,包含testType、answers数组和currentQuestionIndex
scoreYes对当前问题的回答(1=强烈不同意, 2=不同意, 3=中立, 4=同意, 5=强烈同意)

Implementation Reference

  • The core handler logic for the 'answer_question' tool. It processes the submitted score, updates the test session state, determines if the test is complete, and returns either the completion message or the next question.
    if (name === 'answer_question') {
      const session = args.session as TestSession;
      const score = args.score as number;
    
      const questions = session.testType === 'simplified'
        ? questionBank.simplified
        : questionBank.cognitive;
    
      const currentQuestion = questions[session.currentQuestionIndex];
    
      // Save answer
      const newAnswer: Answer = {
        questionId: currentQuestion.id,
        score,
      };
    
      const updatedSession: TestSession = {
        ...session,
        answers: [...session.answers, newAnswer],
        currentQuestionIndex: session.currentQuestionIndex + 1,
      };
    
      // Check if test is complete
      if (updatedSession.currentQuestionIndex >= questions.length) {
        return {
          content: [
            {
              type: 'text',
              text: JSON.stringify({
                message: '所有问题已回答完毕!',
                completed: true,
                progress: {
                  answered: updatedSession.answers.length,
                  total: questions.length,
                },
                session: updatedSession,
                nextStep: '请使用 calculate_mbti_result 工具计算你的MBTI类型',
              }, null, 2),
            },
          ],
        };
      }
    
      // Return next question
      const nextQuestion = questions[updatedSession.currentQuestionIndex];
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify({
              message: '答案已记录',
              progress: {
                answered: updatedSession.answers.length,
                total: questions.length,
              },
              nextQuestion: {
                index: updatedSession.currentQuestionIndex + 1,
                total: questions.length,
                question: nextQuestion,
              },
              session: updatedSession,
            }, null, 2),
          },
        ],
      };
    }
  • src/index.ts:43-77 (registration)
    Registration of the 'answer_question' tool in the ListTools response, including name, description, and input schema definition.
    {
      name: 'answer_question',
      description: '提交当前问题的答案(1-5分),并获取下一题或测试进度。需要传入完整的测试会话状态。',
      inputSchema: {
        type: 'object',
        properties: {
          session: {
            type: 'object',
            description: '测试会话状态,包含testType、answers数组和currentQuestionIndex',
            properties: {
              testType: { type: 'string' },
              answers: {
                type: 'array',
                items: {
                  type: 'object',
                  properties: {
                    questionId: { type: 'number' },
                    score: { type: 'number' },
                  },
                },
              },
              currentQuestionIndex: { type: 'number' },
            },
            required: ['testType', 'answers', 'currentQuestionIndex'],
          },
          score: {
            type: 'number',
            description: '对当前问题的回答(1=强烈不同意, 2=不同意, 3=中立, 4=同意, 5=强烈同意)',
            minimum: 1,
            maximum: 5,
          },
        },
        required: ['session', 'score'],
      },
    },
  • JSON schema definition for the input parameters of the 'answer_question' tool, specifying the structure of session and score.
    inputSchema: {
      type: 'object',
      properties: {
        session: {
          type: 'object',
          description: '测试会话状态,包含testType、answers数组和currentQuestionIndex',
          properties: {
            testType: { type: 'string' },
            answers: {
              type: 'array',
              items: {
                type: 'object',
                properties: {
                  questionId: { type: 'number' },
                  score: { type: 'number' },
                },
              },
            },
            currentQuestionIndex: { type: 'number' },
          },
          required: ['testType', 'answers', 'currentQuestionIndex'],
        },
        score: {
          type: 'number',
          description: '对当前问题的回答(1=强烈不同意, 2=不同意, 3=中立, 4=同意, 5=强烈同意)',
          minimum: 1,
          maximum: 5,
        },
      },
      required: ['session', 'score'],
    },
  • Type definitions supporting the tool, including TestSession, Answer, and QuestionBank used in the handler for type safety.
    export interface QuestionBank {
      simplified: Question[];
      cognitive: Question[];
    }
  • The questionBank data structure used by the handler to retrieve questions based on test type.
    export const questionBank: QuestionBank = {
      simplified: simplifiedQuestions,
      cognitive: cognitiveQuestions,
    };
Behavior2/5

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

No annotations are provided, so the description carries full burden. It mentions the tool submits an answer and gets next question/progress, but doesn't disclose important behavioral traits: whether this is a read-only or mutating operation (likely mutating since it submits answers), what happens to the session state after submission, error conditions (e.g., invalid score range), or response format. For a tool that appears to update test progress with no annotation coverage, this is a significant gap.

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 concise with a single sentence that efficiently conveys the core functionality. It's front-loaded with the primary action and outcome. Every element earns its place, though it could potentially benefit from slightly more detail given the lack of annotations.

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?

Given the tool's apparent complexity (mutating test state, no output schema, no annotations), the description is insufficient. It doesn't explain what the tool returns (next question? updated progress? confirmation?), error handling, or behavioral implications. For a tool that seems to advance a test session and update answers, more context about the operation and results is needed.

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 both parameters thoroughly. The description adds minimal value beyond the schema, only mentioning that the session parameter should be '完整的测试会话状态' (complete test session state), which is already implied by the schema's required fields. No additional syntax, format details, or constraints are provided beyond what's in the schema.

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

Purpose4/5

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

The description clearly states the action ('提交当前问题的答案' - submit current question answer) and resource ('获取下一题或测试进度' - get next question or test progress). It distinguishes from siblings by focusing on answering questions within a test session, unlike 'calculate_mbti_result' (calculates final result), 'get_progress' (likely retrieves progress), or 'start_mbti_test' (initiates test). However, it doesn't explicitly name the test type (MBTI) which would make it more specific.

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

Usage Guidelines3/5

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

The description implies usage context ('当前问题' - current question, '测试会话状态' - test session state) suggesting it should be used during an active test session. However, it doesn't provide explicit guidance on when to use this tool versus alternatives like 'get_progress' for checking progress without answering, or 'calculate_mbti_result' for final calculation. No exclusions or prerequisites are mentioned.

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/wenyili/mbti-mcp'

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