Agent Mode

In version 1.102 of VS Code, Microsoft introduced Agent Modeopen in new window. Among other features, Agent Mode added support for the Model Context Protocol (MCP)open in new window, which enables AI models used in VS Code access to external tool APIs and services. MCP is evolving into an open standard. It is implemented by many vendors and projects, and is supported by various AI clients such as VS Code's GitHub Copilot Chatopen in new window and popular third-party VS Code extensions like Roo Codeopen in new window.

The MCP protocol is implemented by VS Code and many of its extensions as servers that provide access to data required by AI models to deliver accurate answers or to reach resources that are otherwise unavailable. Examples of MCP server functions include accessing your workspace files for review and modification, accessing your Git history to learn about recent changes and their reasons, and accessing resources on the internet, such as the latest documentation for tools and services that the AI model was not originally trained on. MCP tools can also perform active functions, such as executing VS Code tasks or running command-line operations in the terminal.

Z Open Editor adds its own set of MCP capabilities in the form of tools and resources that you can use with an AI chat. By leveraging Z Open Editor's Zowe APIs, the AI can interact with your z/OS system and access data sets, UNIX System Services files, and jobs. For example, you can ask the AI to list the members of a specific data set, fetch files that match a search pattern and compare them with files open in the current workspace, list your jobs and group them by status, or submit a new job using JCL that is selected in the editor or stored in a data set. In all cases, the AI displays the commands it intends to execute, shows the parameters, and requests your permission before proceeding. Another set of tools works with Z Open Editor's configuration files to help diagnose setup issues. You can ask the AI to check the editor's log file and ZAPP settings to determine why a copybook cannot be found for the currently open COBOL program. You can also inquire about your Zowe profiles and which defaults apply.

See the Z Open Editor MCP Reference page for a list of currently available MCP tools and resources. This list expands with each release as new tools are added incrementally.

How to use Agent Mode

As with any business use of AI, it is important to understand the implications. When you run MCP server tools and access resources, you grant the AI access to these data sources. This means content loaded from your z/OS system becomes available to the AI and is collected by the owners of the AI's language model. The AI can also create or delete files and data sets, execute jobs, and perform other operations.

It is therefore important to use these features only with AI setups that you trust and that are approved for use in your organization.

It is recommended not to enable "auto approve" features, which enable MCP tools to perform operations without user confirmation, to avoid accidental loss of data. All tools and resources provided by Z Open Editor must be explicitly enabled before they can be used. Enable them only when the preceding preconditions are met.

Also carefully review the Securityopen in new window section in the VS Code documentation about Agent Mode, which details additional potential security risks.

The main switch for Z Open Editor's MCP feature is the user setting: zopeneditor.mcp.enabled. It is disabled by default.

The following sections outline setup steps required for two AI chat clients tested with Z Open Editor's MCP server. These tools should also work with any other client that implements MCP and is used in your organization instead. Refer to those other client's documentation for details on how to configure third-party MCP servers using the "http-streaming" protocol.

Setup using GitHub Copilot Chat

GitHub Copilot Chat is Microsoft’s default AI‑chat solution for VS Code and enables Agent Mode. It requires a GitHub account and a subscription after the free request limit or trial period ends. The extension can be configured to work with different large language models from a list of providers. Detailed setup instructions are available in the VS Code documentationopen in new window.

