Skip to content

Commit db0bbd3

Browse files
authored
Fix auth issues. (#388)
1 parent 3d5c968 commit db0bbd3

12 files changed

Lines changed: 43 additions & 23 deletions

File tree

mcp_servers/attio/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,7 @@ function extractAccessToken(req: Request): string {
614614

615615
if (!authData) {
616616
console.error('Error: Attio access token is missing. Provide it via ACCESS_TOKEN env var or x-auth-data header with access_token field.');
617-
authData = '';
617+
return '';
618618
}
619619

620620
const authDataJson = JSON.parse(authData);

mcp_servers/exa/server.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
def extract_api_key(request_or_scope) -> str:
4141
"""Extract API key from headers or environment."""
4242
api_key = os.getenv("API_KEY")
43+
auth_data = None
4344

4445
if not api_key:
4546
# Handle different input types (request object for SSE, scope dict for StreamableHTTP)
@@ -54,8 +55,6 @@ def extract_api_key(request_or_scope) -> str:
5455
auth_data = headers.get(b'x-auth-data')
5556
if auth_data:
5657
auth_data = base64.b64decode(auth_data).decode('utf-8')
57-
else:
58-
auth_data = None
5958

6059
if auth_data:
6160
try:

mcp_servers/firecrawl/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1474,6 +1474,10 @@ function trimResponseText(text: string): string {
14741474
function extractApiKey(req: Request): string {
14751475
let authData = process.env.API_KEY;
14761476

1477+
if (authData) {
1478+
return authData;
1479+
}
1480+
14771481
if (!authData && req.headers['x-auth-data']) {
14781482
try {
14791483
authData = Buffer.from(req.headers['x-auth-data'] as string, 'base64').toString('utf8');

mcp_servers/firecrawl_deep_research/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,10 @@ const getFirecrawlDeepResearchMcpServer = () => {
304304

305305
function extractApiKey(req: Request): string {
306306
let authData = process.env.API_KEY;
307+
308+
if (authData) {
309+
return authData;
310+
}
307311

308312
if (!authData && req.headers['x-auth-data']) {
309313
try {

mcp_servers/freshdesk/server.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ def extract_credentials(request_or_scope) -> Dict[str, str]:
103103
"""Extract API key and domain from headers or environment."""
104104
api_key = os.getenv("API_KEY")
105105
domain = os.getenv("DOMAIN")
106+
auth_data = None
106107

107108
# Handle different input types (request object for SSE, scope dict for StreamableHTTP)
108109
if hasattr(request_or_scope, 'headers'):
@@ -116,9 +117,7 @@ def extract_credentials(request_or_scope) -> Dict[str, str]:
116117
headers = dict(request_or_scope.get("headers", []))
117118
header_value = headers.get(b'x-auth-data')
118119
if header_value:
119-
auth_data = base64.b64decode(header_value).decode('utf-8')
120-
else:
121-
auth_data = None
120+
auth_data = base64.b64decode(header_value).decode('utf-8')
122121

123122
# If no API key from environment, try to parse from auth_data
124123
if not api_key and auth_data:

mcp_servers/google_jobs/server.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
def extract_api_key(request_or_scope) -> str:
3838
"""Extract API key from headers or environment."""
3939
api_key = os.getenv("API_KEY")
40+
auth_data = None
4041

4142
if not api_key:
4243
# Handle different input types (request object for SSE, scope dict for StreamableHTTP)
@@ -51,8 +52,6 @@ def extract_api_key(request_or_scope) -> str:
5152
auth_data = headers.get(b'x-auth-data')
5253
if auth_data:
5354
auth_data = base64.b64decode(auth_data).decode('utf-8')
54-
else:
55-
auth_data = None
5655

5756
if auth_data:
5857
try:

mcp_servers/postgres/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,10 @@ function getPool() {
152152

153153
function extractApiKey(req: Request): string {
154154
let authData = process.env.API_KEY;
155+
156+
if (authData) {
157+
return authData;
158+
}
155159

156160
if (!authData && req.headers['x-auth-data']) {
157161
try {

mcp_servers/quickbooks/session_manager.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,15 @@ def extract_credentials_from_headers(self, request_or_scope) -> Tuple[str, str,
9797
# Get headers based on input type
9898
if hasattr(request_or_scope, 'headers'):
9999
# SSE request object
100-
headers = request_or_scope.headers
100+
header_value = request_or_scope.headers.get(b'x-auth-data')
101+
if header_value:
102+
auth_data = base64.b64decode(header_value).decode('utf-8')
101103
elif isinstance(request_or_scope, dict) and 'headers' in request_or_scope:
102104
# StreamableHTTP scope object
103105
headers = dict(request_or_scope.get("headers", []))
104-
else:
105-
return "", "", ""
106+
header_value = headers.get(b'x-auth-data')
107+
if header_value:
108+
auth_data = base64.b64decode(header_value).decode('utf-8')
106109

107110
# Extract auth data from x-auth-data header
108111
auth_data = base64.b64decode(headers.get(b'x-auth-data')).decode('utf-8')

mcp_servers/resend/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -682,6 +682,10 @@ const getResendMcpServer = () => {
682682

683683
function extractApiKey(req: Request): string {
684684
let authData = process.env.API_KEY;
685+
686+
if (authData) {
687+
return authData;
688+
}
685689

686690
if (!authData && req.headers['x-auth-data']) {
687691
try {

mcp_servers/salesforce/server.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,15 @@ def extract_auth_credentials(request_or_scope) -> tuple[str, str]:
5353
# Get headers based on input type
5454
if hasattr(request_or_scope, 'headers'):
5555
# SSE request object
56-
headers = request_or_scope.headers
56+
header_value = request_or_scope.headers.get(b'x-auth-data')
57+
if header_value:
58+
auth_data = base64.b64decode(header_value).decode('utf-8')
5759
elif isinstance(request_or_scope, dict) and 'headers' in request_or_scope:
5860
# StreamableHTTP scope object
5961
headers = dict(request_or_scope.get("headers", []))
60-
else:
61-
return "", ""
62-
63-
# Extract auth data from x-auth-data header
64-
auth_data = base64.b64decode(headers.get(b'x-auth-data')).decode('utf-8')
62+
header_value = headers.get(b'x-auth-data')
63+
if header_value:
64+
auth_data = base64.b64decode(header_value).decode('utf-8')
6565

6666
if not auth_data:
6767
return "", ""

0 commit comments

Comments
 (0)