fastmcp/tests/resources
Marcus Shu 2d7bc4e73d
Add encoding parameter to FileResource (#3580)
* feat: Add encoding parameter to FileResource

- Add optional encoding field (str | None, default None) to FileResource.
- Pass encoding through to read_text() for cross-platform text file reading.
- Preserve backward compatibility by defaulting to system encoding.

* test: Add tests for FileResource encoding parameter

- Test UTF-8 reading with explicit encoding for non-ASCII content.
- Test backward compatibility when no encoding is specified.
- Test that encoding is ignored for binary file reads.
- Test Latin-1 reading with matching encoding.

* docs: Document FileResource encoding parameter

- Add encoding="utf-8" to FileResource example in resource classes guide.
- Update FileResource description to mention encoding support.

* feat: Change FileResource encoding default from None to utf-8

- Default to utf-8 instead of system encoding to prevent cross-platform footgun.
- Update field description to reflect new default.
- Update test to verify default encoding is utf-8 with non-ASCII content.
- Remove redundant encoding="utf-8" from docs example since it is now the default.
2026-03-22 09:55:16 -04:00
..
__init__.py restore 1.x code 2025-04-09 11:54:42 -04:00
test_file_resources.py Add encoding parameter to FileResource (#3580) 2026-03-22 09:55:16 -04:00
test_function_resources.py fix: resolve Pyright "Module is not callable" on @tool, @resource, @prompt decorators (#3540) 2026-03-17 18:11:42 -04:00
test_resource_template.py fix: handle re.error from malformed URI templates in build_regex (#3501) 2026-03-14 16:34:06 -04:00
test_resource_template_meta.py Add meta parameter support to tools, resources, templates, and prompts decorators (#1294) 2025-07-29 17:16:05 -04:00
test_resource_template_query_params.py Raise ValueError for invalid boolean query params in resource templates (#3424) (#3434) 2026-03-07 11:40:29 -05:00
test_resources.py Add loq file size limits and clean up type ignores (#2859) 2026-01-13 07:29:12 -05:00
test_standalone_decorator.py Decorators return functions instead of component objects (#2856) 2026-01-12 21:58:07 -05:00