Skip to content
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .cursor/mcp.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"command": "node",
"args": [
"./packages/angular-mcp/dist/main.js",
"--workspaceRoot=/home/spoltorak/projects/x-mcp",
"--workspaceRoot=/Users/kyrylokarnaukhov/Documents/projects/angular-mcp-toolkit",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets avoid using local paths in the source

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Local MCP is not tracked anymore, example file available

"--ds.storybookDocsRoot=packages/minimal-repo/packages/design-system/storybook-host-app/src/components",
"--ds.deprecatedCssClassesPath=packages/minimal-repo/packages/design-system/component-options.js",
"--ds.uiRoot=packages/minimal-repo/packages/design-system/ui"
Expand Down
1 change: 0 additions & 1 deletion CONTRIBUTING.MD
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ This is an Nx monorepo with the following structure:
│ ├── minimal-repo/ # Test fixtures and examples
│ └── shared/ # Shared libraries
│ ├── angular-ast-utils/ # Angular AST parsing
│ ├── angular-cli-utils/ # Angular CLI utilities
│ ├── ds-component-coverage/ # Design system analysis
│ ├── models/ # Core types and schemas
│ ├── styles-ast-utils/ # CSS/SCSS AST parsing
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ A Model Context Protocol (MCP) server that provides Angular project analysis and

### Prerequisites

- Node.js (version 18 or higher)
- Node.js (version 18 or higher) with ESM support

### Installation & Setup

Expand Down Expand Up @@ -96,6 +96,7 @@ const dsComponents = [
}
];

// Note: Use CommonJS export for configuration files
module.exports = dsComponents;
```

Expand Down
3 changes: 1 addition & 2 deletions docs/architecture-internal-design.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ packages/angular-mcp-server/
| **Prompt** | `prompts/prompt-registry.ts` | 1. Append schema to `PROMPTS`. <br>2. Provide implementation in `PROMPTS_IMPL`. |
| **Resource Provider** | `registerResources()` | Extend logic to aggregate custom docs or design-system assets. |

All tools share the `ToolsConfig` interface (`@push-based/models`) that bundles:
All tools share the `ToolsConfig` interface (`@code-pushup/models`) that bundles:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would not tia everything to CP.. The reason we have out own models and utils is to decouple a bit

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All tools are sharing @push-based/models ToolsConfig. Import name fixed.

- `schema` (name, description, arguments, return type)
- `handler(request)` async function.

Expand All @@ -110,7 +110,6 @@ Validation is handled via **Zod** in `angular-mcp-server-options.schema.ts`.
models (types & schemas)
├─ utils
├─ styles-ast-utils
├─ angular-cli-utils
└─ angular-ast-utils
└─ ds-component-coverage (top-level plugin)
```
Expand Down
2 changes: 1 addition & 1 deletion docs/writing-custom-tools.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ File name **must** end with `.tool.ts` so tests & registries can auto-discover i

