Skip to content

Commit 2b34532

Browse files
committed
fix: read package.json from dist folder
1 parent a348925 commit 2b34532

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"main": "index.ts",
77
"scripts": {
88
"typecheck": "tsc --noEmit",
9-
"build": "pnpm typecheck && tsc",
9+
"build": "pnpm typecheck && tsc && cp package.json dist/package.json",
1010
"start": "node dist/index.js",
1111
"start:stdio": "MCP_TRANSPORT_MODE=stdio pnpm start",
1212
"start:sse": "MCP_TRANSPORT_MODE=sse pnpm start",

src/core/storage/client.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ import { DEFAULT_GATEWAY_URL } from './config.js';
2020
import { Principal } from '@ucanto/interface';
2121
import { DID } from '@ucanto/core';
2222
import { readFileSync } from 'fs';
23-
import { join } from 'path';
23+
import { join, dirname } from 'path';
24+
import { fileURLToPath } from 'url';
2425
import { parseIpfsPath, streamToBase64, base64ToBytes } from './utils.js';
2526
import { CID, UnknownLink } from 'multiformats';
2627
import { CarReader } from '@ipld/car';
@@ -32,7 +33,10 @@ import { Readable } from 'node:stream';
3233
*/
3334
const STORAGE_SERVICE_DID = 'did:web:web3.storage';
3435

35-
const packageJson = JSON.parse(readFileSync(join(process.cwd(), 'package.json'), 'utf-8'));
36+
const __filename = fileURLToPath(import.meta.url);
37+
const __dirname = dirname(__filename);
38+
const rootDir = join(__dirname, '../../..');
39+
const packageJson = JSON.parse(readFileSync(join(rootDir, 'package.json'), 'utf-8'));
3640

3741
/**
3842
* Add the major version of the MCP server to the headers of the Storacha client.

0 commit comments

Comments
 (0)