Skip to main content
Glama
tachibanayu24

jgrants-mcp

get_subsidy_detail

Retrieve detailed information about a specific subsidy by entering its unique subsidy ID to access comprehensive data and requirements.

Instructions

Get detailed information about a specific subsidy. Use the subsidy ID, not the title.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
subsidy_idYesSubsidy ID

Implementation Reference

  • Handler for the 'get_subsidy_detail' tool. Parses arguments using schema, fetches subsidy details from the API, processes attachment metadata without full data, constructs a summary, and returns structured content.
    case "get_subsidy_detail": {
      const args = GetSubsidyDetailSchema.parse(request.params.arguments);
    
      try {
        const response = await fetch(
          `${API_BASE_URL}/subsidies/id/${args.subsidy_id}`
        );
        if (!response.ok) {
          const errorBody = await response.text();
          throw new Error(`API error: ${response.status} - ${errorBody}`);
        }
        const data = (await response.json()) as SubsidyDetailResponse;
    
        // Check result
        if (!data.result || data.result.length === 0) {
          return {
            content: [
              {
                type: "text",
                text: `Subsidy with ID ${args.subsidy_id} was not found.`,
              },
            ],
          };
        }
    
        const subsidyInfo = data.result[0];
    
        // 添付ファイルは軽量メタ情報(index, name, サイズ等)のみ返し、実データは download_attachment で取得
        // Base64 文字列長から概算バイトサイズを計算(デコードコストを回避)
        const calculateBase64Size = (base64: string): number => {
          // 改行などの空白文字を除去(API が 76 文字ごとの改行付きで返すケースに対応)
          const cleanBase64 = base64.replace(/\s+/g, "");
          const paddingCount = cleanBase64.endsWith("==")
            ? 2
            : cleanBase64.endsWith("=")
              ? 1
              : 0;
          return Math.floor((cleanBase64.length * 3) / 4) - paddingCount;
        };
    
        // 添付配列から軽量メタ情報を生成する共通ヘルパー
        const buildAttachmentList = (
          attachments?: Array<{ name: string; data: string }>
        ) =>
          attachments?.map((attachment, index) => ({
            index,
            name: attachment.name,
            sizeBytes: calculateBase64Size(attachment.data),
          })) ?? [];
    
        const applicationGuidelinesAttachments = buildAttachmentList(
          subsidyInfo.application_guidelines
        );
        const outlineOfGrantAttachments = buildAttachmentList(
          subsidyInfo.outline_of_grant
        );
        const applicationFormAttachments = buildAttachmentList(
          subsidyInfo.application_form
        );
    
        const subsidySummary: SubsidyDetailSummary = {
          ...subsidyInfo,
          application_guidelines: {
            count: applicationGuidelinesAttachments.length,
            hasAttachments: applicationGuidelinesAttachments.length > 0,
            attachments: applicationGuidelinesAttachments,
          },
          outline_of_grant: {
            count: outlineOfGrantAttachments.length,
            hasAttachments: outlineOfGrantAttachments.length > 0,
            attachments: outlineOfGrantAttachments,
          },
          application_form: {
            count: applicationFormAttachments.length,
            hasAttachments: applicationFormAttachments.length > 0,
            attachments: applicationFormAttachments,
          },
        };
    
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify(subsidySummary, null, 2),
            },
          ],
          structuredContent: subsidySummary,
        };
      } catch (error) {
        return {
          content: [
            {
              type: "text",
              text: `Error occurred: ${
                error instanceof Error ? error.message : "Unknown error"
              }`,
            },
          ],
        };
      }
    }
  • Zod schema defining the input for 'get_subsidy_detail': requires 'subsidy_id' string.
    const GetSubsidyDetailSchema = z.object({
      subsidy_id: z.string(),
    });
  • index.ts:69-83 (registration)
    Registration of the 'get_subsidy_detail' tool in the list_tools response, including name, description, and input schema.
    {
      name: "get_subsidy_detail",
      description:
        "Get detailed information about a specific subsidy. Use the subsidy ID, not the title.",
      inputSchema: {
        type: "object",
        properties: {
          subsidy_id: {
            type: "string",
            description: "Subsidy ID",
          },
        },
        required: ["subsidy_id"],
      },
    },

Tool Definition Quality

Score is being calculated. Check back soon.

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/tachibanayu24/jgrants-mcp'

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