Skip to main content
Glama

fair.compute

Calculate fair probabilities and odds for football match outcomes including 1X2, over/under 2.5 goals, and both teams to score using Poisson distribution.

Instructions

Calcola probabilità e quote fair (Poisson semplice) per 1X2 / OU 2.5 / BTTS.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
match_idYesFixture id da API-Football

Implementation Reference

  • The execute handler for the fair.compute tool. Builds a match snapshot using the provided match_id and computes fair odds, returning a JSON string with both.
    execute: async (args) => {
      const snapshot = await buildMatchSnapshot(args.match_id);
      const fair = computeFairOddsFromSnapshot(snapshot);
      return JSON.stringify({ snapshot, fair }, null, 2);
    },
  • Zod input schema defining the required match_id parameter (number: Fixture id from API-Football).
    parameters: z.object({
      match_id: z.number().describe("Fixture id da API-Football"),
    }),
  • src/tools/fair.ts:6-19 (registration)
    The registerFairTool function that defines and registers the fair.compute tool on a FastMCP server instance, including name, description, schema, and handler.
    export const registerFairTool = (server: FastMCP) => {
      server.addTool({
        name: "fair.compute",
        description: "Calcola probabilità e quote fair (Poisson semplice) per 1X2 / OU 2.5 / BTTS.",
        parameters: z.object({
          match_id: z.number().describe("Fixture id da API-Football"),
        }),
        execute: async (args) => {
          const snapshot = await buildMatchSnapshot(args.match_id);
          const fair = computeFairOddsFromSnapshot(snapshot);
          return JSON.stringify({ snapshot, fair }, null, 2);
        },
      });
    };
  • src/index.ts:19-19 (registration)
    Top-level registration call that invokes registerFairTool to add the fair.compute tool to the main MCP server.
    registerFairTool(server);
  • Key helper function that performs the Poisson-based fair odds computation from a match snapshot, deriving lambdas, integrating distributions for probabilities (1X2, OU2.5, BTTS), and calculating fair odds.
    export const computeFairOddsFromSnapshot = (snapshot: MatchSnapshot): FairOddsPayload => {
      const lambdaHome = deriveLambda(
        snapshot.home.avgGoalsFor,
        snapshot.away.avgGoalsAgainst,
        config.modeling.homeAdvantage,
      );
      const lambdaAway = deriveLambda(snapshot.away.avgGoalsFor, snapshot.home.avgGoalsAgainst, 1);
    
      const { homeWin, awayWin, draw, over25, bttsYes } = integrateDistributions(lambdaHome, lambdaAway);
    
      const probs = {
        HOME: clampProbability(homeWin),
        DRAW: clampProbability(draw),
        AWAY: clampProbability(awayWin),
        OVER_2_5: clampProbability(over25),
        UNDER_2_5: clampProbability(1 - over25),
        BTTS_YES: clampProbability(bttsYes),
        BTTS_NO: clampProbability(1 - bttsYes),
      } satisfies Record<SelectionKey, number>;
    
      const fairOdds = Object.fromEntries(
        Object.entries(probs).map(([key, value]) => [key, Number((1 / value).toFixed(3))]),
      ) as Record<SelectionKey, number>;
    
      return {
        matchId: snapshot.match.matchId,
        lambdaHome: Number(lambdaHome.toFixed(3)),
        lambdaAway: Number(lambdaAway.toFixed(3)),
        probabilities: probs,
        fairOdds,
      };
    };
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions the calculation method (Poisson semplice) and output types (probabilities and odds for specific markets), but lacks critical details like whether this is a read-only operation, if it requires specific permissions, rate limits, or what the response format looks like. For a computational tool with zero annotation coverage, this is insufficient.

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 concise and front-loaded in a single sentence that directly states the tool's function. It efficiently covers the core purpose without unnecessary words, though it could benefit from slight structural improvements like separating the calculation method from the output markets for clarity.

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 computational nature of the tool, no annotations, and no output schema, the description is incomplete. It doesn't explain what the output looks like (e.g., structured probabilities/odds), error handling, or dependencies on external data (e.g., requiring match statistics from API-Football). For a tool that performs calculations with a single input, more context 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?

The input schema has 100% description coverage, with the single parameter 'match_id' clearly documented as 'Fixture id da API-Football'. The description doesn't add any additional parameter semantics beyond what the schema provides, such as format examples or constraints. With high schema coverage, 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.

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: calculating fair probabilities and odds using simple Poisson distribution for specific betting markets (1X2, Over/Under 2.5, Both Teams to Score). It specifies the verb 'calcola' (calculates) and the resource type (probabilities/odds), though it doesn't explicitly differentiate from sibling tools like 'odds.prematch' or 'value.detect' which might handle similar betting data.

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?

No guidance is provided on when to use this tool versus alternatives. The description doesn't mention prerequisites, context, or comparisons to sibling tools like 'odds.prematch' (which might provide pre-match odds) or 'value.detect' (which might detect value bets). It only states what the tool does, not when it's appropriate.

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/Valerio357/bet_mcp'

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