Skip to main content
Glama

get-membership-plans

Retrieve your membership plan details from note.com to view subscription options and manage your account access.

Instructions

自分のメンバーシッププラン一覧を取得する

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The inline handler function for the 'get-membership-plans' tool. It checks authentication, fetches membership plans from the Note API endpoint '/v2/circle/plans', safely extracts data, formats each plan using formatMembershipPlan, and returns a success response with the total count and formatted plans list. Handles errors appropriately.
    server.tool(
      "get-membership-plans",
      "自分のメンバーシッププラン一覧を取得する",
      {},
      async () => {
        try {
          if (!hasAuth()) {
            return createAuthErrorResponse();
          }
    
          const data = await noteApiRequest("/v2/circle/plans", "GET", null, true);
    
          if (env.DEBUG) {
            console.error(`\n===== FULL Membership Plans API Response =====\n${JSON.stringify(data, null, 2)}`);
          }
    
          const rawPlans = safeExtractData(data, commonExtractors.plans);
          const formattedPlans = rawPlans.map(formatMembershipPlan);
    
          if (env.DEBUG) {
            console.error(`Formatted plans: ${formattedPlans.length} items`);
            if (formattedPlans.length > 0) {
              console.error(`First formatted plan: ${JSON.stringify(formattedPlans[0], null, 2)}`);
            }
          }
    
          return createSuccessResponse({
            total: formattedPlans.length,
            plans: formattedPlans
          });
        } catch (error) {
          return handleApiError(error, "メンバーシッププラン取得");
        }
      }
    );
  • High-level registration of membership tools, which includes the 'get-membership-plans' tool, via calling registerMembershipTools from within registerAllTools.
    registerMembershipTools(server);
  • Helper function formatMembershipPlan used by the tool handler to format raw plan data into a standardized MembershipPlan structure, extracting relevant fields from circle and owner info.
    export function formatMembershipPlan(plan: any): MembershipPlan {
      const circle = plan.circle || {};
      const circlePlans = plan.circlePlans || [];
      const owner = circle.owner || {};
    
      return {
        id: circle.id || plan.id || "",
        key: circle.key || plan.key || "",
        name: circlePlans.length > 0 ? circlePlans[0].name || "" : circle.name || plan.name || "",
        description: circle.description || plan.description || "",
        price: plan.price || circle.price || 0,
        memberCount: circle.subscriptionCount || circle.membershipNumber || 0,
        notesCount: plan.notesCount || 0,
        status: circle.isCirclePublished ? "active" : "inactive",
        ownerName: owner.nickname || owner.name || "",
        headerImagePath: plan.headerImagePath || circle.headerImagePath || "",
        plans: circlePlans.map((p: any) => p.name || "").filter((n: string) => n),
        url: owner.customDomain ?
          `https://${owner.customDomain.host}/membership` :
          `https://note.com/${owner.urlname || ""}/membership`
      };
    }
  • The registerMembershipTools function that directly registers the 'get-membership-plans' tool on the MCP server.
    export function registerMembershipTools(server: McpServer) {
      // 1. 加入済みメンバーシップ一覧取得ツール
      server.tool(
        "get-membership-summaries",
        "加入済みメンバーシップ一覧を取得する",
        {},
        async () => {
          try {
            if (!hasAuth()) {
              return createAuthErrorResponse();
            }
    
            const data = await noteApiRequest("/v2/circle/memberships/summaries", "GET", null, true);
    
            if (env.DEBUG) {
              console.error(`\n===== FULL Membership Summaries API Response =====\n${JSON.stringify(data, null, 2)}`);
            }
    
            const rawSummaries = safeExtractData(data, commonExtractors.memberships);
            const formattedSummaries = rawSummaries.map(formatMembershipSummary);
    
            if (env.DEBUG) {
              console.error(`Returning real API data with ${formattedSummaries.length} formatted summaries`);
              if (formattedSummaries.length > 0) {
                console.error(`First formatted summary: ${JSON.stringify(formattedSummaries[0], null, 2)}`);
              }
            }
    
            return createSuccessResponse({
              total: formattedSummaries.length,
              summaries: formattedSummaries
            });
          } catch (error) {
            return handleApiError(error, "メンバーシップ一覧取得");
          }
        }
      );
    
      // 2. 自分のメンバーシッププラン一覧取得ツール
      server.tool(
        "get-membership-plans",
        "自分のメンバーシッププラン一覧を取得する",
        {},
        async () => {
          try {
            if (!hasAuth()) {
              return createAuthErrorResponse();
            }
    
            const data = await noteApiRequest("/v2/circle/plans", "GET", null, true);
    
            if (env.DEBUG) {
              console.error(`\n===== FULL Membership Plans API Response =====\n${JSON.stringify(data, null, 2)}`);
            }
    
            const rawPlans = safeExtractData(data, commonExtractors.plans);
            const formattedPlans = rawPlans.map(formatMembershipPlan);
    
            if (env.DEBUG) {
              console.error(`Formatted plans: ${formattedPlans.length} items`);
              if (formattedPlans.length > 0) {
                console.error(`First formatted plan: ${JSON.stringify(formattedPlans[0], null, 2)}`);
              }
            }
    
            return createSuccessResponse({
              total: formattedPlans.length,
              plans: formattedPlans
            });
          } catch (error) {
            return handleApiError(error, "メンバーシッププラン取得");
          }
        }
      );

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/shimayuz/note-com-mcp'

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