Skip to main content
Glama

AutoDev Codebase MCP Server

by anrgct
get-relative-path.ts1.47 kB
import * as path from "path" import { getWorkspacePath } from "../../utils/path" /** * Generates a normalized absolute path from a given file path and workspace root. * Handles path resolution and normalization to ensure consistent absolute paths. * * @param filePath - The file path to normalize (can be relative or absolute) * @param workspaceRoot - The root directory of the workspace * @returns The normalized absolute path */ export function generateNormalizedAbsolutePath(filePath: string): string { const workspaceRoot = getWorkspacePath() // Resolve the path to make it absolute if it's relative const resolvedPath = path.resolve(workspaceRoot, filePath) // Normalize to handle any . or .. segments and duplicate slashes return path.normalize(resolvedPath) } /** * Generates a relative file path from a normalized absolute path and workspace root. * Ensures consistent relative path generation across different platforms. * * @param normalizedAbsolutePath - The normalized absolute path to convert * @param workspaceRoot - The root directory of the workspace * @returns The relative path from workspaceRoot to the file */ export function generateRelativeFilePath(normalizedAbsolutePath: string): string { const workspaceRoot = getWorkspacePath() // Generate the relative path const relativePath = path.relative(workspaceRoot, normalizedAbsolutePath) // Normalize to ensure consistent path separators return path.normalize(relativePath) }

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/anrgct/autodev-codebase'

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