-
Notifications
You must be signed in to change notification settings - Fork 26
feat(kafka-client): Allow for kafka client configuration to be passed through via CLI #41
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
#!/usr/bin/env node | ||
|
||
import { KafkaJS } from "@confluentinc/kafka-javascript"; | ||
import { GlobalConfig } from "@confluentinc/kafka-javascript"; | ||
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; | ||
import { | ||
getFilteredToolNames, | ||
|
@@ -13,7 +13,7 @@ import { ToolFactory } from "@src/confluent/tools/tool-factory.js"; | |
import { ToolName } from "@src/confluent/tools/tool-name.js"; | ||
import { EnvVar } from "@src/env-schema.js"; | ||
import { initEnv } from "@src/env.js"; | ||
import { kafkaLogger, logger } from "@src/logger.js"; | ||
import { logger } from "@src/logger.js"; | ||
import { TransportManager } from "@src/mcp/transports/index.js"; | ||
|
||
// Parse command line arguments and load environment variables if --env-file is specified | ||
|
@@ -24,18 +24,24 @@ async function main() { | |
// Initialize environment after CLI args are processed | ||
const env = await initEnv(); | ||
|
||
const kafkaClientConfig: KafkaJS.CommonConstructorConfig = { | ||
kafkaJS: { | ||
brokers: env.BOOTSTRAP_SERVERS?.split(",") ?? [], | ||
clientId: "mcp-client", | ||
ssl: true, | ||
sasl: { | ||
mechanism: "plain", | ||
username: env.KAFKA_API_KEY!, | ||
password: env.KAFKA_API_SECRET!, | ||
}, | ||
logger: kafkaLogger, | ||
}, | ||
// Merge environment variables with kafka config from CLI | ||
// some additional configurations could be set in the client manager | ||
// like seperating groupIds by sessionId | ||
eddyv marked this conversation as resolved.
Show resolved
Hide resolved
|
||
const kafkaClientConfig: GlobalConfig = { | ||
// Base configuration from environment variables | ||
"bootstrap.servers": env.BOOTSTRAP_SERVERS!, | ||
"client.id": "mcp-client", | ||
"security.protocol": "plaintext", | ||
eddyv marked this conversation as resolved.
Show resolved
Hide resolved
|
||
...(env.KAFKA_API_KEY && env.KAFKA_API_SECRET | ||
? { | ||
"security.protocol": "sasl_ssl", | ||
"sasl.mechanisms": "PLAIN", | ||
"sasl.username": env.KAFKA_API_KEY!, | ||
"sasl.password": env.KAFKA_API_SECRET!, | ||
} | ||
: {}), | ||
// Merge any additional properties from the kafka config file | ||
...cliOptions.kafkaConfig, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider clarifying the precedence of configuration merging between environment variables and CLI-provided Kafka configuration; ensure that CLI settings are intended to override environment variables as designed. Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||
}; | ||
|
||
const clientManager = new DefaultClientManager({ | ||
|
Uh oh!
There was an error while loading. Please reload this page.