npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@zrald/function-logic-mcp-server

v1.0.0

Published

Advanced Function Logic Analysis MCP Server - Identifies and analyzes function logic patterns in code, integrates with zrald1 for comprehensive code intelligence

Readme

Zrald2 - Function Logic Analysis MCP Server

Advanced Function Logic Analysis MCP Server that identifies and analyzes function logic patterns related to user files and requests. Integrates with zrald1 MCP server for comprehensive code analysis.

🎯 Purpose

Zrald2 is designed to:

  • Identify Functions: Detect and analyze functions in user code files
  • Logic Pattern Analysis: Identify complex logic patterns (conditionals, loops, recursion, etc.)
  • Context-Aware Analysis: Analyze functions in the context of user requests
  • Integration with Zrald1: Requires and integrates with zrald1 MCP server for file data
  • Comprehensive Summaries: Generate detailed summaries of function logic and patterns

🚀 Features

Core Capabilities

  • Function Detection: Parse and identify functions across multiple programming languages
  • Logic Pattern Recognition: Detect conditional logic, loops, recursion, callbacks, promises, error handling
  • Complexity Analysis: Calculate cyclomatic and cognitive complexity metrics
  • Relationship Mapping: Identify relationships between functions (calls, dependencies, similarities)
  • Context Analysis: Analyze user requests to focus on relevant functions
  • Summary Generation: Create comprehensive, technical-level-appropriate summaries

Integration Features

  • Zrald1 Dependency: Automatically fetches file data from zrald1 MCP server
  • Graph Data Integration: Uses zrald1's graph processing capabilities
  • Content Search Integration: Leverages zrald1's vector search for relevant content
  • Relationship Analysis: Combines with zrald1's file relationship data

📦 Installation

npm install zrald2

🔧 Usage

As a standalone MCP server

npx zrald2

As a library

import { FunctionLogicMCPServer } from 'zrald2';

const server = new FunctionLogicMCPServer();
await server.start();

🛠 Available Tools

1. analyze_functions

Analyze functions in user files and identify logic patterns

Parameters:

  • user_request (required): Description of what to analyze
  • focus_areas (optional): Specific function names or areas to focus on
  • technical_level (optional): 'beginner', 'intermediate', or 'advanced'
  • include_code_examples (optional): Whether to include code examples

Example:

{
  "user_request": "Analyze the authentication functions for security issues",
  "focus_areas": ["login", "authenticate", "validateToken"],
  "technical_level": "advanced",
  "include_code_examples": true
}

2. detect_logic_patterns

Detect specific logic patterns in previously analyzed functions

Parameters:

  • pattern_types (optional): Array of pattern types to detect
  • complexity_threshold (optional): Minimum complexity threshold

Example:

{
  "pattern_types": ["conditional", "loop", "error-handling"],
  "complexity_threshold": 2
}

3. generate_function_summary

Generate a comprehensive summary of function analysis

Parameters:

  • summary_type (optional): 'brief', 'detailed', or 'technical'
  • include_recommendations (optional): Whether to include recommendations

4. analyze_request_context

Analyze user request in context of available functions

Parameters:

  • user_request (required): User request to analyze
  • context_keywords (optional): Additional context keywords

5. validate_zrald1_integration

Validate connection and integration with zrald1 MCP server

📊 Analysis Capabilities

Function Analysis

  • Function Detection: Identifies functions, methods, arrow functions, async functions
  • Parameter Analysis: Analyzes function parameters, types, default values
  • Complexity Metrics: Calculates cyclomatic and cognitive complexity
  • Dependency Tracking: Identifies function dependencies and calls

Logic Pattern Detection

  • Conditional Logic: if/else, switch, ternary operators
  • Loops: for, while, forEach, map, filter operations
  • Recursion: Self-calling functions and recursive patterns
  • Callbacks: Callback functions and event handlers
  • Promises: Promise chains, async/await patterns
  • Error Handling: try/catch blocks, error throwing

Relationship Analysis

  • Function Calls: Maps which functions call which other functions
  • Dependencies: Identifies variable and module dependencies
  • Similarities: Finds functions with similar structure or complexity
  • Call Graphs: Builds call relationship graphs

🔗 Zrald1 Integration

Zrald2 requires zrald1 MCP server to be running and accessible. It integrates by:

  1. File Data Retrieval: Gets file information and content from zrald1
  2. Graph Data Access: Uses zrald1's processed graph data
  3. Content Search: Leverages zrald1's vector search capabilities
  4. Relationship Data: Incorporates zrald1's file relationship analysis

Integration Validation

Use the validate_zrald1_integration tool to ensure proper connection:

# This will test the connection and basic functionality
{
  "tool": "validate_zrald1_integration"
}

📈 Output Examples

Function Analysis Output

{
  "success": true,
  "analysis": {
    "functions": [
      {
        "function": {
          "name": "authenticateUser",
          "type": "async",
          "parameters": [{"name": "username", "type": "string"}],
          "complexity": 8,
          "location": {"filePath": "auth.js", "startLine": 15}
        },
        "logicPatterns": [
          {
            "type": "conditional",
            "description": "User validation logic",
            "complexity": 2
          },
          {
            "type": "error-handling",
            "description": "Authentication error handling",
            "complexity": 1
          }
        ],
        "complexity": {
          "cyclomaticComplexity": 8,
          "cognitiveComplexity": 6,
          "linesOfCode": 25
        },
        "summary": "authenticateUser is an async function that takes 1 parameter with moderate complexity containing conditional, error-handling logic patterns and makes 3 function calls."
      }
    ],
    "overallSummary": "Found 1 relevant function with an average complexity of 8.0.",
    "recommendations": [
      "Consider refactoring 1 high-complexity function to improve maintainability"
    ]
  }
}

Summary Output

# 🔍 Function Logic Analysis

**Request:** Analyze authentication functions for security issues

## 📊 Overview
Found 3 authentication-related functions with moderate to high complexity...

## 🔧 Function Details
### 1. authenticateUser
**Type:** async function
**Parameters:** 2
**Summary:** Complex authentication function with error handling...

## 💡 Recommendations
1. Consider refactoring high-complexity functions
2. Add more comprehensive error handling
3. Review recursive functions for potential issues

🏗 Architecture

zrald2/
├── src/
│   ├── core/
│   │   ├── function-analyzer.ts    # Main function analysis logic
│   │   ├── logic-detector.ts       # Logic pattern detection
│   │   ├── zrald1-client.ts       # Integration with zrald1
│   │   └── summary-generator.ts    # Summary generation
│   ├── types/
│   │   ├── function-analysis.ts    # Type definitions
│   │   └── logic-flow.ts          # Logic flow types
│   ├── utils/
│   │   └── ast-parser.ts          # AST parsing utilities
│   ├── mcp-server.ts              # Main MCP server
│   └── index.ts                   # Entry point

🔧 Development

Prerequisites

  • Node.js 18+
  • TypeScript 5+
  • zrald1 MCP server running

Setup

git clone <repository>
cd zrald2
npm install
npm run build

Testing

npm test

Development Mode

npm run dev

📝 License

MIT License - see LICENSE file for details.

🤝 Contributing

Contributions welcome! Please read the contributing guidelines and submit pull requests.

🆘 Support

For issues and questions:

  1. Check that zrald1 MCP server is running
  2. Validate integration using validate_zrald1_integration
  3. Review logs for connection issues
  4. Submit issues on GitHub

Zrald2 - Advanced Function Logic Analysis for AI Agents 🚀