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
find-project-root.ts•727 B
import { ASTNode } from 'vscode-json-languageservice';
import { isObjectNode, isPropertyNode, isStringNode } from './node-types';
/**
* Get the first `root` property from the current node to determine `${projectRoot}`
* @param node
* @returns
*/
export function findProjectRoot(node: ASTNode): string {
if (isObjectNode(node)) {
for (const child of node.children) {
if (isPropertyNode(child)) {
if (
(child.keyNode.value === 'root' ||
child.keyNode.value === 'sourceRoot') &&
isStringNode(child.valueNode)
) {
return child.valueNode?.value;
}
}
}
}
if (node.parent) {
return findProjectRoot(node.parent);
}
return '';
}