Skip to main content
Glama
azumausu

Shogi MCP Server

by azumausu

Engine 解析

analyze

Analyze shogi positions by evaluating move candidates, scores, and variations using MultiPV to enhance strategic decision-making in Japanese chess.

Instructions

SFENを解析して候補手(MultiPV)・評価値・PVを返す

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
depthNo
forceMoveNo
multipvNo
sfenYes
threadsNo

Implementation Reference

  • The primary handler for the 'analyze' tool. This async method in the AIEngine class performs chess engine analysis on a given SFEN position, up to a specified depth and multipv variations, using a USI-compatible engine process. It handles mutex locking, option setting, position setup, search command issuance, and result parsing via callbacks.
    /**
     * @param {{sfen:string, depth:number, multipv:number, threads?:number, forceMove?:string}} params
     */
    async analyze({ sfen, depth, multipv, threads = this.defaultThreads, forceMove }) {
      return this.mutex.run(async () => {
        await this._waitReady();
        this._write(`setoption name MultiPV value ${multipv}`);
        if (threads && threads !== this.defaultThreads) this._write(`setoption name Threads value ${threads}`);
    
        this._writePosition(sfen, forceMove);
    
        const timeoutMs = Math.max(8000, 400 * depth);
        const results = {};
        const prom = new Promise((resolve, reject) => {
          const timer = setTimeout(() => {
            if (this.pending) { this.pending = null; reject(new Error("engine timeout (no bestmove)")); }
          }, timeoutMs);
          this.pending = { results, resolve: (v) => { clearTimeout(timer); resolve(v); } };
        });
        this._write(`go depth ${depth}`);
        return prom;
      });
    }
  • Helper function to parse 'info' output lines from the USI chess engine, extracting key metrics like depth, multipv, score (cp or mate), nodes, nps, and principal variation (pv). Used in _onLine to populate analysis results.
    function parseInfo(line) {
      const g = {};
      const mDepth = /(?:^| )depth (\d+)/.exec(line);
      const mMPV  = /(?:^| )multipv (\d+)/.exec(line);
      const mCp   = / score cp (-?\d+)/.exec(line);
      const mMate = / score mate (-?\d+)/.exec(line);
      const mNodes= / nodes (\d+)/.exec(line);
      const mNps  = / nps (\d+)/.exec(line);
      const mPv   = / pv (.+)$/.exec(line);
      if (mDepth) g.depth = Number(mDepth[1]);
      if (mMPV)   g.multipv = Number(mMPV[1]);
      if (mCp)    g.scoreCp = Number(mCp[1]);
      if (mMate)  g.mate    = Number(mate = mMate[1]);
      if (mNodes) g.nodes   = Number(mNodes[1]);
      if (mNps)   g.nps     = Number(mNps[1]);
      if (mPv)    g.pv      = mPv[1].trim().split(/\s+/);
      return g;
    }
  • HTTP endpoint '/analyze' that serves as a bridge to invoke the engine's analyze method, with input validation and parameter clamping for depth, multipv, threads.
    app.get("/analyze", async (req, res) => {
      try {
        const sfen = String(req.query.sfen || "");
        if (!sfen) return res.status(400).json({ error: "sfen required" });
    
        const depth = Math.min(Number(req.query.depth || MAX_DEPTH), MAX_DEPTH);
        const multipv = Math.min(Number(req.query.multipv || DEFAULT_MULTIPV), 10);
        const threads = Math.max(1, Math.min(Number(req.query.threads || 1), 8));
        const forceMove = req.query.forceMove ? String(req.query.forceMove) : undefined;
    
        const result = await engine.analyze({ sfen, depth, multipv, threads, forceMove });
        res.json({
          engine: "AI Engine",
          depth,
          multipv,
          threads,
          ...result,
        });
      } catch (e) {
        res.status(500).json({ error: String(e.message || e) });
      }
    });
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 mentions the tool returns data (candidate moves, evaluations, PV) but doesn't describe performance characteristics (e.g., computation time, resource usage), error handling, or any side effects. For an analysis tool with 5 parameters and no annotation coverage, this leaves significant gaps in understanding how the tool behaves.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise—a single sentence in Japanese that efficiently conveys the core purpose. It's front-loaded with the main action ('analyze SFEN') and avoids any redundant information. Every word earns its place, making it easy to parse quickly.

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 complexity (5 parameters, no output schema, no annotations), the description is incomplete. It doesn't explain the output format, how results are structured, or any limitations (e.g., depth/multipv constraints). While concise, it lacks the detail needed for an agent to effectively use this tool without additional context or trial-and-error.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate by explaining parameters. It only mentions 'SFEN' implicitly and doesn't describe any of the 5 parameters (sfen, depth, multipv, threads, forceMove) or their effects on the analysis. The description adds no meaningful semantic information beyond what the parameter names suggest, failing to address the coverage gap.

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 tool's purpose: analyzing SFEN (Shogi Forsyth–Edwards Notation) to return candidate moves (MultiPV), evaluation values, and PV (principal variation). It uses specific verbs ('analyze' and 'return') and identifies the resource (SFEN positions). However, it doesn't explicitly differentiate from sibling tools like 'eval_at' or 'ping', which prevents a perfect score.

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 like 'eval_at'. It doesn't mention any prerequisites, constraints, or typical use cases (e.g., game analysis, move exploration). The agent must infer usage from the purpose alone, which is insufficient for effective tool selection.

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/azumausu/shogi-mcp'

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