Skip to main content
Glama
nbiish
by nbiish

derivative

Calculate derivatives of mathematical expressions to solve calculus problems, analyze functions, and find rates of change in variables.

Instructions

Calculate the derivative of a mathematical expression

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
expressionYesMathematical expression (e.g., "x^2", "e^x", "sin(x)")
variableNoVariable to differentiate with respect to (default: x)

Implementation Reference

  • index.js:9-17 (handler)
    Core handler function that parses the mathematical expression using mathjs and computes its derivative with respect to the specified variable.
    const derivative = (expr, variable = 'x') => {
      try {
        const node = math.parse(expr);
        const derivativeExpr = math.derivative(node, variable);
        return derivativeExpr.toString();
      } catch (e) {
        return `Error: ${e.message}`;
      }
    };
  • Defines the input schema (expression string required, variable string optional) and output schema (string) for the derivative tool.
    inputSchema: z.object({
      expression: z.string().describe('Mathematical expression (e.g., "x^2", "e^x", "sin(x)")'),
      variable: z.string().optional().describe('Variable to differentiate with respect to (default: x)')
    }),
    outputSchema: z.string(),
  • index.js:80-93 (registration)
    Registers the 'derivative' tool with Genkit using ai.defineTool, providing name, description, schema, and a wrapper handler that delegates to the core derivative function.
    ai.defineTool(
      {
        name: 'derivative',
        description: 'Calculate the derivative of a mathematical expression',
        inputSchema: z.object({
          expression: z.string().describe('Mathematical expression (e.g., "x^2", "e^x", "sin(x)")'),
          variable: z.string().optional().describe('Variable to differentiate with respect to (default: x)')
        }),
        outputSchema: z.string(),
      },
      async ({ expression, variable = 'x' }) => {
        return derivative(expression, variable);
      }
    );
  • Thin wrapper handler function that calls the core derivative helper with the input parameters.
    async ({ expression, variable = 'x' }) => {
      return derivative(expression, variable);
    }
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 but only states what the tool does, not how it behaves. It doesn't mention error handling (e.g., invalid expressions), computational limitations, output format, or whether it's a pure function. For a mathematical tool with zero annotation coverage, this represents a significant gap in behavioral context.

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 perfectly concise at just one sentence that directly states the tool's purpose with zero wasted words. It's front-loaded with the essential information and doesn't include any unnecessary elaboration or redundant phrasing.

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 mathematical calculation tool with no annotations and no output schema, the description is insufficiently complete. It doesn't explain what the output looks like (e.g., simplified expression, step-by-step solution), error conditions, or mathematical limitations. Given the complexity of derivative calculation and the rich sibling tool context, more contextual information would be helpful.

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 description doesn't add any parameter information beyond what's already in the schema, which has 100% coverage with clear descriptions for both parameters. The baseline is 3 when the schema does the heavy lifting, and the description neither compensates for gaps nor provides additional semantic context about parameter usage.

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 function with a specific verb ('calculate') and resource ('derivative of a mathematical expression'), making the purpose immediately understandable. However, it doesn't explicitly differentiate from sibling tools like 'integral' or 'limit' that also perform mathematical operations, 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. With multiple mathematical operation siblings (integral, limit, solve, etc.), there's no indication of when differentiation is appropriate versus integration or other operations, leaving the agent without contextual usage information.

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/nbiish/mcp-calc-tools'

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