Skip to main content
Glama

limit

Calculate the limit of a function as a variable approaches a specific value. Ideal for analyzing mathematical behavior and solving calculus problems.

Instructions

Calculate the limit of a function as it approaches a value

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
approachYesValue the variable approaches
expressionYesFunction to evaluate limit
variableYesVariable approaching the limit

Implementation Reference

  • index.js:324-338 (registration)
    Registration of the 'limit' MCP tool using ai.defineTool, specifying name, description, input/output schemas, and handler function that delegates to findLimit.
    ai.defineTool( { name: 'limit', description: 'Calculate the limit of a function as it approaches a value', inputSchema: z.object({ expression: z.string().describe('Function to evaluate limit'), variable: z.string().describe('Variable approaching the limit'), approach: z.number().describe('Value the variable approaches') }), outputSchema: z.union([z.number(), z.string()]), }, async ({ expression, variable, approach }) => { return findLimit(expression, variable, approach); } );
  • Input schema defines parameters: expression (string), variable (string), approach (number). Output schema is union of number or string.
    inputSchema: z.object({ expression: z.string().describe('Function to evaluate limit'), variable: z.string().describe('Variable approaching the limit'), approach: z.number().describe('Value the variable approaches') }), outputSchema: z.union([z.number(), z.string()]),
  • Core handler logic: parses the expression, evaluates it at points epsilon away from the approach value from both sides, averages if they match within epsilon, else reports limit does not exist or error.
    const findLimit = (expr, variable, approach) => { try { const node = math.parse(expr); const scope = {}; const epsilon = 1e-10; // Evaluate near the approach point scope[variable] = approach + epsilon; const rightLimit = math.evaluate(node, scope); scope[variable] = approach - epsilon; const leftLimit = math.evaluate(node, scope); // Check if limits from both sides are approximately equal if (Math.abs(rightLimit - leftLimit) < epsilon) { return (rightLimit + leftLimit) / 2; } return 'Limit does not exist'; } catch (e) { return `Error: ${e.message}`; } };

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

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