Skip to content

Latest commit

 

History

History
165 lines (126 loc) · 3.38 KB

File metadata and controls

165 lines (126 loc) · 3.38 KB

Contributing to D-Tools MCP Server

Thank you for your interest in contributing! This document provides guidelines and instructions for contributing to this project.

Development Setup

Prerequisites

  • Node.js ≥ 18
  • npm ≥ 9
  • Git

Getting Started

  1. Fork and clone the repository:

    git clone https://github.com/Saml1211/D-Tools-MCP-Server.git
    cd D-Tools-MCP-Server
  2. Install dependencies:

    npm install
  3. Create a .env file:

    cp .env.example .env
    # Edit .env with your D-Tools API credentials
  4. Run tests:

    npm test
  5. Build the project:

    npm run build

Development Workflow

Making Changes

  1. Create a feature branch:

    git checkout -b feature/my-new-feature
  2. Make your changes with appropriate tests

  3. Ensure all tests pass:

    npm test
    npm run build
  4. Run linting:

    npm run lint
  5. Format code:

    npm run format

Testing Guidelines

  • Write tests for all new functionality
  • Maintain or improve code coverage
  • Tests should be in src/__tests__/ directory
  • Name test files with .test.ts suffix

Example test structure:

import { describe, it, expect } from 'vitest';
import { myFunction } from '../lib/my-module.js';

describe('My Module', () => {
  it('should do something', () => {
    const result = myFunction('input');
    expect(result).toBe('expected output');
  });
});

Code Style

  • Use TypeScript strict mode
  • Follow existing code patterns
  • Add JSDoc comments for public APIs
  • Use meaningful variable names
  • Keep functions small and focused

Commit Messages

Follow conventional commits format:

  • feat: New feature
  • fix: Bug fix
  • docs: Documentation changes
  • test: Test changes
  • refactor: Code refactoring
  • chore: Build/tooling changes

Example:

feat: add project archiving tool

- Add archive_project tool to projects.ts
- Add tests for archive functionality
- Update README with new tool documentation

Adding New Tools

To add a new MCP tool:

  1. Identify the appropriate tool file in src/tools/

  2. Add the tool using server.tool() — pass a raw-shape object (not z.object()):

    server.tool(
      'my_tool_name',
      'One-sentence description shown to LLM clients.',
      { id: z.string().min(1) },         // raw shape, not z.object({...})
      // @ts-ignore -- SDK v1.27 + TS 5.9 overload resolution; runtime is correct
      async ({ id }) => {
        try {
          const result = await client.myApiMethod(id);
          return {
            content: [{ type: 'text', text: JSON.stringify(result) }],
          };
        } catch (err: any) {
          logger.error({ err }, 'Tool execution failed');
          return {
            content: [{ type: 'text', text: `Error: ${err.message || String(err)}` }],
          };
        }
      }
    );
  3. Add tests in src/__tests__/

  4. Update README.md documentation

  5. Update CHANGELOG.md

Reporting Issues

When reporting issues, please include:

  • Node.js version
  • npm version
  • Error message or stack trace
  • Steps to reproduce
  • Expected vs actual behavior

Security Issues

For security vulnerabilities, please email directly rather than opening a public issue.

License

By contributing, you agree that your contributions will be licensed under the MIT License.