msforms-api
MCP server for Microsoft Forms automation, enabling AI agents to inspect forms, resolve branching, validate and submit answers, upload files, and manage response links.
README
msforms-api
AI-native Microsoft Forms automation for inspecting forms, resolving branching, validating answers, uploading files, submitting responses, and saving response links.
Use it as:
- MCP server for AI agents and editors — recommended for most users.
- Agent skill backed by the CLI for agents that can run shell commands.
- CLI for scripts and terminal workflows.
- TypeScript SDK for custom applications.
<img src="https://img.shields.io/badge/VS_Code-Install_Server-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white" alt="Install in VS Code">
<img src="https://img.shields.io/badge/VS_Code_Insiders-Install_Server-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white" alt="Install in VS Code Insiders">
[!NOTE] This project was generated by GitHub Copilot App using GPT-5.6 Sol with Extra High reasoning in Autopilot mode.
[!WARNING] This project uses reverse-engineered Microsoft Forms web APIs. Microsoft does not document or guarantee these endpoints. They can change without notice. This project is not affiliated with or endorsed by Microsoft.
Quick start
Prerequisites
- Node.js 22 or later.
- Google Chrome or Microsoft Edge. Playwright Chromium is installed automatically when neither is available.
Install as an agent skill
The CLI skill teaches agents how to inspect branching, prepare and validate answers, upload authorized files, and require explicit approval before submission:
npx -y skills add Maxim-Mazurok/msforms-api
The installer detects supported agents such as Claude Code, Cursor, GitHub Copilot, and Codex, then asks where to install the skill. Choose global scope to use it across projects.
The skill runs msforms-api through npx, so it does not require a global
package installation or MCP configuration. It is an alternative interface to
the MCP server; both use the same CLI and SDK behavior.
Install in an AI tool
Click an install badge above, or use this MCP configuration. For Cursor, save
it as ~/.cursor/mcp.json:
{
"mcpServers": {
"microsoft-forms": {
"command": "npx",
"args": ["-y", "-p", "msforms-api@latest", "msforms-api-mcp"]
}
}
}
On first use, ask your agent to authenticate Microsoft Forms. A browser opens for sign-in, then future operations reuse the persistent session.
Try:
Inspect this Microsoft Form and explain every question, validation, upload rule, and branch:
https://forms.cloud.microsoft/...
The agent can prepare and validate answers without submitting. Submission uses a separate destructive MCP tool and requires explicit confirmation.
<details> <summary><strong>VS Code CLI installation</strong></summary>
macOS / Linux:
code --add-mcp '{"name":"microsoft-forms","command":"npx","args":["-y","-p","msforms-api@latest","msforms-api-mcp"]}'
Windows PowerShell:
code --add-mcp '{"name":"microsoft-forms","command":"npx","args":["-y","-p","msforms-api@latest","msforms-api-mcp"]}'
</details>
<details> <summary><strong>Claude Desktop</strong></summary>
Add the MCP configuration above to claude_desktop_config.json.
</details>
<details> <summary><strong>Claude Code</strong></summary>
claude mcp add microsoft-forms -- npx -y -p msforms-api@latest msforms-api-mcp
</details>
<details> <summary><strong>Windsurf and other MCP clients</strong></summary>
Add the MCP configuration above to your client's MCP configuration file.
</details>
What agents can do
- Read complete form metadata, including raw API objects.
- Understand question types, options, required state, and text validation.
- Resolve choice branching through stable question identifiers.
- Inspect matrix rows and their shared options.
- Inspect file count, size, and extension restrictions.
- Validate and serialize answers without submitting.
- Upload files through the authenticated Forms frontend.
- Submit only after explicit confirmation.
- Save and list response links in the signed-in account.
MCP tools
| Tool | Behavior |
|---|---|
forms_authenticate |
Opens visible browser login |
forms_inspect |
Returns normalized and raw form structure |
forms_validate |
Resolves branches and validates without submitting |
forms_upload_file |
Uploads a local file and returns answer metadata |
forms_submit |
Creates a response after elicited confirmation |
forms_save_response |
Saves an existing response link |
forms_list_saved_responses |
Lists saved response links |
forms_submit is marked destructive and non-idempotent. It uses MCP v2
multi-round-trip elicitation. Declined or false confirmation never reaches
submission code.
Cross-cutting workflow and safety guidance is also available through:
npx -y -p msforms-api@latest msforms-api guide
CLI
Run without installing globally:
# Sign in once
npx -y -p msforms-api@latest msforms-api auth
# Inspect a form
npx -y -p msforms-api@latest msforms-api inspect \
--form 'https://forms.cloud.microsoft/Pages/ResponsePage.aspx?id=...'
# Validate answers without submitting
npx -y -p msforms-api@latest msforms-api validate \
--form 'https://forms.cloud.microsoft/Pages/ResponsePage.aspx?id=...' \
--answers @answers.json
# Submit only when intended
npx -y -p msforms-api@latest msforms-api submit \
--form 'https://forms.cloud.microsoft/Pages/ResponsePage.aspx?id=...' \
--answers @answers.json \
--save-response \
--confirm
Frequent CLI users can install globally:
npm install --global msforms-api
msforms-api auth
Every command emits JSON. Add --compact for single-line output.
Authentication and local data
Authentication opens a visible browser and stores its profile under:
~/.msforms-api/browser-profile
The SDK uses that profile to obtain scoped Forms cookies, an anti-forgery token, and session metadata. It does not print or return those credentials. Normal reads and submissions use direct Forms HTTP requests. File upload is browser-assisted because the Forms frontend manages SharePoint authorization.
Override the profile or browser:
msforms-api --profile ~/.config/my-forms-profile --browser chrome auth
MCP environment variables:
| Variable | Purpose |
|---|---|
MSFORMS_PROFILE_DIRECTORY |
Persistent browser profile override |
MSFORMS_BROWSER_CHANNEL |
chrome or msedge |
MSFORMS_HEADLESS |
Set to false to show operational browser windows |
Delete ~/.msforms-api/browser-profile to remove the local session.
Answer format
Answers are keyed by exact question ID returned from forms_inspect.
| Question type | Input |
|---|---|
| Text | String |
| Single choice | Option label or ID |
| Multiple choice | Array of option labels or IDs |
| Date | YYYY-MM-DD string |
| Rating or NPS | Number |
| Ranking | Ordered array containing every option label or ID |
| Matrix row | Option label, or { "id": ..., "key": ... } |
| File upload | Array of objects returned by forms_upload_file |
Matrix answers use each row question ID, not the matrix group ID.
{
"text-question-id": "Ada Lovelace",
"multiple-choice-question-id": ["Desktop", "Laptop"],
"date-question-id": "2026-08-12",
"ranking-question-id": ["Branching", "Uploads", "Ratings"],
"matrix-row-question-id": { "label": "Agree" },
"file-question-id": [
{
"name": "document.pdf",
"uploadSessionUrl": "https://...",
"link": "https://...",
"badgerToken": null,
"time": 1786492949627,
"status": 3,
"id": "sharepoint-item-id"
}
]
}
SDK
npm install msforms-api
import { MicrosoftFormsClient } from "msforms-api";
const client = new MicrosoftFormsClient();
const form = await client.getForm(formUrl);
const answers = {
[form.questions[0].id]: "Example answer",
};
const validation = await client.validateAnswers(formUrl, answers);
if (!validation.valid) {
throw new Error(JSON.stringify(validation.issues));
}
const submission = await client.submitResponse(formUrl, answers, {
saveResponse: true,
});
submitResponse() is direct at SDK level. Applications using the SDK must
implement their own user confirmation boundary. CLI requires --confirm; MCP
requires elicitation.
Form structure
The normalized form model includes:
- IDs, titles, subtitles, order, type, and required state.
- Choice labels and
branchTargetIdvalues. - Matrix rows with inherited options.
- Text validation boundaries and rules.
- File upload restrictions.
- Parsed form settings.
- Full raw form and question objects for forward compatibility.
Example branch:
{
"id": "source-question-id",
"type": "Question.Choice",
"options": [
{
"label": "Yes",
"branchTargetId": "target-question-id"
}
]
}
forms_validate returns visible question IDs, issues, and the exact serialized
answer array. Questions skipped by branching are omitted.
How it works
Browser bootstrap exposes the anti-forgery token, server session ID, tenant, owner, current user, and form prefetch URL. The client combines that data with scoped Forms cookies for direct requests.
Observed endpoint families:
GET /formapi/api/{tenant}/users/{owner}/light/runtimeForms('{formId}')
POST /formapi/api/{tenant}/users/{owner}/forms('{formId}')/responses
POST /formapi/api/{tenant}/users/{owner}/runtimeForms('{formId}')/questions('{questionId}')/CreateUploadSession
POST /formapi/api/{tenant}/users/{user}/saveResponseLink
GET /formapi/api/{tenant}/users/{user}/getResponseLinks
The normalized model retains raw objects so newly introduced Forms properties remain inspectable before this package adds first-class support.
Limitations
- APIs are private and may change.
- File upload currently requires the upload question to be visible in the rendered branch.
- Authentication depends on Microsoft Forms web login behavior.
- The package is for legitimate form automation. Respect form owners, tenant policies, privacy requirements, and applicable law.
Development
See CONTRIBUTING.md.
npm install
npm run type-check
npm test
npm run format-check
npm run spell-check
npm run build
License
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。