File tree Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change 11import { ClientOptions } from 'contentful-management' ;
22import { env } from '../config/env.js' ;
3+ import { getVersion } from '../utils/getVersion.js' ;
34
45/**
56 * Creates a default Contentful client configuration without actually initializing it.
@@ -13,6 +14,9 @@ export function getDefaultClientConfig(): ClientOptions {
1314 accessToken : env . data . CONTENTFUL_MANAGEMENT_ACCESS_TOKEN ,
1415 host : env . data . CONTENTFUL_HOST ,
1516 space : env . data . SPACE_ID ,
17+ headers : {
18+ 'X-Contentful-User-Agent-Tool' : `contentful-mcp/${ getVersion ( ) } ` , //Include user agent header for telemetry tracking
19+ } ,
1620 } ;
1721
1822 return clientConfig ;
Original file line number Diff line number Diff line change 1+ import { readFileSync } from 'node:fs' ;
2+ import { join } from 'node:path' ;
3+ import { fileURLToPath } from 'node:url' ;
4+ import { dirname } from 'node:path' ;
5+
6+ export const getVersion = ( ) => {
7+ const __filename = fileURLToPath ( import . meta. url ) ;
8+ const __dirname = dirname ( __filename ) ;
9+ const packageJsonPath = join ( __dirname , '../../package.json' ) ;
10+ const packageJson = JSON . parse ( readFileSync ( packageJsonPath , 'utf8' ) ) ;
11+ return packageJson . version ;
12+ } ;
You can’t perform that action at this time.
0 commit comments