```ts
import { z } from 'zod';
import { ToolSchemaOptions, ToolsConfig } from '@push-based/models';
import { ToolSchemaOptions, ToolsConfig } from '@code-pushup/models';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This definitely should be '@push-based/models';

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, fixed

import { createHandler, RESULT_FORMATTERS } from '../shared/utils/handler-helpers.js';

// 1️⃣ Schema
Expand Down
3 changes: 0 additions & 3 deletions jest.preset.js

This file was deleted.

3 changes: 3 additions & 0 deletions jest.preset.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import nxPreset from '@nx/jest/preset';

export default { ...nxPreset };
98 changes: 54 additions & 44 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "@push-based/source",
"version": "0.0.0",
"type": "module",
"license": "MIT",
"scripts": {},
"private": true,
Expand Down Expand Up @@ -61,12 +62,11 @@
"@angular-devkit/schematics": "~19.2.0",
"@angular/cli": "~19.2.0",
"@angular/compiler": "~19.2.0",
"@code-pushup/core": "^0.69.0",
"@code-pushup/eslint-plugin": "^0.69.0",
"@code-pushup/models": "^0.69.0",
"@code-pushup/utils": "^0.69.0",
"@code-pushup/core": "^0.75.0",
"@code-pushup/eslint-plugin": "^0.75.0",
"@code-pushup/models": "^0.75.0",
"@code-pushup/utils": "^0.75.0",
"@modelcontextprotocol/sdk": "^1.12.1",
"@push-based/angular-cli-utils": "^0.0.1",
"@push-based/ds-component-coverage": "^0.0.1",
"@push-based/models": "^0.0.1",
"@push-based/utils": "^0.0.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/angular-mcp-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@push-based/angular-mcp-server",
"version": "0.0.1",
"private": true,
"type": "commonjs",
"type": "module",
"main": "./dist/index.js",
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/angular-mcp-server/src/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from './lib/angular-mcp-server';
export * from './lib/angular-mcp-server.js';
10 changes: 5 additions & 5 deletions packages/angular-mcp-server/src/lib/angular-mcp-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@ import {
ListResourcesResult,
ListToolsRequestSchema,
} from '@modelcontextprotocol/sdk/types.js';
import { TOOLS } from './tools/tools';
import { toolNotFound } from './tools/utils';
import { TOOLS } from './tools/tools.js';
import { toolNotFound } from './tools/utils.js';
import * as fs from 'node:fs';
import * as path from 'node:path';
import {
AngularMcpServerOptionsSchema,
AngularMcpServerOptions,
} from './validation/angular-mcp-server-options.schema';
import { validateAngularMcpServerFilesExist } from './validation/file-existence';
import { validateDeprecatedCssClassesFile } from './validation/ds-components-file.validation';
} from './validation/angular-mcp-server-options.schema.js';
import { validateAngularMcpServerFilesExist } from './validation/file-existence.js';
import { validateDeprecatedCssClassesFile } from './validation/ds-components-file.validation.js';

export class AngularMcpServerWrapper {
private readonly mcpServer: McpServer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ToolSchemaOptions } from '@push-based/models';
import {
COMMON_ANNOTATIONS,
createProjectAnalysisSchema,
} from '../../../shared';
} from '../../../shared/index.js';

/**
* Schema for building component contracts
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ToolSchemaOptions } from '@push-based/models';
import {
createProjectAnalysisSchema,
COMMON_ANNOTATIONS,
} from '../../../shared';
} from '../../../shared/index.js';

/**
* Schema for diffing component contracts
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SourceFileLocation } from '@push-based/models';
import { SourceFileLocation } from '@code-pushup/models';

export interface DependencyInfo {
path: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as path from 'path';
import { toUnixPath } from '@push-based/utils';
import { buildText } from '../../shared/utils/output.utils';
import { toUnixPath } from '@code-pushup/utils';
import { buildText } from '../../shared/utils/output.utils.js';
import { CallToolResult } from '@modelcontextprotocol/sdk/types.js';
import {
DependencyGraphResult,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as path from 'path';
import { toUnixPath, findAllFiles } from '@push-based/utils';
import { toUnixPath } from '@code-pushup/utils';
import { findAllFiles } from '@push-based/utils';
import {
BuildComponentUsageGraphOptions,
ComponentUsageGraphResult,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as fs from 'fs';
import * as path from 'path';
import { toUnixPath } from '@push-based/utils';
import { toUnixPath } from '@code-pushup/utils';
import { DEPENDENCY_ANALYSIS_CONFIG } from '../models/config.js';

const { resolveExtensions, indexFiles } = DEPENDENCY_ANALYSIS_CONFIG;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as fs from 'fs';
import * as path from 'path';
import * as ts from 'typescript';
import { toUnixPath } from '@push-based/utils';
import { toUnixPath } from '@code-pushup/utils';

import {
DependencyInfo,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const getDeprecatedCssClassesHandler = createHandler<
>(
getDeprecatedCssClassesSchema.name,
async ({ componentName }, { cwd, deprecatedCssClassesPath }) => {
return getDeprecatedCssClasses(
return await getDeprecatedCssClasses(
componentName,
deprecatedCssClassesPath,
cwd,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ export interface DeprecatedCssComponent {
* @returns Array of deprecated CSS classes for the component
* @throws Error if file not found, invalid format, or component not found
*/
export function getDeprecatedCssClasses(
export async function getDeprecatedCssClasses(
componentName: string,
deprecatedCssClassesPath: string,
cwd: string,
): string[] {
): Promise<string[]> {
if (
!deprecatedCssClassesPath ||
typeof deprecatedCssClassesPath !== 'string'
Expand All @@ -31,11 +31,10 @@ export function getDeprecatedCssClasses(
throw new Error(`File not found at deprecatedCssClassesPath: ${absPath}`);
}

const module = require(absPath);
const module = await import(absPath);

// Handle both ES modules (export default) and CommonJS (module.exports)
// Support: export default dsComponents, module.exports = { dsComponents }, or direct module.exports = dsComponents
const dsComponents = module.default || module.dsComponents || module;
// Pure ESM: use export default
const dsComponents = module.default;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems quickly added instead of thought through

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Open for suggestion, only thing that was not breaking tools.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If its needed to make it work, we could think of some reusable thing or docs on the WHY.
The case module.default || module; e.g. ise repeated module.dsComponents not.

It will help to establish a pattern that others can follow more easily.

Copy link
Member Author

@Karnaukhov-kh Karnaukhov-kh Aug 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Created a helper function in utils. Updated docs. see 720d27f & 775be79


if (!Array.isArray(dsComponents)) {
throw new Error('Invalid export: expected dsComponents to be an array');
Expand Down
Loading