Enable Cursor to directly access the terminal to read the output and fix issues

This lesson demonstrates how to give Cursor direct access to your terminal output using the Nx MCP extension, enabling automatic error detection and fixing in monorepo projects.

Workflow demonstrated in this lesson:

  • Encounter a runtime error when serving a Vite application in an Nx monorepo
  • Install and configure the Nx Console extension with MCP integration
  • Ask Cursor to check your terminal for errors and fix the underlying issues
  • Watch as the AI accesses running task details and terminal output through Nx MCP tools
  • Observe how it analyzes workspace relationships to identify incorrect imports and missing dependencies

Key benefits:

  • Seamless Error Handling: AI gains direct access to terminal output and running task information
  • Automatic Diagnosis: Accurately identify the root cause of errors without manual copying
  • Context-Aware Fixes: Leverage workspace knowledge to implement proper solutions
  • Reduced Context Switching: Eliminate the need to manually relay information between terminal and AI
Share with a coworker

Transcript

[00:00] So here's a Vite app I'm currently coding, and you see there's a mistake happening here. It's actually a pretty obvious one, but I want to show you something which is actually pretty neat. So I run here to dev server, and when I serve it, I run into this issue because apparently I made a mistake by importing this product. Now, the annoying thing right now is if I'm more like in a cursor AI driven way of coding this app where cursor kind of controls most of the flow and I'm just like instructing it with new features It's kind of annoying that it doesn't have access to the terminal. So basically I need to go here and add it to the chat, but it would be much nicer if it could just access the terminal, understand what's currently running, figure out what's wrong, auto-fix it as it is kind of implementing the feature on its own.

[00:45] And so in this particular setup I'm using NX, which is here a small monorepo, and I have their extension installed, which is NX console, and also configured here in my MCP settings. And so that exposes a couple of tools, one of which is also the ability to read what is currently running in the terminal in terms of which tasks are currently running, in this case the serving of my shop application, but also the actual terminal output. So having that I can go here and say something like, Can you please check my current task in the terminal? It looks like something went wrong when serving the application. Can you please fix it?

[01:23] And so now you can see it invokes the MCP tool from an axe which gives it access to the current running task details. So it understands that I'm running shop now it wants to get an output of that task and this gives it access to the actual stack trace and the errors. And so now it understands where there's some error because it cannot import the product detail. So it tries to use the NX Workspace tool, which gives it access to the projects, the relationships, et cetera, as well as information such as the actual import name. And so now it understands that the library is actually called AI Shop Feature Product Details.

[02:08] And it even figures that I have a missing dependency. So it goes ahead and imports this properly, which I can accept here. It now tries to do a bunch of different steps as well. If I have a look here though, the application again surfs and so cursor properly figured out what is going wrong by reading automatically the terminal and then correcting it in the actual code.