We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/software-engineer-mj/slack-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server
from conftest import make_slack_api_error
from slack_mcp.client import _handle_error
from slack_mcp.exceptions import (
SlackAPIError,
SlackAuthenticationError,
SlackMCPError,
SlackNotFoundError,
SlackPermissionError,
SlackRateLimitError,
)
class TestHandleError:
def test_rate_limit_error(self):
err = make_slack_api_error("rate_limited", status_code=429, headers={"Retry-After": "30"})
result = _handle_error(err)
assert isinstance(result, SlackRateLimitError)
assert result.retry_after == 30
assert "Rate limited" in str(result)
def test_rate_limit_by_status_code(self):
err = make_slack_api_error("too_many_requests", status_code=429, headers={"Retry-After": "10"})
result = _handle_error(err)
assert isinstance(result, SlackRateLimitError)
assert result.retry_after == 10
def test_authentication_errors(self):
for code in ["not_authed", "invalid_auth", "account_inactive", "token_revoked", "token_expired"]:
err = make_slack_api_error(code)
result = _handle_error(err)
assert isinstance(result, SlackAuthenticationError), f"Expected SlackAuthenticationError for {code}"
assert result.error_code == code
def test_permission_errors(self):
for code in ["missing_scope", "not_allowed", "no_permission"]:
err = make_slack_api_error(code)
result = _handle_error(err)
assert isinstance(result, SlackPermissionError), f"Expected SlackPermissionError for {code}"
assert result.error_code == code
def test_not_found_errors(self):
for code in ["channel_not_found", "user_not_found", "message_not_found"]:
err = make_slack_api_error(code)
result = _handle_error(err)
assert isinstance(result, SlackNotFoundError), f"Expected SlackNotFoundError for {code}"
assert result.error_code == code
def test_generic_error(self):
err = make_slack_api_error("some_other_error")
result = _handle_error(err)
assert isinstance(result, SlackAPIError)
assert not isinstance(result, SlackRateLimitError)
assert not isinstance(result, SlackPermissionError)
assert not isinstance(result, SlackNotFoundError)
assert result.error_code == "some_other_error"
class TestExceptionHierarchy:
def test_all_subclass_of_base(self):
assert issubclass(SlackAPIError, SlackMCPError)
assert issubclass(SlackAuthenticationError, SlackAPIError)
assert issubclass(SlackRateLimitError, SlackAPIError)
assert issubclass(SlackPermissionError, SlackAPIError)
assert issubclass(SlackNotFoundError, SlackAPIError)
def test_base_has_error_code(self):
err = SlackMCPError("test", error_code="test_code")
assert err.error_code == "test_code"
def test_api_error_has_status_code(self):
err = SlackAPIError("test", error_code="test_code", status_code=500)
assert err.status_code == 500
assert err.error_code == "test_code"
def test_authentication_error(self):
err = SlackAuthenticationError("auth failed", error_code="invalid_auth")
assert err.status_code == 401
assert err.error_code == "invalid_auth"
def test_rate_limit_has_retry_after(self):
err = SlackRateLimitError("rate limited", retry_after=60)
assert err.retry_after == 60
assert err.error_code == "rate_limited"
assert err.status_code == 429