|
| 1 | +# Contributing to Asgardeo MCP Node.js SDKs |
| 2 | + |
| 3 | +This guide walks you through setting up the development environment and other important information for contributing to Asgardeo MCP Node.js SDKs. |
| 4 | + |
| 5 | +We welcome contributions of all kinds, from bug fixes and documentation improvements to new features. |
| 6 | + |
| 7 | +## Table of Contents |
| 8 | + |
| 9 | +- [Prerequisite Software](#prerequisite-software) |
| 10 | +- [Development Tools](#development-tools) |
| 11 | +- [Setting up the Source Code](#setting-up-the-source-code) |
| 12 | +- [Setting up the Development Environment](#setting-up-the-development-environment) |
| 13 | +- [Project Structure](#project-structure) |
| 14 | +- [Development Workflow](#development-workflow) |
| 15 | + - [Branching Strategy](#branching-strategy) |
| 16 | + - [Making Changes](#making-changes) |
| 17 | + - [Building Packages](#building-packages) |
| 18 | + - [Linting Code](#linting-code) |
| 19 | + - [Running Tests](#running-tests) |
| 20 | +- [Commit Message Guidelines](#commit-message-guidelines) |
| 21 | + - [Commit Message Header](#commit-message-header) |
| 22 | + - [Type](#type) |
| 23 | + - [Scope](#scope) |
| 24 | + - [Summary](#summary) |
| 25 | + - [Commit Message Body](#commit-message-body) |
| 26 | + - [Commit Message Footer](#commit-message-footer) |
| 27 | + - [Revert Commits](#revert-commits) |
| 28 | +- [Submitting Changes (Pull Request Process)](#submitting-changes-pull-request-process) |
| 29 | +- [Reporting Bugs](#reporting-bugs) |
| 30 | + - [Security Vulnerabilities](#security-vulnerabilities) |
| 31 | +- [Suggesting Enhancements](#suggesting-enhancements) |
| 32 | +- [License](#license) |
| 33 | + |
| 34 | +## Prerequisite Software |
| 35 | + |
| 36 | +To build and write code, make sure you have the following set of tools on your local environment: |
| 37 | + |
| 38 | +* [Git](https://git-scm.com/downloads) - Open source distributed version control system. |
| 39 | +* [Node.js](https://nodejs.org/en/download/) - JavaScript runtime. (`v16.x or higher`) |
| 40 | +* [pnpm](https://pnpm.io/) - Alternate npm client for faster package installs. (`v8.x or higher`) |
| 41 | + |
| 42 | +## Development Tools |
| 43 | + |
| 44 | +While not required, the following tools are recommended for a better development experience: |
| 45 | + |
| 46 | +### ESLint Plugin |
| 47 | + |
| 48 | +Static code analysis tool for identifying problematic patterns found in JavaScript/TypeScript code. |
| 49 | + |
| 50 | +- [Install for VS Code](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint) |
| 51 | +- [Install for VS Web Storm](https://www.jetbrains.com/help/webstorm/eslint.html) |
| 52 | + |
| 53 | +### Code Spell Checker |
| 54 | + |
| 55 | +A basic spell checker that works well with code and documents. |
| 56 | + |
| 57 | +- [Install for VS Code](https://marketplace.visualstudio.com/items?itemName=streetsidesoftware.code-spell-checker) |
| 58 | + |
| 59 | +### JSON Sort Order |
| 60 | + |
| 61 | +Sorts JSON objects in alphabetical order. |
| 62 | + |
| 63 | +- [Install for VS Code](https://marketplace.visualstudio.com/items?itemName=msyesyan.json-sorter) |
| 64 | + |
| 65 | +## Setting up the Source Code |
| 66 | + |
| 67 | +1. [Fork](https://docs.github.com/en/github/getting-started-with-github/fork-a-repo) the repository. |
| 68 | +2. Clone your fork to the local machine. |
| 69 | + |
| 70 | +Replace `<github username>` with your own username. |
| 71 | + |
| 72 | +```shell |
| 73 | +git clone https://github.com/<github username>/asgardeo-mcp-node.git |
| 74 | +``` |
| 75 | + |
| 76 | +3. Set the original repo as the upstream remote. |
| 77 | + |
| 78 | +```shell |
| 79 | +git remote add upstream https://github.com/brionmario/asgardeo-mcp-node.git |
| 80 | +``` |
| 81 | + |
| 82 | +## Setting up the Development Environment |
| 83 | + |
| 84 | +1. Install dependencies. |
| 85 | + |
| 86 | +```bash |
| 87 | +pnpm install |
| 88 | +``` |
| 89 | + |
| 90 | +2. Build the project. |
| 91 | + |
| 92 | +```bash |
| 93 | +pnpm build |
| 94 | +``` |
| 95 | + |
| 96 | +## Project Structure |
| 97 | + |
| 98 | +The asgardeo-mcp-node repository is a monorepo containing the following key packages located in the `packages/` directory: |
| 99 | + |
| 100 | +- `packages/mcp-node` (`@brionmario-experimental/mcp-node`): Core Node.js utilities for MCP. |
| 101 | +- `packages/mcp-express` (`@brionmario-experimental/mcp-express`): Express middleware for MCP, likely dependent on mcp-node. |
| 102 | + |
| 103 | +Shared configurations (like ESLint, Prettier, TypeScript) are typically managed at the root level. |
| 104 | + |
| 105 | +## Development Workflow |
| 106 | + |
| 107 | +### Branching Strategy |
| 108 | + |
| 109 | +- **main**: This branch contains the latest stable release. Direct pushes to main are restricted. |
| 110 | +- **Feature Branches**: Create new branches from main for new features (e.g., `feat/your-feature-name`). |
| 111 | +- **Bugfix Branches**: Create new branches from main for bug fixes (e.g., `fix/issue-number-description`). |
| 112 | + |
| 113 | +### Making Changes |
| 114 | + |
| 115 | +1. Ensure your local `main` branch is up-to-date with the upstream repository. |
| 116 | +2. Create a new branch from `main` for your changes. |
| 117 | +3. Make your code changes in the relevant package(s) within the `packages/` directory. |
| 118 | +4. Add or update tests as appropriate. |
| 119 | +5. Ensure all tests and linting checks pass. |
| 120 | + |
| 121 | +### Building Packages |
| 122 | + |
| 123 | +You can build all packages or a specific package: |
| 124 | + |
| 125 | +**Build all packages:** |
| 126 | +```bash |
| 127 | +pnpm run build |
| 128 | +# or if you have a specific script for all packages |
| 129 | +# pnpm run build:all |
| 130 | +``` |
| 131 | + |
| 132 | +**Build a specific package:** |
| 133 | +Use the `--filter` flag with pnpm. Replace `<package-name>` with the actual package name (e.g., `@brionmario-experimental/mcp-express`). |
| 134 | + |
| 135 | +```bash |
| 136 | +pnpm --filter <package-name> run build |
| 137 | + |
| 138 | +# Example for mcp-express: |
| 139 | +pnpm --filter @brionmario-experimental/mcp-express run build |
| 140 | +``` |
| 141 | + |
| 142 | +### Linting Code |
| 143 | + |
| 144 | +Ensure your code adheres to the project's linting standards: |
| 145 | + |
| 146 | +**Lint all packages:** |
| 147 | +```bash |
| 148 | +pnpm run lint |
| 149 | +# or |
| 150 | +# pnpm run lint:all |
| 151 | +``` |
| 152 | + |
| 153 | +**Lint a specific package:** |
| 154 | +```bash |
| 155 | +pnpm --filter <package-name> run lint |
| 156 | + |
| 157 | +# Example for mcp-node: |
| 158 | +pnpm --filter @brionmario-experimental/mcp-node run lint |
| 159 | +``` |
| 160 | + |
| 161 | +You can also run lint fix scripts if available (e.g., `pnpm run lint:fix`). |
| 162 | + |
| 163 | +### Running Tests |
| 164 | + |
| 165 | +Ensure all existing tests pass and add new tests for your changes: |
| 166 | + |
| 167 | +**Test all packages:** |
| 168 | +```bash |
| 169 | +pnpm run test |
| 170 | +# or |
| 171 | +# pnpm run test:all |
| 172 | +``` |
| 173 | + |
| 174 | +**Test a specific package:** |
| 175 | +```bash |
| 176 | +pnpm --filter <package-name> run test |
| 177 | + |
| 178 | +# Example for mcp-express: |
| 179 | +pnpm --filter @brionmario-experimental/mcp-express run test |
| 180 | +``` |
| 181 | + |
| 182 | +## Commit Message Guidelines |
| 183 | + |
| 184 | +*This specification is inspired by and supersedes the [AngularJS commit message format][commit-message-format].* |
| 185 | + |
| 186 | +We have very precise rules over how our Git commit messages must be formatted. |
| 187 | +This format leads to **easier to read commit history**. |
| 188 | + |
| 189 | +Each commit message consists of a **header**, a **body**, and a **footer**. |
| 190 | + |
| 191 | +``` |
| 192 | +<header> |
| 193 | +<BLANK LINE> |
| 194 | +<body> |
| 195 | +<BLANK LINE> |
| 196 | +<footer> |
| 197 | +``` |
| 198 | + |
| 199 | +The `header` is mandatory and must conform to the [Commit Message Header](#commit-message-header) format. |
| 200 | + |
| 201 | +The `body` is mandatory for all commits except for those of type "docs". |
| 202 | +When the body is present it must be at least 20 characters long and must conform to the [Commit Message Body](#commit-message-body) format. |
| 203 | + |
| 204 | +The `footer` is optional. The [Commit Message Footer](#commit-message-footer) format describes what the footer is used for and the structure it must have. |
| 205 | + |
| 206 | +### Commit Message Header |
| 207 | + |
| 208 | +``` |
| 209 | +<type>(<scope>): <short summary> |
| 210 | + │ │ │ |
| 211 | + │ │ └─⫸ Summary in present tense. Not capitalized. No period at the end. |
| 212 | + │ │ |
| 213 | + │ └─⫸ Commit Scope: mcp-node|mcp-express |
| 214 | + │ |
| 215 | + └─⫸ Commit Type: build|ci|docs|feat|fix|perf|refactor|chore|test |
| 216 | +``` |
| 217 | + |
| 218 | +The `<type>` and `<summary>` fields are mandatory, the `(<scope>)` field is optional. |
| 219 | + |
| 220 | +#### Type |
| 221 | + |
| 222 | +Must be one of the following: |
| 223 | + |
| 224 | +* **build**: Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm) |
| 225 | +* **ci**: Changes to our CI configuration files and scripts (examples: CircleCi, SauceLabs) |
| 226 | +* **docs**: Documentation only changes |
| 227 | +* **feat**: A new feature |
| 228 | +* **fix**: A bug fix |
| 229 | +* **perf**: A code change that improves performance |
| 230 | +* **refactor**: A code change that neither fixes a bug nor adds a feature |
| 231 | +* **chore**: Housekeeping tasks that doesn't require to be highlighted in the changelog |
| 232 | +* **test**: Adding missing tests or correcting existing tests |
| 233 | + |
| 234 | +#### Scope |
| 235 | + |
| 236 | +The scope should be the name of the npm package affected (as perceived by the person reading the changelog generated from commit messages). |
| 237 | + |
| 238 | +The following is the list of supported scopes: |
| 239 | + |
| 240 | +* `mcp-node` - Changes to the `@brionmario-experimental/mcp-node` package. |
| 241 | +* `mcp-express` - Changes to the `@brionmario-experimental/mcp-express` package. |
| 242 | +* `workspace` - Changes to the workspace. |
| 243 | +* `sample-app` - Changes to the sample app. |
| 244 | + |
| 245 | +There are currently a few exceptions to the "use package name" rule: |
| 246 | + |
| 247 | +* `packaging`: used for changes that change the npm package layout in all of our packages, e.g. public path changes, package.json changes done to all packages, d.ts file/format changes, changes to bundles, etc. |
| 248 | +* `changelog`: used for updating the release notes in CHANGELOG.md |
| 249 | +* `dev-infra`: used for dev-infra related changes within the directories like /scripts. |
| 250 | +* `docs-infra`: used for docs page changes. |
| 251 | +* none/empty string: useful for `test` and `refactor` changes that are done across all packages (e.g. `test: add missing unit tests`) and for docs changes that are not related to a specific package (e.g. `docs: fix typo in example`). |
| 252 | + |
| 253 | +#### Summary |
| 254 | + |
| 255 | +Use the summary field to provide a succinct description of the change: |
| 256 | + |
| 257 | +* Use the imperative, present tense: "change" not "changed" nor "changes". |
| 258 | +* Don't capitalize the first letter. |
| 259 | +* No dot (.) at the end. |
| 260 | + |
| 261 | +### Commit Message Body |
| 262 | + |
| 263 | +Just as in the summary, use the imperative, present tense: "fix" not "fixed" nor "fixes". |
| 264 | + |
| 265 | +Explain the motivation for the change in the commit message body. This commit message should explain _why_ you are making the change. |
| 266 | +You can include a comparison of the previous behavior with the new behavior in order to illustrate the impact of the change. |
| 267 | + |
| 268 | +### Commit Message Footer |
| 269 | + |
| 270 | +The footer can contain information about breaking changes and deprecations and is also the place to reference GitHub issues, Jira tickets, and other PRs that this commit closes or is related to. |
| 271 | +For example: |
| 272 | + |
| 273 | +``` |
| 274 | +BREAKING CHANGE: <breaking change summary> |
| 275 | +<BLANK LINE> |
| 276 | +<breaking change description + migration instructions> |
| 277 | +<BLANK LINE> |
| 278 | +<BLANK LINE> |
| 279 | +Fixes #<issue number> |
| 280 | +``` |
| 281 | + |
| 282 | +or |
| 283 | + |
| 284 | +``` |
| 285 | +DEPRECATED: <what is deprecated> |
| 286 | +<BLANK LINE> |
| 287 | +<deprecation description + recommended update path> |
| 288 | +<BLANK LINE> |
| 289 | +<BLANK LINE> |
| 290 | +Closes #<pr number> |
| 291 | +``` |
| 292 | + |
| 293 | +Breaking Change section should start with the phrase "BREAKING CHANGE: " followed by a summary of the breaking change, a blank line, and a detailed description of the breaking change that also includes migration instructions. |
| 294 | + |
| 295 | +Similarly, a Deprecation section should start with "DEPRECATED: " followed by a short description of what is deprecated, a blank line, and a detailed description of the deprecation that also mentions the recommended update path. |
| 296 | + |
| 297 | +### Revert Commits |
| 298 | + |
| 299 | +If the commit reverts a previous commit, it should begin with `revert: `, followed by the header of the reverted commit. |
| 300 | + |
| 301 | +The content of the commit message body should contain: |
| 302 | + |
| 303 | +- Information about the SHA of the commit being reverted in the following format: `This reverts commit <SHA>`. |
| 304 | +- A clear description of the reason for reverting the commit message. |
| 305 | + |
| 306 | +## Submitting Changes (Pull Request Process) |
| 307 | + |
| 308 | +1. Ensure all development steps (building, linting, testing) are complete and passing. |
| 309 | +2. Commit your changes using the Conventional Commits format. |
| 310 | +3. Push your feature/bugfix branch to your forked repository on GitHub: |
| 311 | + ```bash |
| 312 | + git push origin feat/your-feature-name |
| 313 | + ``` |
| 314 | +4. Go to the original `brionmario/asgardeo-mcp-node` repository on GitHub and open a new Pull Request from your forked branch to the `main` branch of the upstream repository. |
| 315 | +5. Provide a clear title and a detailed description for your Pull Request: |
| 316 | + - Explain the "why" and "what" of your changes. |
| 317 | + - Reference any related GitHub issues (e.g., "Closes #123"). |
| 318 | + - Include steps for testing if applicable. |
| 319 | +6. Your Pull Request will be reviewed by maintainers. Be prepared to discuss your changes and make adjustments based on feedback. |
| 320 | +7. Once approved and all checks pass, your PR will be merged. |
| 321 | + |
| 322 | +## Reporting Bugs |
| 323 | + |
| 324 | +If you encounter a bug, please help us by reporting it! |
| 325 | + |
| 326 | +1. **Search existing issues**: Before creating a new issue, please check if the bug has already been reported on the GitHub Issues page. |
| 327 | +2. **Create a new issue**: If it's a new bug, please provide a detailed report including: |
| 328 | + - A clear and descriptive title. |
| 329 | + - Steps to reproduce the bug. |
| 330 | + - What you expected to happen. |
| 331 | + - What actually happened (including any error messages or stack traces). |
| 332 | + - Your environment (Node.js version, package versions, OS, etc.). |
| 333 | + |
| 334 | +### Security Vulnerabilities |
| 335 | + |
| 336 | +Do not report security vulnerabilities through public GitHub issues. |
| 337 | +Please report security vulnerabilities directly to security@wso2.com. We strongly advise following the WSO2 Security Vulnerability Reporting Guidelines. |
| 338 | + |
| 339 | +## Suggesting Enhancements |
| 340 | + |
| 341 | +We welcome suggestions for new features or improvements! |
| 342 | + |
| 343 | +1. **Search existing issues/discussions**: Check if your idea has already been discussed. |
| 344 | +2. **Create a new issue**: Provide a clear description of the proposed enhancement, why it would be beneficial, and any potential implementation details. |
| 345 | + |
| 346 | +## License |
| 347 | + |
| 348 | +By contributing to this project, you agree that your contributions will be licensed under the same license as the project itself. |
| 349 | + |
| 350 | +[commit-message-format]: https://docs.google.com/document/d/1QrDFcIiPjSLDn3EL15IJygNPiHORgU1_OOAqWjiDU5Y/edit |
0 commit comments