Coverage for src/mcp_atlassian/__init__.py: 43%

1 import asyncio

2 import logging

3 import os

4 import sys

5

6 import click

7 from dotenv import load_dotenv

8

9 __version__ = "0.1.14"

10

11 logger = logging.getLogger("mcp-atlassian")

12

13

14@click.command()

15@click.option("-v", "--verbose", count=True, help="Increase verbosity (can be used multiple times)")

16@click.option("--env-file", type=click.Path(exists=True, dir_okay=False), help="Path to .env file")

17@click.option("--confluence-url", help="Confluence URL (e.g., https://your-domain.atlassian.net/wiki)")

18@click.option("--confluence-username", help="Confluence username/email")

19@click.option("--confluence-token", help="Confluence API token")

20@click.option("--jira-url", help="Jira URL (e.g., https://your-domain.atlassian.net)")

21@click.option("--jira-username", help="Jira username/email")

22@click.option("--jira-token", help="Jira API token")

23 def main(

24 verbose: bool,

25 env_file: str | None,

26 confluence_url: str | None,

27 confluence_username: str | None,

28 confluence_token: str | None,

29 jira_url: str | None,

30 jira_username: str | None,

31 jira_token: str | None,

32) -> None:

33 """MCP Atlassian Server - Jira and Confluence functionality for MCP"""

34 # Configure logging based on verbosity

35 logging_level = logging.INFO

36 if verbose == 1:

37 logging_level = logging.INFO

38 elif verbose >= 2:

39 logging_level = logging.DEBUG

40

41 logging.basicConfig(level=logging_level, stream=sys.stderr)

42

43 # Load environment variables from file if specified, otherwise try default .env

44 if env_file:

45 logger.debug(f"Loading environment from file: {env_file}")

46 load_dotenv(env_file)

47 else:

48 logger.debug("Attempting to load environment from default .env file")

49 load_dotenv()

50

51 # Set environment variables from command line arguments if provided

52 if confluence_url:

53 os.environ["CONFLUENCE_URL"] = confluence_url

54 if confluence_username:

55 os.environ["CONFLUENCE_USERNAME"] = confluence_username

56 if confluence_token:

57 os.environ["CONFLUENCE_API_TOKEN"] = confluence_token

58 if jira_url:

59 os.environ["JIRA_URL"] = jira_url

60 if jira_username:

61 os.environ["JIRA_USERNAME"] = jira_username

62 if jira_token:

63 os.environ["JIRA_API_TOKEN"] = jira_token

64

65 from . import server

66

67 # Run the server

68 asyncio.run(server.main())

69

70

71 __all__ = ["main", "server", "__version__"]

72

73 if __name__ == "__main__":

74 main()