Skip to main content
Glama
nrwl

Nx MCP Server

Official
by nrwl
init-nx-commands-view.ts1.62 kB
import { logAndShowTaskCreationError } from '@nx-console/vscode-output-channels'; import { CliTaskProvider } from '@nx-console/vscode-tasks'; import { commands, ExtensionContext, window } from 'vscode'; import { NxCommandsTreeProvider } from './nx-commands-provider'; export const EXECUTE_ARBITRARY_COMMAND = 'nxConsole.executeArbitraryCommand'; export function initNxCommandsView(context: ExtensionContext) { const nxCommandsTreeView = window.createTreeView('nxCommands', { treeDataProvider: new NxCommandsTreeProvider(context), }); context.subscriptions.push( commands.registerCommand('nxConsole.editCommonCommands', () => { commands.executeCommand( 'workbench.action.openSettings', 'nxConsole.commonNxCommands' ); }), commands.registerCommand( EXECUTE_ARBITRARY_COMMAND, executeArbitraryCommand ), nxCommandsTreeView ); } async function executeArbitraryCommand(command: string, cwd?: string) { let _command: string; let positional: string | undefined; const commandBeforeFlags = command.split(' -')[0]; if (commandBeforeFlags.includes(' ')) { _command = commandBeforeFlags.split(' ')[0]; positional = commandBeforeFlags.replace(_command, '').trim(); } else { _command = commandBeforeFlags; positional = undefined; } const flags = command .replace(commandBeforeFlags, '') .split(' ') .filter(Boolean); try { CliTaskProvider.instance.executeTask({ command: _command, positional, flags, cwd, }); } catch (e) { logAndShowTaskCreationError(e); return; } }

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/nrwl/nx-console'

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