Skip to content

Commit e2a9449

Browse files
authored
Fix: fix excel to add worksheet (#754)
Signed-off-by: Daishan Peng <daishan@acorn.io>
1 parent 0abec42 commit e2a9449

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

microsoft365/excel-mcp-go/main.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919
"github.com/google/jsonschema-go/jsonschema"
2020
"github.com/microsoft/kiota-abstractions-go/serialization"
2121
msgraphsdkgo "github.com/microsoftgraph/msgraph-sdk-go"
22+
"github.com/microsoftgraph/msgraph-sdk-go/drives"
2223
"github.com/microsoftgraph/msgraph-sdk-go/models"
2324
"github.com/modelcontextprotocol/go-sdk/mcp"
2425
util "github.com/obot-platform/tools/microsoft365/excel-mcp-go/utils"
@@ -583,9 +584,12 @@ func (e *ExcelMCPServer) CreateWorksheet(ctx context.Context, req *mcp.CallToolR
583584
return nil, nil, fmt.Errorf("failed to retrieve user's drive ID")
584585
}
585586

587+
requestBody := drives.NewItemItemsItemWorkbookWorksheetsAddPostRequestBody()
588+
requestBody.SetName(util.Ptr(args.Name))
589+
586590
// Create new worksheet
587591
_, err = e.client.Drives().ByDriveId(*drive.GetId()).Items().ByDriveItemId(args.WorkbookID).
588-
Workbook().Worksheets().Post(ctx, nil, nil)
592+
Workbook().Worksheets().Add().Post(ctx, requestBody, nil)
589593
if err != nil {
590594
return nil, nil, fmt.Errorf("failed to create worksheet: %w", err)
591595
}

0 commit comments

Comments
 (0)