Skip to content

chore: update Dockerfile and CI configuration for Node 20, enhance pa…#112

Open
agoldis wants to merge 6 commits intomainfrom
feat/esm-cjs-imports
Open

chore: update Dockerfile and CI configuration for Node 20, enhance pa…#112
agoldis wants to merge 6 commits intomainfrom
feat/esm-cjs-imports

Conversation

@agoldis
Copy link
Copy Markdown
Contributor

@agoldis agoldis commented Mar 25, 2026

…ckage structure

  • Updated Dockerfile to use Node 20 for both build and runtime stages.
  • Modified GitHub Actions workflow to support testing across Node versions 20.x, 22.x, and 24.x.
  • Enhanced package.json to include new module exports and updated dependencies.
  • Introduced tsconfig.cjs.json for CommonJS builds and adjusted TypeScript configurations.
  • Added new scripts for CJS package JSON generation and updated test scripts for improved coverage.
  • Refactored source code structure, including the introduction of an API entry point and integration tests for ESM and CJS compatibility.

Summary by cubic

Move to a dual ESM/CJS build with a clean programmatic API, keep the CLI stdio entrypoint, and adopt Node 20 across Docker and CI. Adds clear failure handling when CURRENTS_API_KEY is missing.

  • New Features

    • Ship dual ESM/CJS builds with an exports map and a new startMcpServer entry point; CLI stdio stays in src/index.ts, server/tool registration moves to src/server.ts; src/api.ts exposes programmatic exports; tools now use direct zod schemas.
    • Integration tests for ESM import, CJS require and dynamic import, CLI bin/npx via npm pack, and published tarball resolution via import "@currents/mcp"; tests build first, increase CLI test timeout, and mock CURRENTS_API_KEY for startup.
    • Error handling: throw on missing CURRENTS_API_KEY (MISSING_CURRENTS_API_KEY_MESSAGE); CLI logs a short guidance message without a stack trace.
    • Platform/deps: Docker and CI on Node 20; CI matrix 20.x/22.x/24.x; upgrade @modelcontextprotocol/sdk to ^1.28.0.
  • Migration

    • Requires Node >=20 (engines updated).
    • Programmatic usage:
      • ESM: import { startMcpServer } from @currents/mcp
      • CJS: const { startMcpServer } = require(@currents/mcp) or import(@currents/mcp)

Written for commit da86eed. Summary will update on new commits.

agoldis added 2 commits March 25, 2026 11:41
…ckage structure

- Updated Dockerfile to use Node 20 for both build and runtime stages.
- Modified GitHub Actions workflow to support testing across Node versions 20.x, 22.x, and 24.x.
- Enhanced package.json to include new module exports and updated dependencies.
- Introduced tsconfig.cjs.json for CommonJS builds and adjusted TypeScript configurations.
- Added new scripts for CJS package JSON generation and updated test scripts for improved coverage.
- Refactored source code structure, including the introduction of an API entry point and integration tests for ESM and CJS compatibility.
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 14 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="mcp-server/src/server.ts">

<violation number="1" location="mcp-server/src/server.ts:44">
P2: Fail fast when the API key is missing; logging and continuing starts a server that can’t successfully call the Currents API.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

agoldis added 4 commits March 25, 2026 12:14
- Updated integration test to always run for package consumers, removing the dual build check.
- Reformatted action descriptions in the server registration to improve readability and maintain consistency across tools.
…ion test timeout

- Changed action tools to directly use the zodSchema instead of its shape for schema definition.
- Enhanced the integration test timeout for the packaged CLI to ensure reliability during execution.
…SM test

- Updated the GitHub Actions workflow to clarify test coverage for workspace ESM/CJS and added a new test for npm pack and import behavior.
- Introduced new integration tests for packaged CLI functionality, ensuring proper execution of the `bin` field and `npx` behavior.
- Added a test for resolving the package name `@currents/mcp` using `package.json` exports after installation from a tarball.
- Included a fixture to validate the ESM entry point and its functionality in a consumer project context.
…ntegration tests

- Enhanced error logging in the main entry point to provide clearer guidance when the CURRENTS_API_KEY is not set.
- Updated the server startup logic to throw an error if the CURRENTS_API_KEY is missing, improving robustness.
- Added a default value for CURRENTS_API_KEY in the environment module to prevent empty strings.
- Modified integration tests to include a mock environment variable for CURRENTS_API_KEY, ensuring proper test execution.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant