We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/lbeatu/slack-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server
dependencies.ts•3.19 kB
import { SlackService } from "../application/services/slack.service.js";
import { GetChannelHistoryUseCase } from "../application/usecases/get-channel-history.usecase.js";
import { ListChannelsUseCase } from "../application/usecases/list-channels.usecase.js";
import { PostMessageUseCase } from "../application/usecases/post-message.usecase.js";
import { SlackClient } from "../infrastructure/clients/slack.client.js";
import { InMemoryStorage } from "../infrastructure/storage/memory.storage.js";
export class Dependencies {
public readonly cacheStorage = new InMemoryStorage(30); // 30 minutes cache
private _slackClient?: SlackClient;
private _slackService?: SlackService;
private _listChannelsUseCase?: ListChannelsUseCase;
private _postMessageUseCase?: PostMessageUseCase;
private _getChannelHistoryUseCase?: GetChannelHistoryUseCase;
private _isInitialized = false;
constructor() {
// Services will be initialized when token is available
}
// Initialize services with token from MCP server
public async initializeWithToken(token: string): Promise<boolean> {
if (!token || token === "xoxb-dummy-token-for-development") {
return false;
}
try {
// Initialize services
this._slackClient = new SlackClient(token);
this._slackService = new SlackService(
this._slackClient,
this.cacheStorage
);
this._listChannelsUseCase = new ListChannelsUseCase(this._slackService);
this._postMessageUseCase = new PostMessageUseCase(this._slackService);
this._getChannelHistoryUseCase = new GetChannelHistoryUseCase(
this._slackService
);
this._isInitialized = true;
return true;
} catch (error) {
return false;
}
}
// Getters with initialization check
public get slackClient(): SlackClient {
if (!this._slackClient || !this._isInitialized) {
throw new Error(
"Slack services not initialized. Please provide a valid token."
);
}
return this._slackClient;
}
public get slackService(): SlackService {
if (!this._slackService || !this._isInitialized) {
throw new Error(
"Slack services not initialized. Please provide a valid token."
);
}
return this._slackService;
}
public get listChannelsUseCase(): ListChannelsUseCase {
if (!this._listChannelsUseCase || !this._isInitialized) {
throw new Error(
"Slack services not initialized. Please provide a valid token."
);
}
return this._listChannelsUseCase;
}
public get postMessageUseCase(): PostMessageUseCase {
if (!this._postMessageUseCase || !this._isInitialized) {
throw new Error(
"Slack services not initialized. Please provide a valid token."
);
}
return this._postMessageUseCase;
}
public get getChannelHistoryUseCase(): GetChannelHistoryUseCase {
if (!this._getChannelHistoryUseCase || !this._isInitialized) {
throw new Error(
"Slack services not initialized. Please provide a valid token."
);
}
return this._getChannelHistoryUseCase;
}
public get isInitialized(): boolean {
return this._isInitialized;
}
}