mirror of
https://github.com/modelcontextprotocol/servers.git
synced 2026-04-20 12:55:21 +02:00
Merge branch 'main' of https://github.com/modelcontextprotocol/servers into burkeholland-vscode-install-instructions
This commit is contained in:
@@ -114,8 +114,9 @@ export const createServer = () => {
|
||||
|
||||
let subscriptions: Set<string> = new Set();
|
||||
let subsUpdateInterval: NodeJS.Timeout | undefined;
|
||||
// Set up update interval for subscribed resources
|
||||
let stdErrUpdateInterval: NodeJS.Timeout | undefined;
|
||||
|
||||
// Set up update interval for subscribed resources
|
||||
subsUpdateInterval = setInterval(() => {
|
||||
for (const uri of subscriptions) {
|
||||
server.notification({
|
||||
@@ -123,7 +124,7 @@ export const createServer = () => {
|
||||
params: { uri },
|
||||
});
|
||||
}
|
||||
}, 5000);
|
||||
}, 10000);
|
||||
|
||||
let logLevel: LoggingLevel = "debug";
|
||||
let logsUpdateInterval: NodeJS.Timeout | undefined;
|
||||
@@ -152,7 +153,21 @@ export const createServer = () => {
|
||||
};
|
||||
if (!isMessageIgnored(message.params.level as LoggingLevel))
|
||||
server.notification(message);
|
||||
}, 15000);
|
||||
}, 20000);
|
||||
|
||||
|
||||
// Set up update interval for stderr messages
|
||||
stdErrUpdateInterval = setInterval(() => {
|
||||
const shortTimestamp = new Date().toLocaleTimeString([], {
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
second: '2-digit'
|
||||
});
|
||||
server.notification({
|
||||
method: "notifications/stderr",
|
||||
params: { content: `${shortTimestamp}: A stderr message` },
|
||||
});
|
||||
}, 30000);
|
||||
|
||||
// Helper method to request sampling from client
|
||||
const requestSampling = async (
|
||||
@@ -676,6 +691,7 @@ export const createServer = () => {
|
||||
const cleanup = async () => {
|
||||
if (subsUpdateInterval) clearInterval(subsUpdateInterval);
|
||||
if (logsUpdateInterval) clearInterval(logsUpdateInterval);
|
||||
if (stdErrUpdateInterval) clearInterval(stdErrUpdateInterval);
|
||||
};
|
||||
|
||||
return { server, cleanup };
|
||||
|
||||
@@ -5,7 +5,7 @@ MCP Server for the Slack API, enabling Claude to interact with Slack workspaces.
|
||||
## Tools
|
||||
|
||||
1. `slack_list_channels`
|
||||
- List public channels in the workspace
|
||||
- List public or pre-defined channels in the workspace
|
||||
- Optional inputs:
|
||||
- `limit` (number, default: 100, max: 200): Maximum number of channels to return
|
||||
- `cursor` (string): Pagination cursor for next page
|
||||
@@ -102,7 +102,8 @@ Add the following to your `claude_desktop_config.json`:
|
||||
],
|
||||
"env": {
|
||||
"SLACK_BOT_TOKEN": "xoxb-your-bot-token",
|
||||
"SLACK_TEAM_ID": "T01234567"
|
||||
"SLACK_TEAM_ID": "T01234567",
|
||||
"SLACK_CHANNEL_IDS": "C01234567, C76543210"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -124,11 +125,14 @@ Add the following to your `claude_desktop_config.json`:
|
||||
"SLACK_BOT_TOKEN",
|
||||
"-e",
|
||||
"SLACK_TEAM_ID",
|
||||
"-e",
|
||||
"SLACK_CHANNEL_IDS",
|
||||
"mcp/slack"
|
||||
],
|
||||
"env": {
|
||||
"SLACK_BOT_TOKEN": "xoxb-your-bot-token",
|
||||
"SLACK_TEAM_ID": "T01234567"
|
||||
"SLACK_TEAM_ID": "T01234567",
|
||||
"SLACK_CHANNEL_IDS": "C01234567, C76543210"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ interface GetUserProfileArgs {
|
||||
// Tool definitions
|
||||
const listChannelsTool: Tool = {
|
||||
name: "slack_list_channels",
|
||||
description: "List public channels in the workspace with pagination",
|
||||
description: "List public or pre-defined channels in the workspace with pagination",
|
||||
inputSchema: {
|
||||
type: "object",
|
||||
properties: {
|
||||
@@ -221,23 +221,51 @@ class SlackClient {
|
||||
}
|
||||
|
||||
async getChannels(limit: number = 100, cursor?: string): Promise<any> {
|
||||
const params = new URLSearchParams({
|
||||
types: "public_channel",
|
||||
exclude_archived: "true",
|
||||
limit: Math.min(limit, 200).toString(),
|
||||
team_id: process.env.SLACK_TEAM_ID!,
|
||||
});
|
||||
|
||||
if (cursor) {
|
||||
params.append("cursor", cursor);
|
||||
const predefinedChannelIds = process.env.SLACK_CHANNEL_IDS;
|
||||
if (!predefinedChannelIds) {
|
||||
const params = new URLSearchParams({
|
||||
types: "public_channel",
|
||||
exclude_archived: "true",
|
||||
limit: Math.min(limit, 200).toString(),
|
||||
team_id: process.env.SLACK_TEAM_ID!,
|
||||
});
|
||||
|
||||
if (cursor) {
|
||||
params.append("cursor", cursor);
|
||||
}
|
||||
|
||||
const response = await fetch(
|
||||
`https://slack.com/api/conversations.list?${params}`,
|
||||
{ headers: this.botHeaders },
|
||||
);
|
||||
|
||||
return response.json();
|
||||
}
|
||||
|
||||
const response = await fetch(
|
||||
`https://slack.com/api/conversations.list?${params}`,
|
||||
{ headers: this.botHeaders },
|
||||
);
|
||||
const predefinedChannelIdsArray = predefinedChannelIds.split(",").map((id: string) => id.trim());
|
||||
const channels = [];
|
||||
|
||||
return response.json();
|
||||
for (const channelId of predefinedChannelIdsArray) {
|
||||
const params = new URLSearchParams({
|
||||
channel: channelId,
|
||||
});
|
||||
|
||||
const response = await fetch(
|
||||
`https://slack.com/api/conversations.info?${params}`,
|
||||
{ headers: this.botHeaders }
|
||||
);
|
||||
const data = await response.json();
|
||||
|
||||
if (data.ok && data.channel && !data.channel.is_archived) {
|
||||
channels.push(data.channel);
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
ok: true,
|
||||
channels: channels,
|
||||
response_metadata: { next_cursor: "" },
|
||||
};
|
||||
}
|
||||
|
||||
async postMessage(channel_id: string, text: string): Promise<any> {
|
||||
|
||||
Reference in New Issue
Block a user