Skip to main content
Glama
shomechakraborty

Scientific Tools MCP Server

analytics

Retrieve usage analytics and revenue data including call volumes, success rates, latency, and dynamic pricing recommendations. Choose from summary, revenue projection, or pricing report types.

Instructions

Query usage analytics and revenue data for this MCP server. Returns call volumes, revenue, success rates, latency, and dynamic pricing recommendations.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
report_typeNoType of analytics report to returnsummary
projection_daysNoDays to project revenue forward (for revenue_projection)

Implementation Reference

  • Async handler for the analytics tool. Dispatches to summary_report(), revenue_projection(), or returns current/pricing data based on report_type argument.
    async def analytics_handler(arguments: dict) -> dict:
        engine = get_engine()
        report_type = arguments.get("report_type", "summary")
    
        if report_type == "summary":
            return engine.summary_report()
        elif report_type == "revenue_projection":
            days = int(arguments.get("projection_days", 30))
            return engine.revenue_projection(days)
        elif report_type == "pricing":
            return {
                "current_prices": {
                    name: stats.current_price
                    for name, stats in engine._stats.items()
                },
                "price_history": {
                    name: stats.price_history[-3:]
                    for name, stats in engine._stats.items()
                },
            }
        return {"error": f"Unknown report type: {report_type}"}
  • Input schema for the analytics tool: accepts 'report_type' (enum: summary, revenue_projection, pricing) and optional 'projection_days' integer.
    ANALYTICS_TOOL_SCHEMA = {
        "type": "object",
        "properties": {
            "report_type": {
                "type": "string",
                "enum": ["summary", "revenue_projection", "pricing"],
                "description": "Type of analytics report to return",
                "default": "summary",
            },
            "projection_days": {
                "type": "integer",
                "description": "Days to project revenue forward (for revenue_projection)",
                "default": 30,
            },
        },
    }
  • Registration function that registers the 'analytics' tool with name, description, input_schema, price, stripe_price_id, handler, and category='internal'.
    def register(registry) -> None:
        from server import ToolDefinition
        registry.register(ToolDefinition(
            name="analytics",
            description=(
                "Query usage analytics and revenue data for this MCP server. "
                "Returns call volumes, revenue, success rates, latency, "
                "and dynamic pricing recommendations."
            ),
            input_schema=ANALYTICS_TOOL_SCHEMA,
            price_per_call_usd=0.001,
            stripe_price_id=os.getenv("STRIPE_PRICE_ANALYTICS", "price_demo_analytics"),
            handler=analytics_handler,
            category="internal",
        ))
  • AnalyticsEngine class that tracks per-tool call volumes, latency, error rates, revenue, and runs periodic pricing optimisation.
    class AnalyticsEngine:
        """
        Tracks all tool calls and runs periodic pricing optimisation.
        Integrates with the MCP server's UsageTracker.
        """
    
        def __init__(self):
            self._stats: dict[str, ToolStats] = {}
            self._last_optimised: float = 0.0
  • ToolStats dataclass capturing per-tool metrics: calls, revenue, latency, customers, hourly call distribution, price history.
    @dataclass
    class ToolStats:
        tool_name: str
        total_calls: int = 0
        successful_calls: int = 0
        failed_calls: int = 0
        total_revenue_usd: float = 0.0
        total_latency_ms: float = 0.0
        unique_customers: set = field(default_factory=set)
        hourly_calls: dict = field(default_factory=lambda: defaultdict(int))
        current_price: float = 0.0
        price_history: list = field(default_factory=list)
    
        @property
        def success_rate(self) -> float:
            if self.total_calls == 0:
                return 1.0
            return self.successful_calls / self.total_calls
    
        @property
        def avg_latency_ms(self) -> float:
            if self.successful_calls == 0:
                return 0.0
            return self.total_latency_ms / self.successful_calls
    
        @property
        def revenue_per_call(self) -> float:
            if self.successful_calls == 0:
                return 0.0
            return self.total_revenue_usd / self.successful_calls
    
        def calls_in_last_n_hours(self, n: int = 24) -> int:
            now_hour = datetime.now(timezone.utc).replace(minute=0, second=0, microsecond=0)
            total = 0
            for i in range(n):
                hour_key = (now_hour - timedelta(hours=i)).isoformat()
                total += self.hourly_calls.get(hour_key, 0)
            return total
Behavior3/5

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

No annotations are provided, so the description must carry the burden. It describes a query operation with no side effects, but does not explicitly state read-only behavior, authorization needs, or rate limits.

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 a single sentence that efficiently conveys the tool's purpose and returns, with no wasted words. It is front-loaded with the core action.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the simple input schema (two optional parameters) and no output schema, the description adequately explains what the tool does and what it returns. It could mention that results are specific to this MCP server, but that is inferred.

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%, so baseline is 3. The description does not add new meaning beyond the schema; it mentions return types but does not elaborate on parameters.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/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: querying usage analytics and revenue data for the MCP server, and lists specific return values (call volumes, revenue, success rates, latency, dynamic pricing). This distinguishes it from sibling tools which cover different domains like compounds or GPU prices.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implicitly indicates use for analytics queries; sibling tools are in distinct domains, so context is clear. However, there is no explicit guidance on when to use or avoid this tool, nor mention of alternatives.

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/shomechakraborty/mcp-scientific-tools'

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