Skip to main content
Glama
yfmeii

WeChat Mini Program Dev MCP

by yfmeii

mp_setDefaultProject

Set the default mini program project path to prioritize it in subsequent connections, enabling retry after project selection failures.

Instructions

设置默认的小程序项目路径,设置后下次连接会优先使用该项目。通常用于修复项目选择失败后的后续重试。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
projectPathYes

Implementation Reference

  • The tool handler function that defines and executes mp_setDefaultProject. It parses the projectPath argument, calls manager.setDefaultProject(), and returns a success/error result.
    function createSetDefaultProjectTool(manager: WeappAutomatorManager): AnyTool {
      return {
        name: "mp_setDefaultProject",
        description: "设置默认的小程序项目路径,设置后下次连接会优先使用该项目。通常用于修复项目选择失败后的后续重试。",
        parameters: setDefaultProjectParameters,
        execute: async (rawArgs) =>
          withUserErrorResult(async () => {
          const args = setDefaultProjectParameters.parse(rawArgs);
          const success = await manager.setDefaultProject(args.projectPath);
    
          if (success) {
            return toTextResult(
              formatJson({
                success: true,
                message: `已设置默认项目: ${args.projectPath}`,
              })
            );
          }
          return toErrorResult(`无效的项目路径或项目目录不存在: ${args.projectPath}`);
          }),
        timeoutMs: 5000,
      };
    }
  • Zod schema for mp_setDefaultProject input parameter: requires a non-empty trimmed string projectPath.
    const setDefaultProjectParameters = z.object({
      projectPath: z.string().trim().min(1),
    });
  • Registration of the tool in the createApplicationTools array. The createSetDefaultProjectTool(manager) is exported as part of the tools list.
    export function createApplicationTools(
      manager: WeappAutomatorManager
    ): AnyTool[] {
      return [
        createEnsureConnectionTool(manager),
        createNavigateTool(manager),
        createScreenshotTool(manager),
        createCallWxMethodTool(manager),
        createGetConsoleLogsTool(manager),
        createCurrentPageTool(manager),
        createListProjectsTool(manager),
        createSetDefaultProjectTool(manager),
      ];
  • Helper method setDefaultProject on WeappAutomatorManager that validates the project path and saves it. Called by the tool handler.
    async setDefaultProject(projectPath: string): Promise<boolean> {
      if (!(await this.isValidWeappProject(projectPath))) {
        return false;
      }
      await this.saveProjectPath(projectPath);
      return true;
    }
  • Helper that checks if a directory is a valid WeChat project by verifying project.config.json exists and has appid or projectname.
    private async isValidWeappProject(projectPath: string): Promise<boolean> {
      const configPath = path.join(projectPath, "project.config.json");
      
      try {
        await fs.promises.access(configPath, fs.constants.F_OK);
        const content = await fs.promises.readFile(configPath, "utf-8");
        const config = JSON.parse(content);
        return !!(config.appid || config.projectname);
      } catch {
        return false;
      }
    }
Behavior3/5

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

The description discloses that setting the default affects the next connection, adding behavioral context beyond the absent annotations. However, it does not mention potential side effects, permissions, or reversibility, limiting full transparency.

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

Conciseness5/5

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

The description is two concise sentences, front-loaded with the primary action and use case, with no unnecessary words.

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

Completeness4/5

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

For a simple setter tool with one parameter and no output schema, the description covers purpose and typical usage scenario, but misses details on return values, error states, or prerequisites. It is largely complete given the tool's simplicity.

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?

The input schema has one parameter with 0% description coverage, and the description does not mention the parameter or its intended use, providing no additional meaning beyond the schema.

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

Purpose5/5

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

The description clearly states the verb 'set' and the resource 'default mini-program project path', and distinguishes its purpose from sibling tools by specifying it is used for retrying after project selection failure.

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

Usage Guidelines4/5

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

The description provides a clear use case: 'usually used for retry after project selection failure.' It implies when to use but does not explicitly mention when not to use or alternatives.

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/yfmeii/weapp-dev-mcp'

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