Skip to content

feat: Refactor server to simplify it #14

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 39 commits into from
Mar 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
6a81878
feat: Refactor and simplify mcp server
jirispilka Mar 14, 2025
8d7945a
fix: lint issues
jirispilka Mar 14, 2025
b8e1e2f
fix: add dotenv package to dev
jirispilka Mar 14, 2025
43532a9
feat: Update readme
jirispilka Mar 14, 2025
12a6e32
feat: Update readme
jirispilka Mar 14, 2025
e29d233
feat: Update readme
jirispilka Mar 14, 2025
0d8fce6
feat: ci
jirispilka Mar 14, 2025
bc47864
feat: ci
jirispilka Mar 14, 2025
5be03ba
chore(release): Update changelog and package version [skip ci]
Mar 14, 2025
e4c084e
feat: ci
jirispilka Mar 14, 2025
5a495aa
Merge remote-tracking branch 'origin/feat/refactor' into feat/refactor
jirispilka Mar 14, 2025
f350a86
chore(release): Update changelog and package version [skip ci]
Mar 14, 2025
d0b70d9
ci
jirispilka Mar 14, 2025
d2c5c0c
Merge remote-tracking branch 'origin/feat/refactor' into feat/refactor
jirispilka Mar 14, 2025
bda5cdf
ci unpublish
jirispilka Mar 14, 2025
815c198
fix: unpublish package
jirispilka Mar 14, 2025
4d0b290
chore(release): Update changelog and package version [skip ci]
Mar 14, 2025
f7e9f16
fix: publish package
jirispilka Mar 14, 2025
3f0d348
chore(release): Update changelog and package version [skip ci]
Mar 14, 2025
a283327
fix: unpublish package
jirispilka Mar 14, 2025
b6c6362
Merge remote-tracking branch 'origin/feat/refactor' into feat/refactor
jirispilka Mar 14, 2025
95c654f
chore(release): Update changelog and package version [skip ci]
Mar 14, 2025
0051f23
fix: unpublish package
jirispilka Mar 14, 2025
bc6e8b4
chore(release): Update changelog and package version [skip ci]
Mar 14, 2025
6302f67
fix: unpublish package, again
jirispilka Mar 14, 2025
e3d3a75
chore(release): Update changelog and package version [skip ci]
Mar 14, 2025
18e81b9
fix: unpublish package, again
jirispilka Mar 14, 2025
e2fb85d
Merge remote-tracking branch 'origin/feat/refactor' into feat/refactor
jirispilka Mar 14, 2025
3f402b0
chore(release): Update changelog and package version [skip ci]
Mar 14, 2025
578fe23
fix: publish package
jirispilka Mar 14, 2025
4042362
Merge remote-tracking branch 'origin/feat/refactor' into feat/refactor
jirispilka Mar 14, 2025
8af879f
chore(release): Update changelog and package version [skip ci]
Mar 14, 2025
7e6371c
fix: update package version
jirispilka Mar 14, 2025
25ced36
chore(release): Update changelog and package version [skip ci]
Mar 14, 2025
57031f3
fix: update index.ts
jirispilka Mar 14, 2025
12312b8
chore(release): Update changelog and package version [skip ci]
Mar 14, 2025
475708c
fix: Update README.md and CHANGELOG.md
jirispilka Mar 14, 2025
7ebf0a8
Merge remote-tracking branch 'origin/feat/refactor' into feat/refactor
jirispilka Mar 14, 2025
baa740c
fix: env variable
jirispilka Mar 17, 2025
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
3 changes: 1 addition & 2 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
APIFY_API_TOKEN=
ANTHROPIC_API_KEY=
APIFY_TOKEN=
41 changes: 0 additions & 41 deletions .eslintrc

This file was deleted.

32 changes: 32 additions & 0 deletions .github/scripts/before-beta-release.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
const { execSync } = require('child_process');
const fs = require('fs');
const path = require('path');

const PKG_JSON_PATH = path.join(__dirname, '..', '..', 'package.json');

const pkgJson = require(PKG_JSON_PATH); // eslint-disable-line import/no-dynamic-require

const PACKAGE_NAME = pkgJson.name;
const VERSION = pkgJson.version;

const nextVersion = getNextVersion(VERSION);
console.log(`before-deploy: Setting version to ${nextVersion}`); // eslint-disable-line no-console
pkgJson.version = nextVersion;

