Skip to content

Feature - add Teradata MCP server #5002

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions packages/components/credentials/TeradataBearerToken.credential.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { INodeParams, INodeCredential } from '../src/Interface'

class TeradataBearerTokenCredential implements INodeCredential {
label: string
name: string
version: number
inputs: INodeParams[]

constructor() {
this.label = 'Teradata Bearer Token'
this.name = 'teradataBearerToken'
this.version = 1.0
this.inputs = [
{
label: 'Token',
name: 'token',
type: 'password'
}
]
}
}

module.exports = { credClass: TeradataBearerTokenCredential }
28 changes: 28 additions & 0 deletions packages/components/credentials/TeradataTD2.credential.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { INodeParams, INodeCredential } from '../src/Interface'

class TeradataTD2Credential implements INodeCredential {
label: string
name: string
version: number
inputs: INodeParams[]

constructor() {
this.label = 'Teradata TD2 Auth'
this.name = 'teradataTD2Auth'
this.version = 1.0
this.inputs = [
{
label: 'Teradata TD2 Auth Username',
name: 'tdUsername',
type: 'string'
},
{
label: 'Teradata TD2 Auth Password',
name: 'tdPassword',
type: 'password'
}
]
}
}

module.exports = { credClass: TeradataTD2Credential }
133 changes: 133 additions & 0 deletions packages/components/nodes/tools/MCP/Teradata/TeradataMCP.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
import { Tool } from '@langchain/core/tools'
import { ICommonObject, INode, INodeData, INodeOptionsValue, INodeParams } from '../../../../src/Interface'
import { getCredentialData, getCredentialParam } from '../../../../src/utils'
import { MCPToolkit } from '../core'

class Teradata_MCP implements INode {
label: string
name: string
version: number
description: string
type: string
icon: string
category: string
baseClasses: string[]
documentation: string
credential: INodeParams
inputs: INodeParams[]

constructor() {
this.label = 'Teradata MCP'
this.name = 'teradataMCP'
this.version = 1.0
this.type = 'Teradata MCP Tool'
this.icon = 'teradata.svg'
this.category = 'Tools (MCP)'
this.description = 'MCP Server for Teradata (remote HTTP streamable)'
this.documentation = 'https://github.com/Teradata/teradata-mcp-server'
this.credential = {
label: 'Connect Credential',
name: 'credential',
type: 'credential',
credentialNames: ['teradataTD2Auth', 'teradataBearerToken'],
description: 'Needed when using Teradata MCP server with authentication'
}
this.inputs = [
{
label: 'MCP Server URL',
name: 'mcpUrl',
type: 'string',
placeholder: 'https://your-mcp-server-url/mcp/',
description: 'URL of your Teradata MCP server',
optional: false
},
{
label: 'Bearer Token',
name: 'bearerToken',
type: 'string',
optional: true,
description: 'Optional to override Default set credentials'
},
{
label: 'Available Actions',
name: 'mcpActions',
type: 'asyncMultiOptions',
loadMethod: 'listActions',
refresh: true
}
]
this.baseClasses = ['Tool']
}

//@ts-ignore
loadMethods = {
listActions: async (nodeData: INodeData, options: ICommonObject): Promise<INodeOptionsValue[]> => {
try {
const toolset = await this.getTools(nodeData, options)
toolset.sort((a: any, b: any) => a.name.localeCompare(b.name))
return toolset.map(({ name, ...rest }) => ({
label: name.toUpperCase(),
name: name,
description: rest.description || name
}))
} catch (error) {
console.error('Error listing actions:', error)
return [
{
label: 'No Available Actions',
name: 'error',
description: 'No available actions, please check your MCP server URL and credentials, then refresh.'
}
]
}
}
}

async init(nodeData: INodeData, _: string, options: ICommonObject): Promise<any> {
const tools = await this.getTools(nodeData, options)
const _mcpActions = nodeData.inputs?.mcpActions
let mcpActions = []
if (_mcpActions) {
try {
mcpActions = typeof _mcpActions === 'string' ? JSON.parse(_mcpActions) : _mcpActions
} catch (error) {
console.error('Error parsing mcp actions:', error)
}
}
return tools.filter((tool: any) => mcpActions.includes(tool.name))
}

async getTools(nodeData: INodeData, options: ICommonObject): Promise<Tool[]> {
const credentialData = await getCredentialData(nodeData.credential ?? '', options)
const mcpUrl = nodeData.inputs?.mcpUrl
if (!mcpUrl) {
throw new Error('Missing MCP Server URL')
}

// Determine auth method from credentials
let serverParams: any = {
url: mcpUrl,
headers: {}
}
// Get Bearer token from node input (from agent flow) or credential store
const bearerToken = nodeData.inputs?.bearerToken || getCredentialParam('token', credentialData, nodeData)
const username = getCredentialParam('tdUsername', credentialData, nodeData)
const password = getCredentialParam('tdPassword', credentialData, nodeData)

if (bearerToken) {
serverParams.headers['Authorization'] = `Bearer ${bearerToken}`
} else if (username && password) {
serverParams.headers['Authorization'] = 'Basic ' + Buffer.from(`${username}:${password}`).toString('base64')
} else {
throw new Error('Missing credentials: provide Bearer token from flow/credentials OR username/password from credentials')
}

// Use SSE for remote HTTP MCP servers
const toolkit = new MCPToolkit(serverParams, 'sse')
await toolkit.initialize()
const tools = toolkit.tools ?? []
return tools as Tool[]
}
}

module.exports = { nodeClass: Teradata_MCP }
1 change: 1 addition & 0 deletions packages/components/nodes/tools/MCP/Teradata/teradata.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.