Skip to content

Commit 2945c53

Browse files
committed
remove extraneous comments
1 parent ef94e09 commit 2945c53

7 files changed

Lines changed: 16 additions & 55 deletions

File tree

apps/sim/app/api/providers/route.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export async function POST(request: NextRequest) {
3737
azureApiVersion,
3838
responseFormat,
3939
workflowId,
40-
workspaceId, // Extract workspaceId for MCP tools
40+
workspaceId,
4141
stream,
4242
messages,
4343
environmentVariables,
@@ -106,7 +106,7 @@ export async function POST(request: NextRequest) {
106106
azureApiVersion,
107107
responseFormat,
108108
workflowId,
109-
workspaceId, // Pass workspaceId for MCP tools
109+
workspaceId,
110110
stream,
111111
messages,
112112
environmentVariables,

apps/sim/app/api/tools/drive/file/route.ts

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,10 @@ const logger = createLogger('GoogleDriveFileAPI')
1111
* Get a single file from Google Drive
1212
*/
1313
export async function GET(request: NextRequest) {
14-
const requestId = generateRequestId() // Generate a short request ID for correlation
14+
const requestId = generateRequestId()
1515
logger.info(`[${requestId}] Google Drive file request received`)
1616

1717
try {
18-
// Get the credential ID and file ID from the query params
1918
const { searchParams } = new URL(request.url)
2019
const credentialId = searchParams.get('credentialId')
2120
const fileId = searchParams.get('fileId')
@@ -31,7 +30,6 @@ export async function GET(request: NextRequest) {
3130
return NextResponse.json({ error: authz.error || 'Unauthorized' }, { status: 403 })
3231
}
3332

34-
// Refresh access token if needed using the utility function
3533
const accessToken = await refreshAccessTokenIfNeeded(
3634
credentialId,
3735
authz.credentialOwnerUserId,
@@ -42,7 +40,6 @@ export async function GET(request: NextRequest) {
4240
return NextResponse.json({ error: 'Failed to obtain valid access token' }, { status: 401 })
4341
}
4442

45-
// Fetch the file from Google Drive API
4643
logger.info(`[${requestId}] Fetching file ${fileId} from Google Drive API`)
4744
const response = await fetch(
4845
`https://www.googleapis.com/drive/v3/files/${fileId}?fields=id,name,mimeType,iconLink,webViewLink,thumbnailLink,createdTime,modifiedTime,size,owners,exportLinks,shortcutDetails&supportsAllDrives=true`,
@@ -69,15 +66,13 @@ export async function GET(request: NextRequest) {
6966

7067
const file = await response.json()
7168

72-
// In case of Google Docs, Sheets, etc., provide the export links
7369
const exportFormats: { [key: string]: string } = {
7470
'application/vnd.google-apps.document': 'application/pdf', // Google Docs to PDF
7571
'application/vnd.google-apps.spreadsheet':
7672
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', // Google Sheets to XLSX
7773
'application/vnd.google-apps.presentation': 'application/pdf', // Google Slides to PDF
7874
}
7975

80-
// Resolve shortcuts transparently for UI stability
8176
if (
8277
file.mimeType === 'application/vnd.google-apps.shortcut' &&
8378
file.shortcutDetails?.targetId
@@ -105,20 +100,16 @@ export async function GET(request: NextRequest) {
105100
}
106101
}
107102

108-
// If the file is a Google Docs, Sheets, or Slides file, we need to provide the export link
109103
if (file.mimeType.startsWith('application/vnd.google-apps.')) {
110104
const format = exportFormats[file.mimeType] || 'application/pdf'
111105
if (!file.exportLinks) {
112-
// If export links are not available in the response, try to construct one
113106
file.downloadUrl = `https://www.googleapis.com/drive/v3/files/${file.id}/export?mimeType=${encodeURIComponent(
114107
format
115108
)}`
116109
} else {
117-
// Use the export link from the response if available
118110
file.downloadUrl = file.exportLinks[format]
119111
}
120112
} else {
121-
// For regular files, use the download link
122113
file.downloadUrl = `https://www.googleapis.com/drive/v3/files/${file.id}?alt=media`
123114
}
124115

apps/sim/app/api/tools/drive/files/route.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,17 @@ const logger = createLogger('GoogleDriveFilesAPI')
1212
* Get files from Google Drive
1313
*/
1414
export async function GET(request: NextRequest) {
15-
const requestId = generateRequestId() // Generate a short request ID for correlation
15+
const requestId = generateRequestId()
1616
logger.info(`[${requestId}] Google Drive files request received`)
1717

1818
try {
19-
// Get the session
2019
const session = await getSession()
2120

22-
// Check if the user is authenticated
2321
if (!session?.user?.id) {
2422
logger.warn(`[${requestId}] Unauthenticated request rejected`)
2523
return NextResponse.json({ error: 'User not authenticated' }, { status: 401 })
2624
}
2725

28-
// Get the credential ID from the query params
2926
const { searchParams } = new URL(request.url)
3027
const credentialId = searchParams.get('credentialId')
3128
const mimeType = searchParams.get('mimeType')
@@ -38,14 +35,12 @@ export async function GET(request: NextRequest) {
3835
return NextResponse.json({ error: 'Credential ID is required' }, { status: 400 })
3936
}
4037

41-
// Authorize use of the credential (supports collaborator credentials via workflow)
4238
const authz = await authorizeCredentialUse(request, { credentialId: credentialId!, workflowId })
4339
if (!authz.ok || !authz.credentialOwnerUserId) {
4440
logger.warn(`[${requestId}] Unauthorized credential access attempt`, authz)
4541
return NextResponse.json({ error: authz.error || 'Unauthorized' }, { status: 403 })
4642
}
4743

48-
// Refresh access token if needed using the utility function
4944
const accessToken = await refreshAccessTokenIfNeeded(
5045
credentialId!,
5146
authz.credentialOwnerUserId,
@@ -56,7 +51,6 @@ export async function GET(request: NextRequest) {
5651
return NextResponse.json({ error: 'Failed to obtain valid access token' }, { status: 401 })
5752
}
5853

59-
// Build Drive 'q' expression safely
6054
const qParts: string[] = ['trashed = false']
6155
if (folderId) {
6256
qParts.push(`'${folderId.replace(/'/g, "\\'")}' in parents`)
@@ -69,7 +63,6 @@ export async function GET(request: NextRequest) {
6963
}
7064
const q = encodeURIComponent(qParts.join(' and '))
7165

72-
// Fetch files from Google Drive API with shared drives support
7366
const response = await fetch(
7467
`https://www.googleapis.com/drive/v3/files?q=${q}&supportsAllDrives=true&includeItemsFromAllDrives=true&spaces=drive&fields=files(id,name,mimeType,iconLink,webViewLink,thumbnailLink,createdTime,modifiedTime,size,owners,parents)`,
7568
{

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/workflow-block/components/sub-block/components/mcp-server-modal/mcp-tool-selector.tsx

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -39,34 +39,25 @@ export function McpToolSelector({
3939
const workspaceId = params.workspaceId as string
4040
const [open, setOpen] = useState(false)
4141

42-
// Get MCP tools from hook
4342
const { mcpTools, isLoading, error, refreshTools, getToolsByServer } = useMcpTools(workspaceId)
4443

45-
// Use collaborative state management via useSubBlockValue hook
4644
const [storeValue, setStoreValue] = useSubBlockValue(blockId, subBlock.id)
4745

48-
// Get the server selection from the dependent field
4946
const [serverValue] = useSubBlockValue(blockId, 'server')
5047

51-
// Extract config values
5248
const label = subBlock.placeholder || 'Select tool'
5349

54-
// Get the effective value (preview or store value)
5550
const effectiveValue = isPreview && previewValue !== undefined ? previewValue : storeValue
5651
const selectedToolId = effectiveValue || ''
5752

58-
// Get available tools for the selected server
5953
const availableTools = useMemo(() => {
6054
if (!serverValue) return []
6155
return getToolsByServer(serverValue)
6256
}, [serverValue, getToolsByServer])
6357

64-
// Get the selected tool
6558
const selectedTool = availableTools.find((tool) => tool.id === selectedToolId)
6659

67-
// Clear tool selection when server changes (but not when tools are still loading)
6860
useEffect(() => {
69-
// Only clear if we have a stored value, tools are loaded, and the tool doesn't exist
7061
if (
7162
storeValue &&
7263
availableTools.length > 0 &&
@@ -78,23 +69,20 @@ export function McpToolSelector({
7869
}
7970
}, [serverValue, availableTools, storeValue, setStoreValue, isPreview])
8071

81-
// Handle popover open to refresh tools
8272
const handleOpenChange = (isOpen: boolean) => {
8373
setOpen(isOpen)
8474
if (isOpen && serverValue) {
8575
refreshTools()
8676
}
8777
}
8878

89-
// Handle tool selection
9079
const handleSelect = (toolId: string) => {
9180
if (!isPreview) {
9281
setStoreValue(toolId)
9382
}
9483
setOpen(false)
9584
}
9685

97-
// Get display text for selected tool
9886
const getDisplayText = () => {
9987
if (selectedTool) {
10088
return <span className='truncate font-normal'>{selectedTool.name}</span>
@@ -106,7 +94,6 @@ export function McpToolSelector({
10694
)
10795
}
10896

109-
// Don't show anything if no server is selected
11097
const isDisabled = disabled || !serverValue
11198

11299
return (

apps/sim/executor/handlers/agent/agent-handler.ts

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -258,11 +258,11 @@ export class AgentBlockHandler implements BlockHandler {
258258
headers.Authorization = `Bearer ${internalToken}`
259259
} catch (error) {
260260
logger.error(`Failed to generate internal token for MCP tool discovery:`, error)
261-
// Still continue with the request, but it will likely fail auth
262261
}
263262
}
264263

265-
const url = new URL(`${process.env.NEXT_PUBLIC_APP_URL}/api/mcp/tools/discover`)
264+
const appUrl = getEnv('NEXT_PUBLIC_APP_URL')
265+
const url = new URL(`${appUrl}/api/mcp/tools/discover`)
266266
url.searchParams.set('serverId', serverId)
267267
if (context.workspaceId) {
268268
url.searchParams.set('workspaceId', context.workspaceId)
@@ -313,23 +313,19 @@ export class AgentBlockHandler implements BlockHandler {
313313
headers.Authorization = `Bearer ${internalToken}`
314314
} catch (error) {
315315
logger.error(`Failed to generate internal token for MCP tool ${toolName}:`, error)
316-
// Still continue with the request, but it will likely fail auth
317316
}
318317
}
319318

320-
const execResponse = await fetch(
321-
`${process.env.NEXT_PUBLIC_APP_URL}/api/mcp/tools/execute`,
322-
{
323-
method: 'POST',
324-
headers,
325-
body: JSON.stringify({
326-
serverId,
327-
toolName,
328-
arguments: { ...params, ...callParams },
329-
workspaceId: context.workspaceId,
330-
}),
331-
}
332-
)
319+
const execResponse = await fetch(`${appUrl}/api/mcp/tools/execute`, {
320+
method: 'POST',
321+
headers,
322+
body: JSON.stringify({
323+
serverId,
324+
toolName,
325+
arguments: { ...params, ...callParams },
326+
workspaceId: context.workspaceId,
327+
}),
328+
})
333329

334330
if (!execResponse.ok) {
335331
throw new Error(

apps/sim/executor/handlers/generic/generic-handler.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ export class GenericBlockHandler implements BlockHandler {
2525
): Promise<any> {
2626
logger.info(`Executing block: ${block.id} (Type: ${block.metadata?.id})`)
2727

28-
// Handle MCP tools
2928
const isMcpTool = block.config.tool?.startsWith('mcp-')
3029
let tool = null
3130

@@ -36,16 +35,13 @@ export class GenericBlockHandler implements BlockHandler {
3635
}
3736
}
3837

39-
// Apply block-level parameter transformation if available
4038
let finalInputs = { ...inputs }
4139

42-
// Get the block configuration to check for parameter transformation
4340
const blockType = block.metadata?.id
4441
if (blockType) {
4542
const blockConfig = getBlock(blockType)
4643
if (blockConfig?.tools?.config?.params) {
4744
try {
48-
// Apply the block's parameter transformation
4945
const transformedParams = blockConfig.tools.config.params(inputs)
5046
finalInputs = { ...transformedParams }
5147
logger.info(`Applied parameter transformation for block type: ${blockType}`, {

apps/sim/hooks/use-mcp-server-test.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ export function useMcpServerTest() {
5959
setTestResult(null)
6060

6161
try {
62-
// Filter out empty headers before sending to API
6362
const cleanConfig = {
6463
...config,
6564
headers: config.headers
@@ -134,7 +133,6 @@ export function getTestResultSummary(result: McpServerTestResult): string {
134133
export function isServerSafeToAdd(result: McpServerTestResult): boolean {
135134
if (!result.success) return false
136135

137-
// Check for version compatibility issues
138136
if (result.warnings?.some((w) => w.toLowerCase().includes('version'))) {
139137
return false
140138
}

0 commit comments

Comments
 (0)