Skip to content

Commit 9cb570d

Browse files
committed
feat: add additional headers and update linter
1 parent 1838bd7 commit 9cb570d

File tree

15 files changed

+142
-101
lines changed

15 files changed

+142
-101
lines changed

eslint.config.mjs

Lines changed: 31 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
// @ts-check
1717
import eslint from '@eslint/js'
18-
import stylisticJs from '@stylistic/eslint-plugin-js'
18+
import stylistic from '@stylistic/eslint-plugin'
1919
import tseslint from 'typescript-eslint'
2020

2121
export default tseslint.config(
@@ -32,7 +32,7 @@ export default tseslint.config(
3232
],
3333
},
3434
eslint.configs.recommended,
35-
stylisticJs.configs.all,
35+
stylistic.configs.all,
3636
tseslint.configs.recommended,
3737
tseslint.configs.stylistic,
3838
{
@@ -47,62 +47,76 @@ export default tseslint.config(
4747
allowSeparatedGroups: true,
4848
},
4949
],
50-
'@stylistic/js/multiline-comment-style': 'off',
51-
'@stylistic/js/lines-between-class-members': 'off',
52-
'@stylistic/js/newline-per-chained-call': 'off',
53-
'@stylistic/js/indent': [
50+
'@stylistic/multiline-comment-style': 'off',
51+
'@stylistic/lines-between-class-members': 'off',
52+
'@stylistic/newline-per-chained-call': 'off',
53+
'@stylistic/indent': [
5454
'error',
5555
2,
5656
],
57-
'@stylistic/js/quotes': [
57+
'@stylistic/quotes': [
5858
'error',
5959
'single',
6060
{
6161
allowTemplateLiterals: true,
6262
},
6363
],
64-
'@stylistic/js/quote-props': [
64+
'@stylistic/quote-props': [
6565
'error',
6666
'as-needed',
6767
],
68-
'@stylistic/js/semi': [
68+
'@stylistic/semi': [
6969
'error',
7070
'never',
7171
],
72-
'@stylistic/js/comma-dangle': [
72+
'@stylistic/comma-dangle': [
7373
'error',
7474
'always-multiline',
7575
],
76-
'@stylistic/js/function-call-argument-newline': [
76+
'@stylistic/function-call-argument-newline': [
7777
'error',
7878
'consistent',
7979
],
80-
'@stylistic/js/padded-blocks': [
80+
'@stylistic/padded-blocks': [
8181
'error',
8282
'never',
8383
],
84-
'@stylistic/js/object-curly-spacing': [
84+
'@stylistic/object-curly-spacing': [
8585
'error',
8686
'always',
8787
],
88-
'@stylistic/js/array-bracket-spacing': [
88+
'@stylistic/array-bracket-spacing': [
8989
'error',
9090
'always',
9191
],
92-
'@stylistic/js/array-bracket-newline': [
92+
'@stylistic/array-bracket-newline': [
9393
'error',
9494
'consistent',
9595
],
96-
'@stylistic/js/array-element-newline': [
96+
'@stylistic/array-element-newline': [
9797
'error',
9898
'consistent',
9999
],
100-
'@stylistic/js/object-property-newline': [
100+
'@stylistic/object-property-newline': [
101101
'error',
102102
{
103103
allowAllPropertiesOnSameLine: true,
104104
},
105105
],
106+
'@stylistic/member-delimiter-style': [
107+
'error',
108+
{
109+
multiline: {
110+
delimiter: 'none',
111+
requireLast: true
112+
},
113+
singleline: {
114+
delimiter: 'comma',
115+
requireLast: false
116+
},
117+
multilineDetection: 'brackets'
118+
},
119+
]
106120
},
107121
},
108122
)

package-lock.json

Lines changed: 21 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
},
3535
"devDependencies": {
3636
"@eslint/js": "^9.24.0",
37-
"@stylistic/eslint-plugin-js": "^4.4.0",
37+
"@stylistic/eslint-plugin": "^4.4.0",
3838
"@types/node": "^22.15.27",
3939
"c8": "^10.1.3",
4040
"eslint": "^9.27.0",

src/clients/FeaturesToggleClient.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ export enum ScopeType {
2626
}
2727

2828
export interface FeatureTogglesContext {
29-
tenantId?: string,
30-
projectId?: string,
31-
envId?: string,
29+
tenantId?: string
30+
projectId?: string
31+
envId?: string
3232
}
3333

3434
export type IFeatureTogglesClient = Omit<FeatureTogglesClient, 'client'>

src/lib/client/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ export class APIClient {
9191
const url = new URL(path, this.baseURL)
9292
params.set('per_page', '200')
9393

94-
const results:T[] = []
94+
const results: T[] = []
9595
let page = startingPage
9696
do {
9797
params.set('page', `${page}`)

src/lib/client/miactl-cache.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ interface MiactlCache {
3535
expiry: string // ISO-8601 format
3636
}
3737

38-
async function getMiactlCache (endpoint: string): Promise<MiactlCache|undefined> {
39-
let cacheFolderPath: string|undefined = process.env['XDG_CACHE_HOME']
38+
async function getMiactlCache (endpoint: string): Promise<MiactlCache | undefined> {
39+
let cacheFolderPath: string | undefined = process.env['XDG_CACHE_HOME']
4040
if (!cacheFolderPath) {
4141
const home = homeFolderPath()
4242
cacheFolderPath = join(home, '.cache')

src/lib/client/token.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,17 @@ export class AccessToken {
3939
return this.expires_at - (Date.now() + expirationWindowSeconds * 1000) <= 0
4040
}
4141

42-
refreshToken (): string|undefined {
42+
refreshToken (): string | undefined {
4343
return this.refresh_token
4444
}
4545
}
4646

4747
interface AuthnOpts {
48-
clientId?: string,
49-
clientSecret?: string,
48+
clientId?: string
49+
clientSecret?: string
5050
}
5151

52-
export async function doAuthentication (baseURL: string, options: AuthnOpts): Promise<AccessToken|undefined> {
52+
export async function doAuthentication (baseURL: string, options: AuthnOpts): Promise<AccessToken | undefined> {
5353
if (options.clientId && options.clientSecret) {
5454
return await doM2MAuthentication(baseURL, options.clientId, options.clientSecret)
5555
}
@@ -95,7 +95,7 @@ async function doM2MAuthentication (baseURL: string, clientId: string, clientCre
9595
return new AccessToken(data.access_token, data.token_type, data.expires_in)
9696
}
9797

98-
async function doUserAuthentication (baseURL: string): Promise<AccessToken|undefined> {
98+
async function doUserAuthentication (baseURL: string): Promise<AccessToken | undefined> {
9999
const miactlToken = await loadMiactlToken(baseURL)
100100
if (!miactlToken) {
101101
return undefined

src/server/httpserver.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import { httpServer } from './httpserver.js'
2323
suite('test http streaming server', () => {
2424
const testHost = 'http://localhost:3000'
2525

26-
let fastify:FastifyInstance
26+
let fastify: FastifyInstance
2727
beforeEach(async () => {
2828
fastify = Fastify({
2929
logger: false,

src/server/httpserver.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,14 @@
1313
// See the License for the specific language governing permissions and
1414
// limitations under the License.
1515

16+
import { env } from 'node:process'
17+
1618
import { FastifyInstance } from 'fastify'
1719
import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js'
1820
import { ErrorCode, JSONRPC_VERSION } from '@modelcontextprotocol/sdk/types.js'
1921

2022
import { getMcpServer } from './server'
23+
import { IncomingHttpHeaders } from 'undici/types/header'
2124

2225
export interface HTTPServerOptions {
2326
host: string
@@ -27,10 +30,18 @@ export interface HTTPServerOptions {
2730

2831
export function httpServer (fastify: FastifyInstance, opts: HTTPServerOptions) {
2932
const { host, clientID, clientSecret } = opts
33+
const additionalHeadersKeys = env.HEADERS_TO_PROXY?.split(',') || []
3034

3135
fastify.post('/mcp', async (request, reply) => {
36+
const additionalHeaders: IncomingHttpHeaders = {}
37+
for (const key of additionalHeadersKeys) {
38+
if (key in request.headers) {
39+
additionalHeaders[key] = request.headers[key]
40+
}
41+
}
42+
3243
try {
33-
const server = getMcpServer(host, clientID, clientSecret)
44+
const server = getMcpServer(host, clientID, clientSecret, additionalHeaders)
3445
const transport = new StreamableHTTPServerTransport({
3546
sessionIdGenerator: undefined,
3647
})

src/server/test-utils.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export async function TestMCPServer (toolsBuilder: ToolsBuilder): Promise<Client
4545
return testClient
4646
}
4747

48-
export function getAppContext (ctx: Partial<AppContext> & {client: APIClient}): AppContext {
48+
export function getAppContext (ctx: Partial<AppContext> & { client: APIClient }): AppContext {
4949
return {
5050
ftClient: getMockFeatureTogglesClient({}),
5151
...ctx,

0 commit comments

Comments
 (0)