Skip to content

Commit a499c36

Browse files
committed
Add Flutter multi-platform package; add Android 16kb page size support; fix broken npmjs packages workflow
1 parent 52d0463 commit a499c36

File tree

17 files changed

+365
-10
lines changed

17 files changed

+365
-10
lines changed
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
name: publish flutter package
2+
on:
3+
push:
4+
tags:
5+
- '*.*.*'
6+
7+
permissions:
8+
contents: read
9+
id-token: write
10+
11+
jobs:
12+
publish:
13+
runs-on: ubuntu-22.04
14+
name: publish to pub.dev
15+
16+
steps:
17+
18+
- uses: actions/checkout@v4.2.2
19+
20+
- name: download release assets
21+
run: |
22+
VERSION=${GITHUB_REF#refs/tags/}
23+
echo "VERSION=$VERSION" >> $GITHUB_ENV
24+
25+
mkdir -p artifacts
26+
cd artifacts
27+
28+
# Download all platform binaries from the GitHub release
29+
gh release download "$VERSION" --pattern "mcp-*.tar.gz"
30+
31+
# Extract all archives
32+
for archive in mcp-*.tar.gz; do
33+
name=$(basename "$archive" "-$VERSION.tar.gz")
34+
mkdir -p "$name"
35+
tar -xzf "$archive" -C "$name"
36+
rm "$archive"
37+
done
38+
39+
ls -la
40+
env:
41+
GH_TOKEN: ${{ github.token }}
42+
43+
- uses: dart-lang/setup-dart@v1.7.1
44+
45+
- name: assemble and publish flutter package
46+
run: |
47+
FLUTTER_DIR=packages/flutter
48+
49+
# Android
50+
mkdir -p $FLUTTER_DIR/native_libraries/android
51+
cp artifacts/mcp-android-arm64-v8a/mcp.so $FLUTTER_DIR/native_libraries/android/mcp_android_arm64.so
52+
cp artifacts/mcp-android-armeabi-v7a/mcp.so $FLUTTER_DIR/native_libraries/android/mcp_android_arm.so
53+
cp artifacts/mcp-android-x86_64/mcp.so $FLUTTER_DIR/native_libraries/android/mcp_android_x64.so
54+
55+
# iOS device
56+
mkdir -p $FLUTTER_DIR/native_libraries/ios
57+
cp artifacts/mcp-ios/mcp.dylib $FLUTTER_DIR/native_libraries/ios/mcp_ios_arm64.dylib
58+
59+
# iOS simulator (keep universal/fat binary as-is)
60+
mkdir -p $FLUTTER_DIR/native_libraries/ios-sim
61+
cp artifacts/mcp-ios-sim/mcp.dylib $FLUTTER_DIR/native_libraries/ios-sim/mcp_ios-sim.dylib
62+
63+
# macOS (separate arch-specific dylibs)
64+
mkdir -p $FLUTTER_DIR/native_libraries/mac
65+
cp artifacts/mcp-macos-arm64/mcp.dylib $FLUTTER_DIR/native_libraries/mac/mcp_mac_arm64.dylib
66+
cp artifacts/mcp-macos-x86_64/mcp.dylib $FLUTTER_DIR/native_libraries/mac/mcp_mac_x64.dylib
67+
68+
# Linux
69+
mkdir -p $FLUTTER_DIR/native_libraries/linux
70+
cp artifacts/mcp-linux-x86_64/mcp.so $FLUTTER_DIR/native_libraries/linux/mcp_linux_x64.so
71+
cp artifacts/mcp-linux-arm64/mcp.so $FLUTTER_DIR/native_libraries/linux/mcp_linux_arm64.so
72+
73+
# Windows
74+
mkdir -p $FLUTTER_DIR/native_libraries/windows
75+
cp artifacts/mcp-windows-x86_64/mcp.dll $FLUTTER_DIR/native_libraries/windows/mcp_windows_x64.dll
76+
77+
# Update version
78+
sed -i "s/^version: .*/version: $VERSION/" $FLUTTER_DIR/pubspec.yaml
79+
80+
# Publish to pub.dev
81+
cd $FLUTTER_DIR
82+
dart pub get
83+
dart pub publish --dry-run
84+
dart pub publish --force

.github/workflows/main.yml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
name: Build, Test and Release
99
on:
1010
push:
11+
branches:
12+
- '**'
13+
tags-ignore:
14+
- '**'
1115
workflow_dispatch:
1216

1317
permissions:
@@ -353,12 +357,9 @@ jobs:
353357
- uses: actions/setup-node@v4
354358
if: steps.tag.outputs.version != ''
355359
with:
356-
node-version: '20'
360+
node-version: '24'
357361
registry-url: 'https://registry.npmjs.org'
358362

359-
- name: update npm
360-
run: npm install -g npm@11.5.1
361-
362363
- name: build and publish npm packages
363364
if: steps.tag.outputs.version != ''
364365
run: |
@@ -414,10 +415,12 @@ jobs:
414415
- uses: softprops/action-gh-release@v2.2.1
415416
if: steps.tag.outputs.version != ''
416417
with:
418+
token: ${{ secrets.RELEASE_PAT }}
417419
body: |
418-
420+
419421
## Packages
420422
423+
[**Flutter/Dart**](https://pub.dev/packages/sqlite_mcp): `flutter pub add sqlite_mcp:${{ steps.tag.outputs.version }}` or `dart pub add sqlite_mcp:${{ steps.tag.outputs.version }}`
421424
[**Node**](https://www.npmjs.com/package/@sqliteai/sqlite-mcp): `npm install @sqliteai/sqlite-mcp`
422425
[**Android**](https://central.sonatype.com/artifact/ai.sqlite/mcp): `ai.sqlite:mcp:${{ steps.tag.outputs.version }}`
423426
[**Swift**](https://github.com/sqliteai/sqlite-mcp#swift-package): [Installation Guide](https://github.com/sqliteai/sqlite-mcp#swift-package)

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,10 @@ packages/node/test-platform-packages/
5353
.DS_Store
5454
Thumbs.db
5555
*.db
56+
57+
# Dart/Flutter
58+
.dart_tool/
59+
pubspec.lock
60+
.flutter-plugins
61+
.flutter-plugins-dependencies
62+
packages/flutter/native_libraries/

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "mcp-ffi"
3-
version = "0.1.4"
3+
version = "0.1.5"
44
edition = "2021"
55

66
[dependencies]

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ else ifeq ($(PLATFORM),android)
100100
CC = $(BIN)/$(ARCH)-linux-$(ANDROID_ABI)-clang
101101
OPENSSL = $(OPENSSL_INSTALL_DIR)/lib/libssl.a
102102
TARGET := $(DIST_DIR)/mcp.so
103-
LDFLAGS += -shared -L$(OPENSSL_INSTALL_DIR)/lib -Wl,--gc-sections
103+
LDFLAGS += -shared -L$(OPENSSL_INSTALL_DIR)/lib -Wl,--gc-sections -Wl,-z,max-page-size=16384
104104
CFLAGS += -fPIC -I$(OPENSSL_INSTALL_DIR)/include
105105
STRIP = $(BIN)/llvm-strip --strip-unneeded $@
106106
LIBS = -lmcp_ffi -ldl -lm -lssl -lcrypto

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,27 @@ A SQLite extension that integrates the [Model Context Protocol (MCP)](https://mo
1010

1111
Download for your platform: **macOS**, **Linux**, **Windows**, **Android**, and **iOS**.
1212

13+
#### Flutter Package
14+
15+
Add the [sqlite_mcp](https://pub.dev/packages/sqlite_mcp) package to your project:
16+
17+
```bash
18+
flutter pub add sqlite_mcp # Flutter projects
19+
dart pub add sqlite_mcp # Dart projects
20+
```
21+
22+
Usage with `sqlite3` package:
23+
```dart
24+
import 'package:sqlite3/sqlite3.dart';
25+
import 'package:sqlite_mcp/sqlite_mcp.dart';
26+
27+
sqlite3.loadSqliteMcpExtension();
28+
final db = sqlite3.openInMemory();
29+
print(db.select('SELECT mcp_version()'));
30+
```
31+
32+
For a complete example, see the [Flutter example](https://github.com/sqliteai/sqlite-extensions-guide/blob/main/examples/flutter/README.md).
33+
1334
### Basic Usage
1435

1536
```sql

packages/flutter/.pubignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Only ignore development files, NOT native_libraries
2+
.dart_tool/
3+
pubspec.lock
4+
5+
# Explicitly include native_libraries (override any parent .gitignore)
6+
!native_libraries/
7+
!native_libraries/**

packages/flutter/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Changelog
2+
3+
## 0.1.5
4+
5+
- Initial Flutter package release
6+
- Added support for Android 16kb page size devices

packages/flutter/LICENSE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../LICENSE

packages/flutter/README.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# sqlite_mcp
2+
3+
A SQLite extension that integrates the Model Context Protocol (MCP) Rust SDK, enabling SQLite databases to connect to MCP servers and call their tools.
4+
5+
## Installation
6+
7+
```
8+
dart pub add sqlite_mcp
9+
```
10+
11+
Requires Dart 3.10+ / Flutter 3.38+.
12+
13+
## Usage
14+
15+
### With `sqlite3`
16+
17+
```dart
18+
import 'package:sqlite3/sqlite3.dart';
19+
import 'package:sqlite_mcp/sqlite_mcp.dart';
20+
21+
void main() {
22+
// Load once at startup.
23+
sqlite3.loadSqliteMcpExtension();
24+
25+
final db = sqlite3.openInMemory();
26+
27+
// Check version.
28+
final result = db.select('SELECT mcp_version() AS version');
29+
print(result.first['version']);
30+
31+
db.dispose();
32+
}
33+
```
34+
35+
### With `drift`
36+
37+
```dart
38+
import 'package:sqlite3/sqlite3.dart';
39+
import 'package:sqlite_mcp/sqlite_mcp.dart';
40+
import 'package:drift/native.dart';
41+
42+
Sqlite3 loadExtensions() {
43+
sqlite3.loadSqliteMcpExtension();
44+
return sqlite3;
45+
}
46+
47+
// Use when creating the database:
48+
NativeDatabase.createInBackground(
49+
File(path),
50+
sqlite3: loadExtensions,
51+
);
52+
```
53+
54+
## Supported platforms
55+
56+
| Platform | Architectures |
57+
|----------|---------------|
58+
| Android | arm64, arm, x64 |
59+
| iOS | arm64 (device + simulator) |
60+
| macOS | arm64, x64 |
61+
| Linux | arm64, x64 |
62+
| Windows | x64 |
63+
64+
## API
65+
66+
See the full [sqlite-mcp API documentation](https://github.com/sqliteai/sqlite-mcp/blob/main/API.md).
67+
68+
## License
69+
70+
See [LICENSE](LICENSE).

0 commit comments

Comments
 (0)