fs.writeFileSync(PKG_JSON_PATH, `${JSON.stringify(pkgJson, null, 2)}\n`);

function getNextVersion(version) {
const versionString = execSync(`npm show ${PACKAGE_NAME} versions --json`, { encoding: 'utf8' });
const versions = JSON.parse(versionString);

if (versions.some((v) => v === VERSION)) {
console.error(`before-deploy: A release with version ${VERSION} already exists. Please increment version accordingly.`); // eslint-disable-line no-console
process.exit(1);
}

const prereleaseNumbers = versions
.filter((v) => (v.startsWith(VERSION) && v.includes('-')))
.map((v) => Number(v.match(/\.(\d+)$/)[1]));
const lastPrereleaseNumber = Math.max(-1, ...prereleaseNumbers);
return `${version}-beta.${lastPrereleaseNumber + 1}`;
}
32 changes: 32 additions & 0 deletions .github/workflows/check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# This workflow runs for every pull request to lint and test the proposed changes.

name: Check

on:
pull_request:

# Push to master will trigger code checks
push:
branches:
- master
tags-ignore:
- "**" # Ignore all tags to prevent duplicate builds when tags are pushed.

jobs:
lint_and_test:
name: Lint
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Use Node.js 22
uses: actions/setup-node@v4
with:
node-version: 22
cache: 'npm'
cache-dependency-path: 'package-lock.json'
- name: Install Dependencies
run: npm ci

- name: Lint
run: npm run lint
107 changes: 107 additions & 0 deletions .github/workflows/pre_release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
name: Create a pre-release

on:
# Push to master will deploy a beta version
push:
branches:
- master
tags-ignore:
- "**" # Ignore all tags to prevent duplicate builds when tags are pushed.

concurrency:
group: release
cancel-in-progress: false

jobs:
release_metadata:
if: "!startsWith(github.event.head_commit.message, 'docs') && !startsWith(github.event.head_commit.message, 'ci') && startsWith(github.repository, 'apify/')"
name: Prepare release metadata
runs-on: ubuntu-latest
outputs:
version_number: ${{ steps.release_metadata.outputs.version_number }}
changelog: ${{ steps.release_metadata.outputs.changelog }}
steps:
- uses: apify/workflows/git-cliff-release@main
name: Prepare release metadata
id: release_metadata
with:
release_type: prerelease
existing_changelog_path: CHANGELOG.md

wait_for_checks:
name: Wait for code checks to pass
runs-on: ubuntu-latest
steps:
- uses: lewagon/[email protected]
with:
ref: ${{ github.ref }}
repo-token: ${{ secrets.GITHUB_TOKEN }}
check-regexp: (Build & Test .*|Lint|Docs build)
wait-interval: 5

update_changelog:
needs: [ release_metadata, wait_for_checks ]
name: Update changelog
runs-on: ubuntu-latest
outputs:
changelog_commitish: ${{ steps.commit.outputs.commit_long_sha || github.sha }}

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
token: ${{ secrets.APIFY_SERVICE_ACCOUNT_GITHUB_TOKEN }}

- name: Use Node.js 22
uses: actions/setup-node@v4
with:
node-version: 22

- name: Update package version in package.json
run: npm version --no-git-tag-version --allow-same-version ${{ needs.release_metadata.outputs.version_number }}

- name: Update CHANGELOG.md
uses: DamianReeves/write-file-action@master
with:
path: CHANGELOG.md
write-mode: overwrite
contents: ${{ needs.release_metadata.outputs.changelog }}

- name: Commit changes
id: commit
uses: EndBug/add-and-commit@v9
with:
author_name: Apify Release Bot
author_email: [email protected]
message: "chore(release): Update changelog and package version [skip ci]"

publish_to_npm:
name: Publish to NPM
needs: [ release_metadata, wait_for_checks ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ needs.update_changelog.changelog_commitish }}
- name: Use Node.js 22
uses: actions/setup-node@v4
with:
node-version: 22
cache: 'npm'
cache-dependency-path: 'package-lock.json'
- name: Install dependencies
run: |
echo "access=public" >> .npmrc
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" >> .npmrc
npm ci
- # Check version consistency and increment pre-release version number for beta only.
name: Bump pre-release version
run: node ./.github/scripts/before-beta-release.cjs
- name: Build module
run: npm run build
- name: Publish to NPM
run: npm publish --tag beta

