Skip to main content
For the complete documentation index for agents and LLMs, see llms.txt.

MSSharePointRetriever

Search Microsoft SharePoint and OneDrive and retrieve matching content as Haystack Document objects. Use this component to find files, list items, and pages before fetching their full content.

Key Features

  • Runs full-text search over SharePoint and OneDrive via the Microsoft Search (Graph) API.
  • Returns search snippets as document content with rich metadata (file_name, web_url, entity_type, timestamps, and SharePoint identifiers).
  • Supports Keyword Query Language (KQL) filters in queries and query templates.
  • Configurable entity types, field selection, and result count.
  • Works with OAuthTokenResolver for per-user delegated access.

Configuration

Add Workspace-Level Integration

  1. Click your profile icon and choose Settings.
  2. Go to Workspace>Integrations.
  3. Find the provider you want to connect and click Connect next to them.
  4. Enter the API key and any other required details.
  5. Click Connect. You can use this integration in pipelines and indexes in the current workspace.

Add Organization-Level Integration

  1. Click your profile icon and choose Settings.
  2. Go to Organization>Integrations.
  3. Find the provider you want to connect and click Connect next to them.
  4. Enter the API key and any other required details.
  5. Click Connect. You can use this integration in pipelines and indexes in all workspaces in the current organization.
  1. Drag the MSSharePointRetriever component onto the canvas from the Component Library.
  2. Wire an upstream OAuthTokenResolver to provide a delegated Microsoft Graph bearer token on the access_token input.
  3. Set top_k to control the number of results.
  4. Go to the Advanced tab to configure entity_types, query_template, and fields.

The access token must carry delegated Microsoft Graph permissions, for example Files.Read.All and Sites.Read.All. The Search API supports delegated permissions only.

Connections

MSSharePointRetriever receives a search query and an access_token. It outputs a list of Document objects. Connect the documents output to MSSharePointFetcher for full file content, or to downstream components that process search snippets.

Source Code

To check this component's source code, open retriever.py in the Haystack Core Integrations repository.

Usage Examples

Basic Configuration

  MSSharePointRetriever:
type: haystack_integrations.components.retrievers.microsoft_sharepoint.retriever.MSSharePointRetriever
init_parameters:
top_k: 10

Using the Component in a Pipeline

# haystack-pipeline
components:
oauth_resolver:
type: haystack_integrations.components.connectors.oauth.resolver.OAuthTokenResolver
init_parameters:
token_source:
type: haystack_integrations.utils.oauth.sources.OAuthRefreshTokenSource
init_parameters:
token_url: https://login.microsoftonline.com/common/oauth2/v2.0/token
client_id: your-client-id
refresh_token:
type: env_var
env_vars:
- MS_REFRESH_TOKEN
strict: false
scopes:
- https://graph.microsoft.com/Files.Read.All
- https://graph.microsoft.com/Sites.Read.All

retriever:
type: haystack_integrations.components.retrievers.microsoft_sharepoint.retriever.MSSharePointRetriever
init_parameters:
top_k: 5
query_template: '{searchTerms} path:"https://contoso.sharepoint.com/sites/Team"'

connections:
- sender: oauth_resolver.access_token
receiver: retriever.access_token

inputs:
query:
- retriever.query

outputs:
documents: retriever.documents

Parameters

Inputs

ParameterTypeDescription
querystrSearch query string. Embed KQL operators directly, for example filetype:docx or path:"https://contoso.sharepoint.com/sites/Team".
access_tokenstr | SecretDelegated Microsoft Graph bearer token for the user whose content is searched.
top_kint | NoneOverrides the init-time top_k for this run.

Outputs

ParameterTypeDescription
documentsList[Document]Matching items as Haystack documents with search snippets and metadata.

Init Parameters

These are the parameters you can configure in Pipeline Builder:

ParameterTypeDefaultDescription
entity_typesList[str] | None["driveItem", "listItem"]Microsoft Search entity types to query. Also supports "list" and "site".
top_kint10Maximum number of documents to return.
fieldsList[str] | NoneNoneResource properties to request via the Search API fields selection.
query_templatestr | NoneNoneQuery template to scope the search. Use {searchTerms} as the placeholder for the run-time query.
graph_urlstrhttps://graph.microsoft.com/v1.0The Microsoft Graph base URL. Override for sovereign clouds.
timeoutfloat30.0HTTP timeout in seconds for each Graph API request.
max_retriesint3Maximum retries for throttled or transient server errors.

Run Method Parameters

These are the parameters you can configure for the component's run() method. This means you can pass these parameters at query time through the API, in Playground, or when running a job. For details, see Modify Pipeline Parameters at Query Time.

ParameterTypeDefaultDescription
querystrSearch query string.
access_tokenstr | SecretDelegated Microsoft Graph bearer token.
top_kint | NoneNoneMaximum number of documents to return. Overrides the init-time value.