Skip to main content
Glama

get_user_subscription

Retrieve current subscription details including status, plan information, credit usage, and renewal status for ListenHub Pro users.

Instructions

Get current user subscription information, including subscription status, credit usage, plan details, and renewal status.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The main handler function for the 'get_user_subscription' tool. It queries the client for subscription data, formats it into a readable string with sections for period, credits, plan, and status, handles errors, and returns the formatted response.
    async execute(_args, {log}: {log: any}) { try { log.info('Querying user subscription information'); const response = await client.user.getUserSubscription(); if (response.code !== 0) { return `Failed to query subscription: ${response.message ?? 'Unknown error'}`; } if (!response.data) { return 'No subscription data available'; } const sub = response.data; const parts = [ '=== Subscription Information ===', '', '** Subscription Period **', `Started: ${formatTimestamp(sub.subscriptionStartedAt)}`, `Expires: ${formatTimestamp(sub.subscriptionExpiresAt)}`, `Reset Date: ${formatTimestamp(sub.resetAt)}`, '', '** Credit Usage **', `Monthly Credits: ${sub.usageAvailableMonthlyCredits} / ${sub.usageTotalMonthlyCredits} available`, `Permanent Credits: ${sub.usageAvailablePermanentCredits} / ${sub.usageTotalPermanentCredits} available`, `Limited-Time Credits: ${sub.usageAvailableLimitedTimeCredits}`, `Total Available Credits: ${sub.totalAvailableCredits}`, '', '** Subscription Plan **', `Plan: ${sub.subscriptionPlan.name.toUpperCase()}`, `Duration: ${sub.subscriptionPlan.duration}`, `Platform: ${sub.subscriptionPlan.platform}`, '', '** Status **', `Auto-Renew: ${sub.renewStatus ? 'Enabled' : 'Disabled'}`, `Paid Status: ${sub.paidStatus ? 'Active' : 'Inactive'}`, ]; log.info('User subscription retrieved', { plan: sub.subscriptionPlan.name, totalCredits: sub.totalAvailableCredits, }); return parts.join('\n'); } catch (error) { const errorMessage = formatError(error); log.error('Failed to query user subscription', {error: errorMessage}); return `Failed to query user subscription: ${errorMessage}`; } },
  • Registers the 'get_user_subscription' tool on the FastMCP server, specifying name, description, empty input schema (z.object({})), annotations, and the handler function.
    server.addTool({ name: 'get_user_subscription', description: 'Get current user subscription information, including subscription status, credit usage, plan details, and renewal status.', parameters: z.object({}), annotations: { title: 'Get User Subscription', openWorldHint: true, readOnlyHint: true, }, async execute(_args, {log}: {log: any}) { try { log.info('Querying user subscription information'); const response = await client.user.getUserSubscription(); if (response.code !== 0) { return `Failed to query subscription: ${response.message ?? 'Unknown error'}`; } if (!response.data) { return 'No subscription data available'; } const sub = response.data; const parts = [ '=== Subscription Information ===', '', '** Subscription Period **', `Started: ${formatTimestamp(sub.subscriptionStartedAt)}`, `Expires: ${formatTimestamp(sub.subscriptionExpiresAt)}`, `Reset Date: ${formatTimestamp(sub.resetAt)}`, '', '** Credit Usage **', `Monthly Credits: ${sub.usageAvailableMonthlyCredits} / ${sub.usageTotalMonthlyCredits} available`, `Permanent Credits: ${sub.usageAvailablePermanentCredits} / ${sub.usageTotalPermanentCredits} available`, `Limited-Time Credits: ${sub.usageAvailableLimitedTimeCredits}`, `Total Available Credits: ${sub.totalAvailableCredits}`, '', '** Subscription Plan **', `Plan: ${sub.subscriptionPlan.name.toUpperCase()}`, `Duration: ${sub.subscriptionPlan.duration}`, `Platform: ${sub.subscriptionPlan.platform}`, '', '** Status **', `Auto-Renew: ${sub.renewStatus ? 'Enabled' : 'Disabled'}`, `Paid Status: ${sub.paidStatus ? 'Active' : 'Inactive'}`, ]; log.info('User subscription retrieved', { plan: sub.subscriptionPlan.name, totalCredits: sub.totalAvailableCredits, }); return parts.join('\n'); } catch (error) { const errorMessage = formatError(error); log.error('Failed to query user subscription', {error: errorMessage}); return `Failed to query user subscription: ${errorMessage}`; } }, });
  • Zod schema for tool inputs: empty object (no parameters required).
    parameters: z.object({}), annotations: {
  • UserClient method that performs the HTTP GET request to '/v1/user/subscription' to fetch the subscription data, returning ApiResponse<UserSubscriptionInfo>.
    async getUserSubscription(): Promise<ApiResponse<UserSubscriptionInfo>> { const response = await this.axiosInstance.get< ApiResponse<UserSubscriptionInfo> >('/v1/user/subscription'); return response.data; }
  • Proxy method in ListenHubClient that delegates to the UserClient's getUserSubscription.
    async getUserSubscription() { return this.user.getUserSubscription(); }

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/marswaveai/listenhub-mcp-server'

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