Skip to main content
Glama
KunihiroS

claude-code-mcp

your_own_query

Send custom queries with contextual details to Claude Code MCP server for tailored responses. Ideal for precise information retrieval and specific task execution.

Instructions

Sends a custom query with context.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contextNoAdditional context
queryYesQuery text

Implementation Reference

  • The execution handler for the 'your_own_query' tool. It destructures the query and optional context from arguments, constructs a simple prompt, calls the shared runClaudeCommand to execute Claude CLI with '--print', and returns the text output.
    case 'your_own_query': {
      const { query, context } = args;
      logger.debug(`Processing your_own_query request, query length: ${query.length}`);
      const prompt = `Query: ${query} ${context || ''}`;
      logger.debug('Calling Claude CLI with prompt');
      const output = await runClaudeCommand(['--print'], prompt);
      logger.debug(`Received response from Claude, length: ${output.length}`);
      return { content: [{ type: 'text', text: output }] };
    }
  • Registration of the 'your_own_query' tool in the ListTools response, including its name, description, and input schema definition.
    {
      name: 'your_own_query',
      description: 'Sends a custom query with context.',
      inputSchema: {
        type: 'object',
        properties: {
          query: { type: 'string', description: 'Query text' },
          context: { type: 'string', description: 'Additional context', default: '' }
        },
        required: ['query']
      }
    }
  • Input schema for the 'your_own_query' tool, defining the expected parameters: required 'query' string and optional 'context' string.
    inputSchema: {
      type: 'object',
      properties: {
        query: { type: 'string', description: 'Query text' },
        context: { type: 'string', description: 'Additional context', default: '' }
      },
      required: ['query']
  • Shared helper function runClaudeCommand used by all tools, including 'your_own_query', to execute the Claude CLI binary securely with timeout and logging.
    const runClaudeCommand = (claudeArgs: string[], stdinInput?: string): Promise<string> => {
      return new Promise((resolve, reject) => {
        // タイムアウト設定 (5分)
        const timeoutMs = 5 * 60 * 1000;
        let timeoutId: NodeJS.Timeout;
        
        try {
          // より詳細なデバッグ情報
          logger.debug(`Executing Claude CLI at path: ${validatedClaudePath}`);
          logger.debug(`Claude CLI arguments: ${JSON.stringify(claudeArgs)}`);
          if (stdinInput) logger.debug(`Input length: ${stdinInput.length} characters`);
          
          // 環境変数をログに出力
          logger.debug(`Environment PATH: ${process.env.PATH}`);
          
          if (validatedClaudePath === null) {
              logger.error('validatedClaudePath is null. Claude CLI cannot be executed.');
              // エラーをクライアントに返すなど、より丁寧なエラー処理を検討してください。
              throw new Error('Validated Claude CLI path is not available. Please check CLAUDE_BIN environment variable or server configuration.');
          }
    
          const proc = child_process.spawn(validatedClaudePath, claudeArgs, {
              env: { ...process.env },
              stdio: ['pipe', 'pipe', 'pipe']
          }) as child_process.ChildProcess;
    
          // 標準入力がある場合は書き込みと終了
          if (stdinInput) {
              proc.stdin!.write(stdinInput);
              proc.stdin!.end();
              logger.debug('Wrote input to Claude CLI stdin');
          }
    
          let stdout = '';
          let stderr = '';
    
          proc.stdout!.on('data', (data: string) => {
              const chunk = data.toString();
              stdout += chunk;
              logger.debug(`Received stdout chunk: ${chunk.length} bytes`);
          });
    
          proc.stderr!.on('data', (data: string) => {
              const chunk = data.toString();
              stderr += chunk;
              logger.error(`Claude stderr: ${chunk}`);
              logger.debug(`Claude stderr output: ${chunk}`);
          });
    
          // タイムアウト設定
          timeoutId = setTimeout(() => {
              logger.error(`Command timed out after ${timeoutMs/1000} seconds`);
              logger.debug('Killing process due to timeout');
              proc.kill();
              reject(new Error(`Command timed out after ${timeoutMs / 1000} seconds`));
          }, timeoutMs);
    
          proc.on('close', (code: number) => {
              clearTimeout(timeoutId);
              logger.debug(`Claude process closed with code: ${code}`);
              if (code === 0) {
                  logger.debug(`Claude command completed successfully, output length: ${stdout.length} bytes`);
                  resolve(stdout.trim());
              }
              else {
                  logger.error(`Command failed with code ${code}`);
                  logger.debug(`stderr: ${stderr}`);
                  reject(new Error(`Command failed with code ${code}: ${stderr}`));
              }
          });
    
          proc.on('error', (err: Error) => {
              clearTimeout(timeoutId);
              logger.error("Process spawn error:", err);
              logger.debug(`Process error details: ${err.stack}`);
              reject(err);
          });
        } catch (err) {
          logger.error("Failed to spawn process:", err);
          logger.debug(`Spawn failure details: ${err instanceof Error ? err.stack : String(err)}`);
          reject(err);
        }
      });
    };
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It only states the action ('sends a custom query with context') without explaining what happens after sending (e.g., response format, error handling, side effects, or rate limits). For a tool with no annotations, this is insufficient to inform the agent about its behavior.

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 a single, efficient sentence ('Sends a custom query with context.') that is front-loaded and wastes no words. However, it could be more structured by including key details, but it earns high marks for brevity and clarity within its limited scope.

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 complexity (a query tool with no annotations and no output schema), the description is incomplete. It doesn't explain what the tool returns, how errors are handled, or the context of use (e.g., related to code or commands). With siblings like code-related tools, more context is needed to guide the agent effectively.

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%, with clear descriptions for both parameters ('query' as query text, 'context' as additional context). The description adds no additional meaning beyond the schema, such as examples or constraints. Since the schema does the heavy lifting, the baseline score of 3 is appropriate.

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 'sends a custom query with context', which provides a basic verb+resource combination. However, it's vague about what type of query this is (e.g., database query, API query, natural language query) and doesn't distinguish it from sibling tools like 'simulate_command' or 'explain_code' that might also involve queries. The purpose is understandable but lacks specificity.

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. With siblings like 'explain_code' and 'simulate_command', it's unclear if this tool is for general-purpose queries or specific contexts. There are no explicit when/when-not instructions or named alternatives mentioned, leaving usage ambiguous.

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

Related 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/KunihiroS/claude-code-mcp'

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