query_company_overseas_investments
Retrieve detailed overseas investment data for a company, including amount, shareholding ratio, and shareholder type, using the company's full name. Ensure accurate results by first obtaining the company's full name via a fuzzy query tool.
Instructions
Query external investment information, such as the amount, shareholding ratio, shareholder type, etc., by the company's full name. Please use the fuzzy query tool to obtain the company full name before calling this tool.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| entName | Yes | company full name |
Implementation Reference
- src/index.ts:166-180 (handler)The handler function that executes the tool logic: takes company full name (entName), calls the shared yushantwo API helper with product ID 'COM045' specific to overseas investments, and returns the API response as text content.async ({entName}) => { const requestData = { entName: entName }; const prodId = "COM045"; const data = await yushantwo(requestData, prodId); return { content: [ { type: "text", text: data, }, ], }; }
- src/index.ts:163-165 (schema)Input schema defining the required 'entName' parameter as a string (company full name).{ entName: z.string().describe("company full name"), },
- src/index.ts:160-181 (registration)Registration of the 'query_company_overseas_investments' tool using server.tool(), including name, description, input schema, and handler function.server.tool( "query_company_overseas_investments", "Query external investment information, such as the amount, shareholding ratio, shareholder type, etc., by the company's full name. Please use the fuzzy query tool to obtain the company full name before calling this tool.", { entName: z.string().describe("company full name"), }, async ({entName}) => { const requestData = { entName: entName }; const prodId = "COM045"; const data = await yushantwo(requestData, prodId); return { content: [ { type: "text", text: data, }, ], }; } );
- src/index.ts:49-86 (helper)Shared helper function yushantwo that handles API calls to the Yushan service: encrypts request body with AES, sends POST with specific headers and prod_id, decrypts response, used by all tools including this one.async function yushantwo(requestData: RequestData, prodId: string): Promise<string> { const url = "***"; const reqTime = Date.now(); const requestSN = Array.from({ length: 32 }, () => "ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678"[Math.floor(Math.random() * 58)]).join(""); const requestBody = JSON.stringify({ prod_id: prodId, req_data: requestData, req_time: reqTime, request_sn: requestSN, }); // 加密请求数据 const encryptedRequest = encrypt(requestBody, apiKey); const headers = { AES_KEY: apiKey, ACCT_ID: apiUserId, ENCODE: "AES256", }; try { const response = await fetch(url, { method: "POST", headers: headers, body: encryptedRequest, }); const responseText = await response.text(); // 解密返回数据 const decryptedString = decrypt(responseText, apiKey); return decryptedString; } catch (e) { console.error("Error:", e); return "error"; } }