Steps to enable and test Z Open Editor's MCP server:

  1. Install and configure the GitHub Copilot Chatopen in new window VS Code extension and sign in with your GitHub account.

  2. Ensure Agent Mode is enabled in VS Code with the user setting chat.agent.enabled.

  3. In the Chat panel's lower-left corner, change the mode drop-down from its default "Ask" value to "Agent".

  4. In the model selection drop-down next to it, select the large language model you are authorized to use. Use the "Manage Models.." item for additional configuration options if necessary.

  5. Load your source code workspace and create an MCP configuration file by adding an entry in the workspace's .vscode/mcp.json file. If you use a multi-root workspace or multiple editor windows, create one in each workspace you want to use, with unique name postfixes and port numbers to set the correct context for the AI. Alternatively, run the "MCP: Add Server" command to use prompts to create and edit the file.

    {
      "servers": {
        "zopeneditor-sample": { "url": "http://localhost:3005/mcp" }
      }
    }
    
  6. Ensure that the server name starts with zopeneditor followed by a workspace-specific prefix, as shown in the preceding example. This enables you and the AI to distinguish between different servers running in multiple workspaces. Each server you run in parallel requires a unique port number and name. Errors are shown in the Output panel called "Z Open Editor MCP" if a server cannot be started because its port is already in use.

  7. Enable Z Open Editor's MCP server with the user setting: zopeneditor.mcp.enabled.

  8. Reload the VS Code window to ensure all components are initialized and restarted.

  9. Check the Z Open Editor output panel for an INFO message reporting that the MCP feature is enabled (search for message id "CRRZG5452I").

  10. Switch to the Z Open Editor MCP output panel and observe the startup messages in this view. It is recommended to set Z Open Editor's logger to the DEBUG level to see more detailed information. The log should report that it found the mcp.json file and started the server using the information specified for the workspace in which is was found.

  11. Switch back to the Chat panel in VS Code and click the tools icon at the bottom-right.

  12. In the panel that appears at the top, the list of MCP tools is displayed. Below the "Built-In" section, locate the entry that matches the name of the server specified in the mcp.json file. Expand it to view all MCP tools provided by Z Open Editor.

  13. Alternatively type /list in the Chat panel to obtain the list of tools in the Chat's output.

  14. If the tools do not appear, check the Output panels again for any errors reported.

  15. Execute any tool directly in the chat by using # with code completion on the tools list. For example, #zowe-list-all-profiles typed into the chat lists your profiles, assuming Zowe profiles defined.

Examples of using the tools

After the MCP server starts, you can access it from the Chat panel. Refer to the Z Open Editor page for a list of available tools, you can combine them with tools from other MCP servers and with the built‑in tools. Here are few things you can try. Note, the responses you receive depend on the language model you use and on other factors.

Try some of the following examples, if a valid Zowe profile is configured in your workspace that can be used to access z/OS data sets, files, and jobs through Zowe Explorer. Replace the example names with your own.

  • "List the members of the data set USER.SAMPLE.COBOL that start with the prefix SAM". The AI prompts you for permission to execute the MCP tool "zowe-get-members" with the data set name you provided. After you approve the execution, the tool returns the list of members that start with SAM. Expand and examine the tool entry in the chat to see the full response. You see that the AI reduced the full list of members it received to the members that match the prefix.

  • Open a modified version of one of the programs listed in the previous step and ask "Download the member with the name SAM1 and compare to the currently open COBOL program in my editor." The chat asks for approval to execute the "zowe-download-member" tool. After approval, the tool fetches the member and the AI provides a detailed explanation of the differences. The more the large language mode is trained on COBOL, the richer the explanation. If your are looking for a sample program, use the files "COBOL/SAM1.cbl" and "multiroot/sam/SAM1.cbl" from our samples repository. They are different versions of the same application.

  • "What are the jobs of user IBMUSER grouped by status?" The AI returns a list of job names organized in sections by status.

  • Use Zowe Explorer to open a JCL file from one of your data sets in Z Open Editor and ask "Submit the JCL in the currently open editor as a job." It will prompt for approval of the "zowe-submit-job-dataset" tool with the correct data set name. If you would have opened a local file it would have used the tool "zowe-submit-job-jcl" instead. After it ran the command it will show you the job id, name, and status of your job. It might even ask you to retrieve the job output or current status.

  • Do retrieve the outputs from your job by replying "Yes, retrieve the spool files for me." which will result into the list of files available, asking you which one you want to see. Reply with "Show me SYSOUT", which it then retrieves and displays in the chat. If the output contained error messages, then some AI models will even explain the reasons for why things might have gone wrong. If you ask "Fetch SYSOUT and open it in a VS Code editor tab", it would do that as well after asking you for permission, if it is allowed to save the content in a workspace file first.

  • "Fetch my .profile file from my UNIX home directory and open it in the editor. My userid is ibmuser.". The AI deduces the home directory "/u/ibmuser", asks for approval, downloads the file, and opens it in VS Code. If the deduction is incorrect, reject the request and refine the prompt with more specifics.

