@microsoft/powerbi-modeling-mcp 0.5.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (5) hide show
  1. package/CHANGELOG.md +131 -0
  2. package/LICENSE +99 -0
  3. package/README.md +120 -0
  4. package/index.js +146 -0
  5. package/package.json +48 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,131 @@
1
+ # CHANGELOG 📝
2
+
3
+ The Power BI Modeling MCP Server is a multiplatform application that updates automatically in internal flows. Updates will be released periodically.
4
+
5
+ ## [0.5.0-beta.2] - 2026-03-27 - Pre-release
6
+
7
+ ### Features
8
+
9
+ - *(npm)* Add NPM package release
10
+
11
+ ### Fixes
12
+
13
+ - Minor fixes and stability improvements
14
+
15
+ ### Other Changes
16
+
17
+ - Add agentic infrastructure documentation
18
+ - *(security)* Update .NET SDK version to 8.0.504 for bug #2030536
19
+ - *(security)* Update .NET SDK version to 8.0.419 for bug #2030536
20
+
21
+ ## [0.5.0-beta.1] - 2026-03-13 - Pre-release
22
+
23
+ ### Features
24
+
25
+ - Support for the `authmode` parameter for service principal authentication.
26
+
27
+ ### Fixes
28
+
29
+ - `IndexOutOfRangeException` when connecting to Analysis Services.
30
+ - Execution metrics are now preserved on successful DAX execution.
31
+ - Improved error message when setting `sortByColumn` on a column where `isAvailableInMdx = false`.
32
+ - Improved Analysis Services connection stability and reconnection handling.
33
+
34
+ ## [0.4.0] - 2026-03-04
35
+
36
+ ### Features
37
+
38
+ - Token consumption optimization
39
+
40
+ ## [0.3.2] - 2026-03-02 - Pre-release
41
+
42
+ ### Features
43
+
44
+ - Linux platform support
45
+ - Token consumption optimization
46
+
47
+ ### Fixes
48
+
49
+ - Minor fixes and stability improvements
50
+
51
+ ## [0.2.3] - 2026-01-09 - Pre-release
52
+
53
+ ### Fixes
54
+
55
+ - Minor fixes and stability improvements.
56
+ - Deadlock issue resolved in table_operations GET
57
+
58
+ ## [0.2.2] - 2025-12-16 - Pre-release
59
+
60
+ ### Features
61
+
62
+ - Support batch operations natively in all tools and removal of batch_* tools
63
+ - Load MCP server on startup
64
+
65
+ ### Fixes
66
+
67
+ - Minor fixes and stability improvements.
68
+
69
+ ## [0.1.9] - 2025-11-21
70
+
71
+ ### Features
72
+
73
+ - Support for ARM based processors
74
+
75
+ ### Fixes
76
+
77
+ - Bug fixes: connection name issue, null-ref dropping tables and others
78
+
79
+ ## [0.1.8] - 2025-11-18
80
+
81
+ ### Other Changes
82
+
83
+ - Documentation updates
84
+
85
+ ## [0.1.7] - 2025-11-18
86
+
87
+ ### Features
88
+
89
+ - Automatic connection names
90
+ - Execution metrics option when running DAX queries
91
+
92
+ ### Fixes
93
+
94
+ - Minor fixes and stability improvements.
95
+
96
+ ### Other Changes
97
+
98
+ - Tool description updates
99
+
100
+ ## [0.1.5]
101
+
102
+ ### Features
103
+
104
+ - DAX query execution metrics
105
+ - User confirmation before running DAX queries
106
+
107
+ ### Fixes
108
+
109
+ - Minor fixes and stability improvements.
110
+
111
+ ### Other Changes
112
+
113
+ - Optimization to trace operations
114
+
115
+ ## [0.1.1]
116
+
117
+ ### Features
118
+
119
+ - MCP prompts to facilitate connections: /ConnectToPowerBIDesktop; /ConnectToFabric; /ConnectToPowerBIProject
120
+ - Support for Direct Lake entity partitions
121
+ - Trace operations
122
+
123
+ ### Fixes
124
+
125
+ - Minor fixes and stability improvements.
126
+
127
+ ## [0.1.0]
128
+
129
+ ### Features
130
+
131
+ - Initial release
package/LICENSE ADDED
@@ -0,0 +1,99 @@
1
+ # MICROSOFT SOFTWARE LICENSE TERMS
2
+
3
+ **Power BI Modeling MCP Server (PREVIEW)**
4
+
5
+ These license terms are an agreement between you and Microsoft Corporation (or one of its affiliates). They apply to the software named above and any Microsoft services or software updates (except to the extent such services or updates are accompanied by new or additional terms, in which case those different terms apply prospectively and do not alter your or Microsoftís rights relating to pre-updated software or services). IF YOU COMPLY WITH THESE LICENSE TERMS, YOU HAVE THE RIGHTS BELOW. BY USING THE SOFTWARE, YOU ACCEPT THESE TERMS.
6
+
7
+ **INSTALLATION AND USE RIGHTS.**
8
+
9
+ **a) General.** You may install and use any number of copies of the software on your devices, solely to demonstrate, and for your internal business purposes to develop and test your applications. You may not use the software in a live operating environment unless Microsoft permits you to do so under another agreement.
10
+
11
+ **b) Work or School Accounts.** You can sign into the software with a work or school email address. If you do, you agree that the owner of the domain associated with your email address may control and administer your account, and access and process your data, including the contents of your communications and files. You further agree that your use of the software may be subject to: i) your organizationís guidelines and policies regarding the use of the software; and ii) the agreements Microsoft has with you or your organization, and in such case these terms may not apply. If you already have a Microsoft account and you use a separate work or school email address to access the software, you may be prompted to update the email address associated with your Microsoft account to continue accessing the software.
12
+
13
+ **c) Included Microsoft Applications.** The software may include other Microsoft applications. These license terms apply to those included applications, if any, unless other license terms are provided with the other Microsoft applications.
14
+
15
+ **d) Competitive Benchmarking.** If you are a direct competitor, and you access or use the software for purposes of competitive benchmarking, analysis, or intelligence gathering, you waive as against Microsoft, its subsidiaries, and its affiliated companies (including prospectively) any competitive use, access, and benchmarking test restrictions in the terms governing your software to the extent your terms of use are, or purport to be, more restrictive than Microsoftís terms. If you do not waive any such purported restrictions in the terms governing your software, you are not allowed to access or use this software, and will not do so.
16
+
17
+ **TIME-SENSITIVE SOFTWARE.**
18
+
19
+ **a) Period.** This agreement is effective on your acceptance and terminates on the earlier of (i) 30 days following first availability of a commercial release of the software or (ii) upon termination by Microsoft. Microsoft may extend this agreement in its discretion.
20
+
21
+ **b) Notice.** You may receive periodic reminder notices of this date through the software.
22
+
23
+ **c) Access to data.** You may not be able to access data used in the software when it stops running.
24
+
25
+ **SCOPE OF LICENSE.** The software is licensed, not sold. Microsoft reserves all other rights. Unless applicable law gives you more rights despite this limitation, you will not (and have no right to):
26
+
27
+ a) work around any technical limitations in the software that only allow you to use it in certain ways;
28
+
29
+ b) reverse engineer, decompile or disassemble the software, or otherwise attempt to derive the source code for the software, except and to the extent required by third party licensing terms governing use of certain open source components that may be included in the software;
30
+
31
+ c) remove, minimize, block, or modify any notices of Microsoft or its suppliers in the software;
32
+
33
+ d) use the software in any way that is against the law or to create or propagate malware; or
34
+
35
+ e) share, publish, distribute, or lease the software, provide the software as a stand-alone offering for others to use, or transfer the software or this agreement to any third party.
36
+
37
+ **PRE-RELEASE SOFTWARE.** The software is a pre-release version. It may not operate correctly. It may be different from the commercially released version.
38
+
39
+ **FEEDBACK.** If you give feedback about the software to Microsoft, you give to Microsoft, without charge, the right to use, share and commercialize your feedback in any way and for any purpose. You will not give feedback that is subject to a license that requires Microsoft to license its software or documentation to third parties because Microsoft includes your feedback in them. These rights survive this agreement.
40
+
41
+ **DATA.**
42
+
43
+ **a) Data Collection.** The software may collect information about you and your use of the software, and send that to Microsoft. Microsoft may use this information to provide services and improve our products and services. You may opt-out of many of these scenarios, but not all, as described in the product documentation.† There are also some features in the software that may enable you to collect data from users of your applications. If you use these features to enable data collection in your applications, you must comply with applicable law, including providing appropriate notices to users of your applications. You can learn more about data collection and use in the help documentation and the privacy statement at https://go.microsoft.com/fwlink/?linkid=521839. Your use of the software operates as your consent to these practices.
44
+
45
+ **b) Processing of Personal Data.** To the extent Microsoft is a processor or subprocessor of personal data in connection with the software, Microsoft makes the commitments in the European Union General Data Protection Regulation Terms of the Microsoft Products and Services Data Protection Addendum to all customers effective May 25, 2018, at https://go.microsoft.com/fwlink/?linkid=2135030.
46
+
47
+ **EXPORT RESTRICTIONS.** You must comply with all domestic and international export laws and regulations that apply to the software, which include restrictions on destinations, end users, and end use. For further information on export restrictions, visit https://aka.ms/exporting.
48
+
49
+ **SUPPORT SERVICES.** Microsoft is not obligated under this agreement to provide any support services for the software. Any support provided is ìas isî, ìwith all faultsî, and without warranty of any kind.
50
+
51
+ **UPDATES.** The software may periodically check for updates, and download and install them for you. You may obtain updates only from Microsoft or authorized sources. Microsoft may need to update your system to provide you with updates. You agree to receive these automatic updates without any additional notice. Updates may not include or support all existing software features, services, or peripheral devices.
52
+
53
+ **TERMINATION.** Without prejudice to any other rights, Microsoft may terminate this agreement if you fail to comply with any of its terms or conditions. In such event, you must destroy all copies of the software and all of its component parts.
54
+
55
+ **ENTIRE AGREEMENT.** This agreement, and any other terms Microsoft may provide for supplements, updates, or third-party applications, is the entire agreement for the software.
56
+
57
+ **APPLICABLE LAW AND PLACE TO RESOLVE DISPUTES.** If you acquired the software in the United States or Canada, the laws of the state or province where you live (or, if a business, where your principal place of business is located) govern the interpretation of this agreement, claims for its breach, and all other claims (including consumer protection, unfair competition, and tort claims), regardless of conflict of laws principles. If you acquired the software in any other country, its laws apply. If U.S. federal jurisdiction exists, you and Microsoft consent to exclusive jurisdiction and venue in the federal court in King County, Washington for all disputes heard in court. If not, you and Microsoft consent to exclusive jurisdiction and venue in the Superior Court of King County, Washington for all disputes heard in court.
58
+
59
+ **CONSUMER RIGHTS; REGIONAL VARIATIONS.** This agreement describes certain legal rights. You may have other rights, including consumer rights, under the laws of your state, province, or country. Separate and apart from your relationship with Microsoft, you may also have rights with respect to the party from which you acquired the software. This agreement does not change those other rights if the laws of your state, province, or country do not permit it to do so. For example, if you acquired the software in one of the below regions, or mandatory country law applies, then the following provisions apply to you:
60
+
61
+ **a) Australia.** You have statutory guarantees under the Australian Consumer Law and nothing in this agreement is intended to affect those rights.
62
+
63
+ **b) Canada.** If you acquired this software in Canada, you may stop receiving updates by turning off the automatic update feature, disconnecting your device from the Internet (if and when you re-connect to the Internet, however, the software will resume checking for and installing updates), or uninstalling the software. The product documentation, if any, may also specify how to turn off updates for your specific device or software.
64
+
65
+ **c) Germany and Austria.** i. Warranty. The properly licensed software will perform substantially as described in any Microsoft materials that accompany the software. However, Microsoft gives no contractual guarantee in relation to the licensed software. ii. Limitation of Liability. In case of intentional conduct, gross negligence, claims based on the Product Liability Act, as well as, in case of death or personal or physical injury, Microsoft is liable according to the statutory law.
66
+
67
+ Subject to the foregoing clause ii., Microsoft will only be liable for slight negligence if Microsoft is in breach of such material contractual obligations, the fulfillment of which facilitate the due performance of this agreement, the breach of which would endanger the purpose of this agreement and the compliance with which a party may constantly trust in (so-called "cardinal obligations"). In other cases of slight negligence, Microsoft will not be liable for slight negligence.
68
+
69
+ **DISCLAIMER OF WARRANTY. THE SOFTWARE IS LICENSED ìAS IS.î YOU BEAR THE RISK OF USING IT. MICROSOFT GIVES NO EXPRESS WARRANTIES, GUARANTEES, OR CONDITIONS. TO THE EXTENT PERMITTED UNDER APPLICABLE LAWS, MICROSOFT EXCLUDES ALL IMPLIED WARRANTIES, INCLUDING MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.**
70
+
71
+ **LIMITATION ON AND EXCLUSION OF DAMAGES. IF YOU HAVE ANY BASIS FOR RECOVERING DAMAGES DESPITE THE PRECEDING DISCLAIMER OF WARRANTY, YOU CAN RECOVER FROM MICROSOFT AND ITS SUPPLIERS ONLY DIRECT DAMAGES UP TO U.S. $5.00. YOU CANNOT RECOVER ANY OTHER DAMAGES, INCLUDING CONSEQUENTIAL, LOST PROFITS, SPECIAL, INDIRECT OR INCIDENTAL DAMAGES.**
72
+
73
+ **This limitation applies to (a) anything related to the software, services, content (including code) on third party Internet sites, or third party applications; and (b) claims for breach of contract, warranty, guarantee, or condition; strict liability, negligence, or other tort; or any other claim; in each case to the extent permitted by applicable law.**
74
+
75
+ **It also applies even if Microsoft knew or should have known about the possibility of the damages. The above limitation or exclusion may not apply to you because your state, province, or country may not allow the exclusion or limitation of incidental, consequential, or other damages.**
76
+
77
+ **CONFIDENTIAL INFORMATION.** The software, including its user interface, features and documentation, is confidential and proprietary to Microsoft and its suppliers.
78
+
79
+ **a) Use.** For five years after installation of the software or its commercial release, whichever is first, you may not disclose confidential information to third parties. You may disclose confidential information only to your employees and consultants who need to know the information. You must have written agreements with them that protect the confidential information at least as much as this agreement.
80
+
81
+ **b) Survival.** Your duty to protect confidential information survives this agreement.
82
+
83
+ **c) Exclusions.** You may disclose confidential information in response to a judicial or governmental order. You must first give written notice to Microsoft to allow it to seek a protective order or otherwise protect the information. Confidential information does not include information that: i. becomes publicly known through no wrongful act; ii. you received from a third party who did not breach confidentiality obligations to Microsoft or its suppliers; or iii. you developed independently.
84
+
85
+ **Please note: As this software is distributed in Canada, some of the clauses in this agreement are provided below in French.**
86
+
87
+ **Remarque: Ce logiciel Ètant distribuÈ au Canada, certaines des clauses dans ce contrat sont fournies ci-dessous en français.**
88
+
89
+ **EXONERATION DE GARANTIE. Le logiciel visÈ par une licence est offert ´ tel quel ª. Toute utilisation de ce logiciel est ‡ votre seule risque et pÈril. Microsoft níaccorde aucune autre garantie expresse. Vous pouvez bÈnÈficier de droits additionnels en vertu du droit local sur la protection des consommateurs, que ce contrat ne peut modifier. La ou elles sont permises par le droit locale, les garanties implicites de qualitÈ marchande, díadÈquation ‡ un usage particulier et díabsence de contrefaÁon sont exclues.**
90
+
91
+ **LIMITATION DES DOMMAGES-INT…R TS ET EXCLUSION DE RESPONSABILIT… POUR LES DOMMAGES. Vous pouvez obtenir de Microsoft et de ses fournisseurs une indemnisation en cas de dommages directs uniquement ‡ hauteur de 5,00 $ US. Vous ne pouvez prÈtendre ‡ aucune indemnisation pour les autres dommages, y compris les dommages spÈciaux, indirects ou accessoires et pertes de bÈnÈfices.**
92
+
93
+ **Cette limitation concerne:**
94
+
95
+ **tout ce qui est reliÈ au logiciel, aux services ou au contenu (y compris le code) figurant sur des sites Internet tiers ou dans des programmes tiers; et
96
+ les rÈclamations au titre de violation de contrat ou de garantie, ou au titre de responsabilitÈ stricte, de nÈgligence ou díune autre faute dans la limite autorisÈe par la loi en vigueur.**
97
+ **Elle síapplique Ègalement, mÍme si Microsoft connaissait ou devrait connaÓtre líÈventualitÈ díun tel dommage. Si votre pays níautorise pas líexclusion ou la limitation de responsabilitÈ pour les dommages indirects, accessoires ou de quelque nature que ce soit, il se peut que la limitation ou líexclusion ci-dessus ne síappliquera pas ‡ votre Ègard.**
98
+
99
+ **EFFET JURIDIQUE. Le prÈsent contrat dÈcrit certains droits juridiques. Vous pourriez avoir díautres droits prÈvus par les lois de votre pays. Le prÈsent contrat ne modifie pas les droits que vous confËrent les lois de votre pays si celles-ci ne le permettent pas.**
package/README.md ADDED
@@ -0,0 +1,120 @@
1
+ # ✨ Power BI Modeling MCP Server NPM Package
2
+
3
+ The **Power BI Modeling MCP Server** brings Power BI semantic modeling capabilities to your AI agents through a **local MCP server**. This allows developers and AI applications to interact with Power BI models in entirely new ways, from using natural language to execute modeling changes to autonomous AI agentic development workflows.
4
+
5
+ ## 💡 What can you do?
6
+
7
+ - **🔄 Build and Modify Semantic Models with Natural Language** - Tell your AI assistant what you need, and it uses this MCP server to create, update, and manage tables, columns, measures, relationships, and more... across Power BI Desktop and Fabric semantic models.
8
+
9
+ - **⚡ Bulk Operations at Scale** - AI applications can execute batch modeling operations on hundreds of objects simultaneously — bulk renaming, bulk refactoring, model translations, or model security rules - with transaction support and error handling, turning hours of repetitive work into seconds.
10
+
11
+ - **✅ Apply modeling best practices** - Easily evaluate and implement modeling best practices against your model.
12
+
13
+ - **🤖 Agentic Development Workflows** - Supports working with [TMDL and Power BI Project files](https://learn.microsoft.com/power-bi/developer/projects/projects-dataset#tmdl-format), enabling AI agents to autonomously plan, create, and execute complex modeling tasks across your semantic model codebase.
14
+
15
+ - **🔍 Query and Validate DAX** - AI assistants can execute and validate DAX queries against your model, helping you test measures, troubleshoot calculations, and explore your data
16
+
17
+ 📹 Watch the video for an [end-to-end demo](https://aka.ms/power-modeling-mcp-demo).
18
+
19
+ More details on how to use and configure this MCP are available in the GitHub repository: [powerbi-modeling-mcp](https://aka.ms/powerbi-modeling-mcp).
20
+
21
+ ## 📋 Prerequisites
22
+
23
+ Before getting started, ensure you have **Node.js** (which includes NPM and NPX) installed:
24
+
25
+ - **Node.js 18+** - [Download from nodejs.org](https://nodejs.org/)
26
+
27
+ You can verify your installation by running:
28
+
29
+ ```bash
30
+ node --version
31
+ npm --version
32
+ ```
33
+
34
+ ## 📦 Installation
35
+
36
+ Configure the `mcp.json` file with the following:
37
+
38
+ ```json
39
+ {
40
+ "mcpServers": {
41
+ "powerbi-modeling-mcp": {
42
+ "type": "local",
43
+ "command": "npx",
44
+ "args": [
45
+ "-y",
46
+ "@microsoft/powerbi-modeling-mcp",
47
+ "--start",
48
+ ]
49
+ }
50
+ }
51
+ }
52
+ ```
53
+
54
+ **Note:** When manually configuring Visual Studio and Visual Studio Code, use `servers` instead of `mcpServers` as the root object.
55
+
56
+ ## 🚀 Get started
57
+
58
+ **First, you must connect to a Power BI semantic model**, which can reside in Power BI Desktop, Fabric workspace or in Power BI Project (PBIP) files.
59
+
60
+ - **For Power BI Desktop:**
61
+
62
+ ```
63
+ Connect to '[File Name]' in Power BI Desktop
64
+ ```
65
+
66
+ - **For Semantic Model in Fabric Workspace:**
67
+
68
+ ```
69
+ Connect to semantic model '[Semantic Model Name]' in Fabric Workspace '[Workspace Name]'
70
+ ```
71
+
72
+ - **For Power BI Project files:**
73
+
74
+ ```
75
+ Open semantic model from PBIP folder '[Path to the definition/ TMDL folder in the PBIP]'
76
+ ```
77
+
78
+ Once the connection is established, you can use natural language to ask the AI agent to make any modeling changes. To get started, try one of the following scenarios.
79
+
80
+ ## 💬 Feedback and Support
81
+
82
+ - Check the [Troubleshooting guide](https://github.com/microsoft/powerbi-modeling-mcp/blob/main/TROUBLESHOOTING.md) to diagnose and resolve common issues.
83
+ - We're building this in the open. Your feedback is much appreciated, and will help us shape the future of the Power BI Modeling MCP server.
84
+ - 👉 [Open an issue](https://github.com/microsoft/powerbi-modeling-mcp/issues) in the public GitHub repository - we’d love to hear from you!
85
+
86
+ ## Security
87
+
88
+ Your credentials are always handled securely through the official [Azure Identity SDK](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/identity/Azure.Identity/README.md) - **we never store or manage tokens directly**.
89
+
90
+ MCP as a phenomenon is very novel and cutting-edge. As with all new technology standards, consider doing a security review to ensure any systems that integrate with MCP servers follow all regulations and standards your system is expected to adhere to. This includes not only the Power BI Modeling MCP Server, but any MCP client/agent that you choose to implement down to the model provider.
91
+
92
+ You should follow Microsoft security guidance for MCP servers, including enabling Entra ID authentication, secure token management, and network isolation. Refer to [Microsoft Security Documentation](https://learn.microsoft.com/en-us/azure/api-management/secure-mcp-servers) for details.
93
+
94
+ ## Permissions and Risk
95
+
96
+ MCP clients can invoke operations based on the user’s Fabric RBAC permissions. Autonomous or misconfigured clients may perform destructive actions. You should review and apply least-privilege RBAC roles and implement safeguards before deployment. Certain safeguards, such as flags to prevent destructive operations, are not standardized in the MCP specification and may not be supported by all clients.
97
+
98
+ ## Data Collection
99
+
100
+ The software may collect information about you and your use of the software and send it to Microsoft. Microsoft may use this information to provide services and improve our products and services. There are also some features in the software that may enable you and Microsoft to collect data from users of your applications. If you use these features, you must comply with applicable law, including providing appropriate notices to users of your applications together with a copy of Microsoft's [privacy statement](https://www.microsoft.com/privacy/privacystatement). You can learn more about data collection and use in the help documentation and our privacy statement. Your use of the software operates as your consent to these practices.
101
+
102
+ ## Compliance Responsibility
103
+
104
+ This MCP server may be installed, used and share data with third party clients and services, such as third party LLMs that operate outside Microsoft compliance boundaries. You are responsible for ensuring that any integration complies with applicable organizational, regulatory, and contractual requirements.
105
+
106
+ ## Third Party Components
107
+
108
+ This MCP server may use or depend on third party components. You are responsible for reviewing and complying with the licenses and security posture of any third-party components.
109
+
110
+ ## Export Control
111
+
112
+ Use of this software must comply with all applicable export laws and regulations, including U.S. Export Administration Regulations and local jurisdiction requirements.
113
+
114
+ ## No Warranty / Limitation of Liability
115
+
116
+ This software is provided “as is” without warranties or conditions of any kind, either express or implied. Microsoft shall not be liable for any damages arising from use, misuse, or misconfiguration of this software.
117
+
118
+ ## Code of Conduct
119
+
120
+ This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information, see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [open@microsoft.com](mailto:open@microsoft.com) with any additional questions or comments.
package/index.js ADDED
@@ -0,0 +1,146 @@
1
+ #!/usr/bin/env node
2
+ // -----------------------------------------------------------------------
3
+ // <copyright company="Microsoft Corporation">
4
+ // copyright (c) Microsoft Corporation. All rights reserved.
5
+ // </copyright>
6
+ // -----------------------------------------------------------------------
7
+
8
+ const os = require('os')
9
+ const packageJson = require('./package.json')
10
+ const { get } = require('http')
11
+
12
+ // Check if DEBUG environment variable is set
13
+ const isDebugMode = process.env.DEBUG && (
14
+ process.env.DEBUG.toLowerCase() === 'true' ||
15
+ process.env.DEBUG.includes('mcp') ||
16
+ process.env.DEBUG === '*'
17
+ )
18
+
19
+ // Helper function for debug logging
20
+ function debugLog(...args) {
21
+ if (isDebugMode) {
22
+ console.error(...args)
23
+ }
24
+ }
25
+
26
+ // Helper function to get command line argument value
27
+ const getArgument = (argName) => {
28
+ let argIndex = process.argv.indexOf(argName);
29
+ if (argIndex !== -1 && argIndex < process.argv.length - 1) {
30
+ return process.argv[argIndex + 1] || null;
31
+ }
32
+ return null;
33
+ }
34
+
35
+ const packageName = packageJson.name
36
+
37
+ // Check for --help argument
38
+ if (process.argv.includes('--help') || process.argv.includes('-h')) {
39
+ console.log(`
40
+ Usage: ${packageName} [options]
41
+
42
+ Options:
43
+ --help, -h Show this help message
44
+ --use-version Specify a specific version to use
45
+
46
+ Environment Variables:
47
+ DEBUG Enable debug logging (true, mcp, or *)
48
+
49
+ Examples:
50
+ ${packageName} --help
51
+ ${packageName} --use-version 1.0.0
52
+ DEBUG=true ${packageName}
53
+ `)
54
+ process.exit(0)
55
+ }
56
+
57
+ debugLog('PowerBI Modeling MCP core package starting')
58
+ debugLog('All args:')
59
+ process.argv.forEach((val, index) => {
60
+ debugLog(`${index}: ${val}`)
61
+ })
62
+
63
+ const platform = os.platform()
64
+ const arch = os.arch()
65
+
66
+ const version = getArgument('--use-version') || packageJson.version || 'latest'
67
+ const platformPackageName = `${packageName}-${platform}-${arch}`
68
+
69
+ console.log(`Detected platform: ${platform}, architecture: ${arch}`)
70
+ console.log(`Using ${platformPackageName} version: ${version}`)
71
+
72
+ // Try to load the platform package
73
+ let platformPackage
74
+ try {
75
+ debugLog(`Attempting to require platform package: ${platformPackageName}`)
76
+ platformPackage = require(platformPackageName)
77
+ } catch (err) {
78
+ debugLog(`Failed to require ${platformPackageName}, attempting auto-install: ${err.message}`)
79
+
80
+ // Try to automatically install the missing platform package
81
+ try {
82
+ const { execSync } = require('child_process')
83
+
84
+ console.error(`Installing missing platform package: ${platformPackageName}`)
85
+
86
+ // Try to install the platform package
87
+ try {
88
+ execSync(`npm install ${platformPackageName}@${version}`, {
89
+ stdio: ['inherit', 'inherit', 'pipe'], // Only pipe stderr to capture errors
90
+ timeout: 60000 // 60 second timeout
91
+ })
92
+ } catch (npmErr) {
93
+ // If npm install fails, try with --no-save and different install strategies
94
+ debugLog(`npm install failed, trying alternative installation methods: ${npmErr.message}`)
95
+
96
+ // Try with --no-save and --prefer-online
97
+ execSync(`npm install ${platformPackageName}@${version} --no-save --prefer-online`, {
98
+ stdio: ['inherit', 'inherit', 'pipe'],
99
+ timeout: 60000
100
+ })
101
+ }
102
+
103
+ // Clear module cache and try to require again after installation
104
+ Object.keys(require.cache).forEach(key => {
105
+ if (key.includes(platformPackageName)) {
106
+ delete require.cache[key]
107
+ }
108
+ })
109
+
110
+ platformPackage = require(platformPackageName)
111
+
112
+ console.error(`✅ Successfully installed and loaded ${platformPackageName}`)
113
+
114
+ } catch (installErr) {
115
+ debugLog(`Auto-install failed: ${installErr.message}`)
116
+
117
+ console.error(`\n❌ Failed to load platform specific package '${platformPackageName}'`)
118
+ console.error(`\n🔍 Troubleshooting steps:`)
119
+ console.error(`\n1. Clear npm cache:`)
120
+ console.error(` npm cache clean --force`)
121
+ console.error(`\n2. If installing as a global tool, uninstall and reinstall:`)
122
+ console.error(` npm uninstall -g ${packageName}`)
123
+ console.error(` npm install -g ${packageName}`)
124
+ console.error(`\n3. If using npx, clear the npx cache and try again:`)
125
+ console.error(` npx -y clear-npx-cache`)
126
+ console.error(` npx -y ${packageName}@latest --version`)
127
+ console.error(`\n4. Manually install the platform package to check compatibility:`)
128
+ console.error(` npm install ${platformPackageName}@latest`)
129
+ console.error(`\n5. Check your internet connection and try again`)
130
+ console.error(`\n6. If the issue persists, please report it at:`)
131
+ console.error(` https://github.com/microsoft/mcp/issues`)
132
+ console.error(`\nOriginal error: ${err.message}`)
133
+ console.error(`Install error: ${installErr.message}`)
134
+ process.exit(1)
135
+ }
136
+ }
137
+
138
+ platformPackage.runExecutable(process.argv.slice(2))
139
+ .then((code) => {
140
+ debugLog(`Process exited with code: ${code}`)
141
+ process.exit(code)
142
+ })
143
+ .catch((err) => {
144
+ console.error(`Error: ${err.message}`)
145
+ process.exit(1)
146
+ })
package/package.json ADDED
@@ -0,0 +1,48 @@
1
+ {
2
+ "name": "@microsoft/powerbi-modeling-mcp",
3
+ "version": "0.5.0-beta.2",
4
+ "description": "Power BI Modeling MCP Server - Node.js client package for installing and running the Power BI Modeling MCP server",
5
+ "author": "Microsoft",
6
+ "homepage": "https://github.com/microsoft/powerbi-modeling-mcp#readme",
7
+ "license": "Microsoft",
8
+ "keywords": [
9
+ "powerbi",
10
+ "modeling",
11
+ "mcp",
12
+ "model-context-protocol",
13
+ "semantic-model",
14
+ "tabular",
15
+ "analysis-services"
16
+ ],
17
+ "bugs": {
18
+ "url": "https://github.com/microsoft/powerbi-modeling-mcp/issues"
19
+ },
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "git+https://github.com/microsoft/powerbi-modeling-mcp.git",
23
+ "directory": "clients/node"
24
+ },
25
+ "engines": {
26
+ "node": ">=18.0.0"
27
+ },
28
+ "bin": {
29
+ "powerbi-modeling-mcp": "./index.js"
30
+ },
31
+ "os": [
32
+ "win32",
33
+ "darwin",
34
+ "linux"
35
+ ],
36
+ "cpu": [
37
+ "x64",
38
+ "arm64"
39
+ ],
40
+ "optionalDependencies": {
41
+ "@microsoft/powerbi-modeling-mcp-linux-arm64": "0.5.0-beta.2",
42
+ "@microsoft/powerbi-modeling-mcp-win32-x64": "0.5.0-beta.2",
43
+ "@microsoft/powerbi-modeling-mcp-linux-x64": "0.5.0-beta.2",
44
+ "@microsoft/powerbi-modeling-mcp-win32-arm64": "0.5.0-beta.2",
45
+ "@microsoft/powerbi-modeling-mcp-darwin-arm64": "0.5.0-beta.2"
46
+ },
47
+ "mcpName": "powerbi-modeling-mcp"
48
+ }