env:
NODE_AUTH_TOKEN: ${{ secrets.APIFY_SERVICE_ACCOUNT_NPM_TOKEN }}
NPM_TOKEN: ${{ secrets.APIFY_SERVICE_ACCOUNT_NPM_TOKEN }}
123 changes: 123 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
name: Create a release

on:
# Trigger a stable version release via GitHub's UI, with the ability to specify the type of release.
workflow_dispatch:
inputs:
release_type:
description: Release type
required: true
type: choice
default: auto
options:
- auto
- custom
- patch
- minor
- major
custom_version:
description: The custom version to bump to (only for "custom" type)
required: false
type: string
default: ""

concurrency:
group: release
cancel-in-progress: false

jobs:
release_metadata:
name: Prepare release metadata
runs-on: ubuntu-latest
outputs:
version_number: ${{ steps.release_metadata.outputs.version_number }}
tag_name: ${{ steps.release_metadata.outputs.tag_name }}
changelog: ${{ steps.release_metadata.outputs.changelog }}
release_notes: ${{ steps.release_metadata.outputs.release_notes }}
steps:
- uses: apify/workflows/git-cliff-release@main
name: Prepare release metadata
id: release_metadata
with:
release_type: ${{ inputs.release_type }}
custom_version: ${{ inputs.custom_version }}
existing_changelog_path: CHANGELOG.md

update_changelog:
needs: [ release_metadata ]
name: Update changelog
runs-on: ubuntu-latest
outputs:
changelog_commitish: ${{ steps.commit.outputs.commit_long_sha || github.sha }}

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
token: ${{ secrets.APIFY_SERVICE_ACCOUNT_GITHUB_TOKEN }}

- name: Use Node.js 22
uses: actions/setup-node@v4
with:
node-version: 22

- name: Update package version in package.json
run: npm version --no-git-tag-version --allow-same-version ${{ needs.release_metadata.outputs.version_number }}

- name: Update CHANGELOG.md
uses: DamianReeves/write-file-action@master
with:
path: CHANGELOG.md
write-mode: overwrite
contents: ${{ needs.release_metadata.outputs.changelog }}

- name: Commit changes
id: commit
uses: EndBug/add-and-commit@v9
with:
author_name: Apify Release Bot
author_email: [email protected]
message: "chore(release): Update changelog and package version [skip ci]"

create_github_release:
name: Create github release
needs: [release_metadata, update_changelog]
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Create release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ needs.release_metadata.outputs.tag_name }}
name: ${{ needs.release_metadata.outputs.version_number }}
target_commitish: ${{ needs.update_changelog.outputs.changelog_commitish }}
body: ${{ needs.release_metadata.outputs.release_notes }}

publish_to_npm:
name: Publish to NPM
needs: [ update_changelog ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ needs.update_changelog.changelog_commitish }}
- name: Use Node.js 22
uses: actions/setup-node@v4
with:
node-version: 22
cache: 'npm'
cache-dependency-path: 'package-lock.json'
- name: Install dependencies
run: |
echo "access=public" >> .npmrc
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" >> .npmrc
npm ci
- name: Build module
run: npm run build
- name: Publish to NPM
run: npm publish --tag latest

env:
NODE_AUTH_TOKEN: ${{ secrets.APIFY_SERVICE_ACCOUNT_NPM_TOKEN }}
NPM_TOKEN: ${{ secrets.APIFY_SERVICE_ACCOUNT_NPM_TOKEN }}
8 changes: 8 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# .npmignore
# Exclude everything by default
*

# Include specific files and folders
!dist/
!README.md
!LICENSE
1 change: 0 additions & 1 deletion .python-version

This file was deleted.

19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Changelog

All notable changes to this project will be documented in this file.

## 0.1.1 (2025-03-14)

### 🐛 Bug Fixes

- Change env variable name from APIFY_API_TOKEN to APIFY_TOKEN
- Add extra query parameters
- Remove unnecessary example clients (SSE and chat client)
- Create NPM package @apify/mcp-server-rag-web-browser
- Update readme

## 0.1.0 (2025-01-17)

### 🚀 Features

- Initial release
Loading
Loading