In addition to Zowe interactions, you can use tools and resources provided by Z Open Editor's MCP server to query your configuration.

  • "List my Zowe profiles and the profiles defined as default for Z Open Editor.". The AI executes two MCP tools, "zowe-list-all-profiles" and "zopeneditor-get-default-zowe-profile", then lists all profiles found in your personal Zowe team configuration files together with the default profile used by Z Open Editor.

  • "What are my ZAPP property groups for this workspace for COBOL and HLASM?". AI calls "zapp-get-property-groups" twice and returns a summary for each language, assuming the property groups are defined in your ZAPP file.

  • Open a program where some copybooks cannot be found and ask: "Using the zopeneditor.log resource and the ZAPP property groups, analyze why copybook include files could not be found for the currently open program?" Depending on the language model, the AI automatically uses the MCP resource defined by Z Open Editor MCP or prompts you to execute the tool "zopeneditor-read-the-log" together with he previously retrieved ZAPP information, then provides a detailed breakdown of the search process, listing locations that succeeded, locations that failed, and user settings that may have influenced the search.

  • To use the Z Open Editor log file as a resource in GitHub Chat, click the "Add Context..." button in the chat panel, select the file under "MCP Resources" in the prompt at the top of the screen and confirm. The log file then appears next to the open program as context for your questions. You can use it to find various types of information from a DEBUG-level log file, such as details about your Zowe configuration, the version of Java used by the editor, user setting values, and more.

You can combine Z Open Editor’s capabilities with the VS Code built‑in MCP tools listed earlier.

  • Open a COBOL program and run an IBM ZCodeScan through the right-click menu. If the scan finds issues they will be listed in the VS Code Problems view panel and can be utilized by the Chat. Ask "Can you explain the issues listed in the Problems view for COBOL developers and how to fix them?" If your large language model has been trained on COBOL, it will give you a detailed description of the problems found and make suggestions for how to fix them.

  • "Who made the last few changes on this program looking at the Git history?". The AI generates a command line that queries the local Git repository, retrieves recent commits, and displays their descriptions.

  • "Can you find other programs in the workspace that have the same ACCEPT-DATE and ACCEPT-TIME statements that need fixing?". The AI uses the context of the previous interactions, runs a VS Code Search to find similar statements in other files in your workspace and lists the matching files with line numbers.

As these examples demonstrate, a basic set of MCP tools can be used and combined in many ways, providing endless opportunities to make your development activities more productive. You no longer have to learn the syntax of complex Zowe CLI commands, search manually through large log files, or download, save, and compare files versions. Just ask the AI to do this for you. With many more tools on the horizon, IDz on VS Code seamlessly integrates into your AI workflows and use cases, delivering new capabilities as more tools become available.

Setup using Roo Code

Roo Codeopen in new window is gaining popularity as an alternative to GitHub Copilot Chat. It offers on-premises solutions with custom large language models, agentic multi-step tasks for larger workflows, and additional developer features such as workspace indexing.

To setup Z Open Editor's MCP with Roo Code

  1. Install the Roo Code VS Code extensionopen in new window.

  2. Configure your large language model by selecting a provider, entering API keys, and following the steps documented for Roo Code.

  3. Load your source code workspace and create an MCP configuration file, or add an entry in the workspace's .roo/mcp.json file. As shown in the example below, the location and format of the file differ slightly from those used for VS Code GitHub Chat.

    {
      "mcpServers": {
        "zopeneditor-sample": {
          "url": "http://localhost:3005/mcp",
          "type": "streamable-http"
        }
      }
    }
    
  4. Enable Z Open Editor's MCP server with the user setting: zopeneditor.mcp.enabled.

  5. Reload the VS Code window to ensure all components are initialized and restarted.

  6. At the top-right of the Roo Code chat panel, select the menu button (three dots) and choose "MCP Servers" item.

  7. In the MCP Servers panel, verify that your "zopeneditor" server is listed. Use the Refresh buttons in the panel if it is not visible or is disabled.

  8. After enabled, expand the "zopeneditor" entry and see all the MCP tools listed.

  9. Close the panel with the "Done" button and start a chat.

  10. Ask "List all Zowe profiles". The chat prompts you to approve the execution of the "zowe-list-all-profiles" MCP tool. After you click Approve, the list appears.

Last Updated:
Contributors: PETER HAUMER, Peter Haumer