Skip to main content
Glama
debug-ast.js•1.68 kB
import { parse } from '@babel/parser'; import traverse from '@babel/traverse'; const code = ` const usersSlice = createSlice({ name: 'users', initialState: { items: [], loading: false, error: null }, reducers: { clearError: (state) => { state.error = null; } }, extraReducers: (builder) => { builder .addCase(fetchUsers.pending, (state) => { state.loading = true; state.error = null; }) .addCase(fetchUsers.fulfilled, (state, action) => { state.loading = false; state.items = action.payload; }) .addCase(fetchUsers.rejected, (state, action) => { state.loading = false; state.error = action.payload; }); } }); `; const ast = parse(code, { sourceType: 'module', plugins: ['jsx', 'typescript', 'decorators-legacy'], }); console.log('šŸ” Analyzing AST structure...'); traverse(ast, { AssignmentExpression(path) { const left = path.node.left; if (left.type === 'MemberExpression' && left.object.name === 'state') { console.log(`\nšŸ“ Found state mutation at line ${path.node.loc?.start.line}:`); console.log(` Assignment: ${left.object.name}.${left.property.name} = ...`); // Debug the path structure console.log('\nšŸ” Path structure:'); let currentPath = path; let depth = 0; while (currentPath && depth < 10) { console.log(` ${depth}: ${currentPath.node.type} (${currentPath.node.key?.name || currentPath.node.callee?.name || ''})`); currentPath = currentPath.parentPath; depth++; } } } });

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/moikas-code/moidvk'

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