Skip to content

Conversation

Copy link

Copilot AI commented Nov 10, 2025

🎯 Aim

Enable LLMs to retrieve scripting best practices when generating CLI for Microsoft 365 commands, improving script quality through contextual guidance on authentication, error handling, and output management.

📷 Result

N/A - Backend MCP tool addition

✅ What was done

  • Created best-practices.md with comprehensive scripting guidance
    • Authentication status checking patterns
    • Error handling for PowerShell (with helper function) and Bash/Zsh
    • Output handling (JSON/text/CSV) and parsing
    • Configuration recommendations for scripts
    • Security best practices and script templates
  • Added getBestPractices() utility function with multi-path resolution
  • Registered m365_get_best_practices MCP tool (no input parameters)
  • Updated README tools table

Usage example:

// LLM calls this tool when generating scripts
server.registerTool('m365_get_best_practices', {
  inputSchema: {}
}, async () => ({
  content: [{ type: 'text', text: await util.getBestPractices() }]
}));

🔗 Related issue

Closes: #103

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • pnp.github.io
    • Triggering command: curl -s REDACTED (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>💡 [Feature]: Add a tool that brings in best practices for using CLI for Microsoft 365</issue_title>
<issue_description>### 🎯 Aim of the feature

The idea is to add a tool that the LM could use when creating a script that uses CLI for Microsoft 365 commands. The LM could retrieve/get additional context with best practices how CLI for M365 commands should be used in a script like how to check auth, how to catch errors, how to handle output.

💡 idea

How we could go about it is add a new .MD file with best practices for using CLI for Microsoft 365 in a script file for PowerShell in this repo and then add a MCP tool that would fetch this .MD file from repo and use it as context for LLM.

The .MD guidance could base on information that is present on this page
https://pnp.github.io/cli-microsoft365/user-guide/using-cli

🤔 Additional remarks or comments

Something similar was already done in Azure MCP and Dev Proxy MCP so we could follow similar approach</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Add tool for best practices using CLI for Microsoft 365 Add best practices tool for CLI for Microsoft 365 scripting guidance Nov 10, 2025
Copilot AI requested a review from Adam-it November 10, 2025 19:05
Copilot finished work on behalf of Adam-it November 10, 2025 19:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

💡 [Feature]: Add a tool that brings in best practices for using CLI for Microsoft 365

2 participants