Skip to main content
Glama
oofengoo

MCP-Serve 多语言翻译服务

by oofengoo

copyI18n

Extract and translate text from project files to manage multilingual content using external translation APIs.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
rootPathYes

Implementation Reference

  • The main handler function for the 'copyI18n' tool. It downloads i18n files for Chinese and optionally English, saves them temporarily, copies to src/lang/source, and cleans up.
    async ({ rootPath }) => {
      let langArr = [{ name: "ZhCn", value: 1, filePath: "ZhCn.js" }];
      // 目前只有企业版需要英文文件
      if (port === "5500") {
        langArr.push({ name: "EnUs", value: 2, filePath: "EnUs.js" });
      }
      // 获取工作区根路径
      // const rootPath = process.cwd();
      let result = "";
      try {
        for (let lang of langArr) {
          const langTargetPath = path.join(
            rootPath,
            "src/lang/source",
            lang.filePath
          );
          const tempFilePath = path.join(rootPath, lang.filePath);
          // 创建一个写入流
          const writer = fs.createWriteStream(tempFilePath);
          const res = await downFile(lang.value);
          res.data.pipe(writer);
          await new Promise<void>((resolve, reject) => {
            writer.on("finish", () => resolve());
            writer.on("error", (err) => reject(err));
          });
          fs.copyFileSync(tempFilePath, langTargetPath);
          fs.unlinkSync(tempFilePath);
          console.log(`${lang.name}文件复制成功`);
          result = `${tempFilePath}文件复制成功`;
        }
      } catch (error) {
        console.log("文件复制失败", error);
        result = `文件复制失败${error},${rootPath},`;
      }
      return {
        content: [
          {
            type: "text",
            text: result,
          },
        ],
      };
    }
  • Input schema for the copyI18n tool, requiring a 'rootPath' string parameter.
    {
      rootPath: z.string(),
    },
  • src/index.ts:51-99 (registration)
    Registration of the 'copyI18n' tool using server.tool(), including schema and inline handler.
    server.tool(
      "copyI18n",
      {
        rootPath: z.string(),
      },
      async ({ rootPath }) => {
        let langArr = [{ name: "ZhCn", value: 1, filePath: "ZhCn.js" }];
        // 目前只有企业版需要英文文件
        if (port === "5500") {
          langArr.push({ name: "EnUs", value: 2, filePath: "EnUs.js" });
        }
        // 获取工作区根路径
        // const rootPath = process.cwd();
        let result = "";
        try {
          for (let lang of langArr) {
            const langTargetPath = path.join(
              rootPath,
              "src/lang/source",
              lang.filePath
            );
            const tempFilePath = path.join(rootPath, lang.filePath);
            // 创建一个写入流
            const writer = fs.createWriteStream(tempFilePath);
            const res = await downFile(lang.value);
            res.data.pipe(writer);
            await new Promise<void>((resolve, reject) => {
              writer.on("finish", () => resolve());
              writer.on("error", (err) => reject(err));
            });
            fs.copyFileSync(tempFilePath, langTargetPath);
            fs.unlinkSync(tempFilePath);
            console.log(`${lang.name}文件复制成功`);
            result = `${tempFilePath}文件复制成功`;
          }
        } catch (error) {
          console.log("文件复制失败", error);
          result = `文件复制失败${error},${rootPath},`;
        }
        return {
          content: [
            {
              type: "text",
              text: result,
            },
          ],
        };
      }
    );
  • Helper function 'downFile' used by copyI18n to download the i18n JSON file as a stream for a given language ID.
    async function downFile(language: number) {
      const streamConfig = {
        baseURL: `${url}`,
        headers: {
          Cookie: token,
        },
        responseType: "stream" as const
      };
      const res = await http.get(
        `/MultiLanguageResource/DownWebJson?language=${language}`,
        null,
        streamConfig
      );
      return res;
    }
Behavior1/5

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

Tool has no description.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness1/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Tool has no description.

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

Completeness1/5

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

Tool has no description.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters1/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Tool has no description.

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

Purpose1/5

Does the description clearly state what the tool does and how it differs from similar tools?

Tool has no description.

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

Usage Guidelines1/5

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

Tool has no description.

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/oofengoo/mcp-serve-learn'

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